babylon.module.d.ts 5.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766
  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. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts current color in rgb space to HSV values
  466. * @returns a new color3 representing the HSV values
  467. */
  468. toHSV(): Color3;
  469. /**
  470. * Converts current color in rgb space to HSV values
  471. * @param result defines the Color3 where to store the HSV values
  472. */
  473. toHSVToRef(result: Color3): void;
  474. /**
  475. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  476. * @param convertedColor defines the Color3 object where to store the linear space version
  477. * @returns the unmodified Color3
  478. */
  479. toLinearSpaceToRef(convertedColor: Color3): Color3;
  480. /**
  481. * Computes a new Color3 converted from the current one to gamma space
  482. * @returns a new Color3 object
  483. */
  484. toGammaSpace(): Color3;
  485. /**
  486. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  487. * @param convertedColor defines the Color3 object where to store the gamma space version
  488. * @returns the unmodified Color3
  489. */
  490. toGammaSpaceToRef(convertedColor: Color3): Color3;
  491. private static _BlackReadOnly;
  492. /**
  493. * Convert Hue, saturation and value to a Color3 (RGB)
  494. * @param hue defines the hue
  495. * @param saturation defines the saturation
  496. * @param value defines the value
  497. * @param result defines the Color3 where to store the RGB values
  498. */
  499. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  500. /**
  501. * Creates a new Color3 from the string containing valid hexadecimal values
  502. * @param hex defines a string containing valid hexadecimal values
  503. * @returns a new Color3 object
  504. */
  505. static FromHexString(hex: string): Color3;
  506. /**
  507. * Creates a new Color3 from the starting index of the given array
  508. * @param array defines the source array
  509. * @param offset defines an offset in the source array
  510. * @returns a new Color3 object
  511. */
  512. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  513. /**
  514. * Creates a new Color3 from integer values (< 256)
  515. * @param r defines the red component to read from (value between 0 and 255)
  516. * @param g defines the green component to read from (value between 0 and 255)
  517. * @param b defines the blue component to read from (value between 0 and 255)
  518. * @returns a new Color3 object
  519. */
  520. static FromInts(r: number, g: number, b: number): Color3;
  521. /**
  522. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  523. * @param start defines the start Color3 value
  524. * @param end defines the end Color3 value
  525. * @param amount defines the gradient value between start and end
  526. * @returns a new Color3 object
  527. */
  528. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  529. /**
  530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  531. * @param left defines the start value
  532. * @param right defines the end value
  533. * @param amount defines the gradient factor
  534. * @param result defines the Color3 object where to store the result
  535. */
  536. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  537. /**
  538. * Returns a Color3 value containing a red color
  539. * @returns a new Color3 object
  540. */
  541. static Red(): Color3;
  542. /**
  543. * Returns a Color3 value containing a green color
  544. * @returns a new Color3 object
  545. */
  546. static Green(): Color3;
  547. /**
  548. * Returns a Color3 value containing a blue color
  549. * @returns a new Color3 object
  550. */
  551. static Blue(): Color3;
  552. /**
  553. * Returns a Color3 value containing a black color
  554. * @returns a new Color3 object
  555. */
  556. static Black(): Color3;
  557. /**
  558. * Gets a Color3 value containing a black color that must not be updated
  559. */
  560. static readonly BlackReadOnly: DeepImmutable<Color3>;
  561. /**
  562. * Returns a Color3 value containing a white color
  563. * @returns a new Color3 object
  564. */
  565. static White(): Color3;
  566. /**
  567. * Returns a Color3 value containing a purple color
  568. * @returns a new Color3 object
  569. */
  570. static Purple(): Color3;
  571. /**
  572. * Returns a Color3 value containing a magenta color
  573. * @returns a new Color3 object
  574. */
  575. static Magenta(): Color3;
  576. /**
  577. * Returns a Color3 value containing a yellow color
  578. * @returns a new Color3 object
  579. */
  580. static Yellow(): Color3;
  581. /**
  582. * Returns a Color3 value containing a gray color
  583. * @returns a new Color3 object
  584. */
  585. static Gray(): Color3;
  586. /**
  587. * Returns a Color3 value containing a teal color
  588. * @returns a new Color3 object
  589. */
  590. static Teal(): Color3;
  591. /**
  592. * Returns a Color3 value containing a random color
  593. * @returns a new Color3 object
  594. */
  595. static Random(): Color3;
  596. }
  597. /**
  598. * Class used to hold a RBGA color
  599. */
  600. export class Color4 {
  601. /**
  602. * Defines the red component (between 0 and 1, default is 0)
  603. */
  604. r: number;
  605. /**
  606. * Defines the green component (between 0 and 1, default is 0)
  607. */
  608. g: number;
  609. /**
  610. * Defines the blue component (between 0 and 1, default is 0)
  611. */
  612. b: number;
  613. /**
  614. * Defines the alpha component (between 0 and 1, default is 1)
  615. */
  616. a: number;
  617. /**
  618. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  619. * @param r defines the red component (between 0 and 1, default is 0)
  620. * @param g defines the green component (between 0 and 1, default is 0)
  621. * @param b defines the blue component (between 0 and 1, default is 0)
  622. * @param a defines the alpha component (between 0 and 1, default is 1)
  623. */
  624. constructor(
  625. /**
  626. * Defines the red component (between 0 and 1, default is 0)
  627. */
  628. r?: number,
  629. /**
  630. * Defines the green component (between 0 and 1, default is 0)
  631. */
  632. g?: number,
  633. /**
  634. * Defines the blue component (between 0 and 1, default is 0)
  635. */
  636. b?: number,
  637. /**
  638. * Defines the alpha component (between 0 and 1, default is 1)
  639. */
  640. a?: number);
  641. /**
  642. * Adds in place the given Color4 values to the current Color4 object
  643. * @param right defines the second operand
  644. * @returns the current updated Color4 object
  645. */
  646. addInPlace(right: DeepImmutable<Color4>): Color4;
  647. /**
  648. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  649. * @returns the new array
  650. */
  651. asArray(): number[];
  652. /**
  653. * Stores from the starting index in the given array the Color4 successive values
  654. * @param array defines the array where to store the r,g,b components
  655. * @param index defines an optional index in the target array to define where to start storing values
  656. * @returns the current Color4 object
  657. */
  658. toArray(array: number[], index?: number): Color4;
  659. /**
  660. * Determines equality between Color4 objects
  661. * @param otherColor defines the second operand
  662. * @returns true if the rgba values are equal to the given ones
  663. */
  664. equals(otherColor: DeepImmutable<Color4>): boolean;
  665. /**
  666. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  667. * @param right defines the second operand
  668. * @returns a new Color4 object
  669. */
  670. add(right: DeepImmutable<Color4>): Color4;
  671. /**
  672. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  673. * @param right defines the second operand
  674. * @returns a new Color4 object
  675. */
  676. subtract(right: DeepImmutable<Color4>): Color4;
  677. /**
  678. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  679. * @param right defines the second operand
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the current Color4 object
  682. */
  683. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  684. /**
  685. * Creates a new Color4 with the current Color4 values multiplied by scale
  686. * @param scale defines the scaling factor to apply
  687. * @returns a new Color4 object
  688. */
  689. scale(scale: number): Color4;
  690. /**
  691. * Multiplies the current Color4 values by scale and stores the result in "result"
  692. * @param scale defines the scaling factor to apply
  693. * @param result defines the Color4 object where to store the result
  694. * @returns the current unmodified Color4
  695. */
  696. scaleToRef(scale: number, result: Color4): Color4;
  697. /**
  698. * Scale the current Color4 values by a factor and add the result to a given Color4
  699. * @param scale defines the scale factor
  700. * @param result defines the Color4 object where to store the result
  701. * @returns the unmodified current Color4
  702. */
  703. scaleAndAddToRef(scale: number, result: Color4): Color4;
  704. /**
  705. * Clamps the rgb values by the min and max values and stores the result into "result"
  706. * @param min defines minimum clamping value (default is 0)
  707. * @param max defines maximum clamping value (default is 1)
  708. * @param result defines color to store the result into.
  709. * @returns the cuurent Color4
  710. */
  711. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  712. /**
  713. * Multipy an Color4 value by another and return a new Color4 object
  714. * @param color defines the Color4 value to multiply by
  715. * @returns a new Color4 object
  716. */
  717. multiply(color: Color4): Color4;
  718. /**
  719. * Multipy a Color4 value by another and push the result in a reference value
  720. * @param color defines the Color4 value to multiply by
  721. * @param result defines the Color4 to fill the result in
  722. * @returns the result Color4
  723. */
  724. multiplyToRef(color: Color4, result: Color4): Color4;
  725. /**
  726. * Creates a string with the Color4 current values
  727. * @returns the string representation of the Color4 object
  728. */
  729. toString(): string;
  730. /**
  731. * Returns the string "Color4"
  732. * @returns "Color4"
  733. */
  734. getClassName(): string;
  735. /**
  736. * Compute the Color4 hash code
  737. * @returns an unique number that can be used to hash Color4 objects
  738. */
  739. getHashCode(): number;
  740. /**
  741. * Creates a new Color4 copied from the current one
  742. * @returns a new Color4 object
  743. */
  744. clone(): Color4;
  745. /**
  746. * Copies the given Color4 values into the current one
  747. * @param source defines the source Color4 object
  748. * @returns the current updated Color4 object
  749. */
  750. copyFrom(source: Color4): Color4;
  751. /**
  752. * Copies the given float values into the current one
  753. * @param r defines the red component to read from
  754. * @param g defines the green component to read from
  755. * @param b defines the blue component to read from
  756. * @param a defines the alpha component to read from
  757. * @returns the current updated Color4 object
  758. */
  759. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  760. /**
  761. * Copies the given float values into the current one
  762. * @param r defines the red component to read from
  763. * @param g defines the green component to read from
  764. * @param b defines the blue component to read from
  765. * @param a defines the alpha component to read from
  766. * @returns the current updated Color4 object
  767. */
  768. set(r: number, g: number, b: number, a: number): Color4;
  769. /**
  770. * Compute the Color4 hexadecimal code as a string
  771. * @returns a string containing the hexadecimal representation of the Color4 object
  772. */
  773. toHexString(): string;
  774. /**
  775. * Computes a new Color4 converted from the current one to linear space
  776. * @returns a new Color4 object
  777. */
  778. toLinearSpace(): Color4;
  779. /**
  780. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  781. * @param convertedColor defines the Color4 object where to store the linear space version
  782. * @returns the unmodified Color4
  783. */
  784. toLinearSpaceToRef(convertedColor: Color4): Color4;
  785. /**
  786. * Computes a new Color4 converted from the current one to gamma space
  787. * @returns a new Color4 object
  788. */
  789. toGammaSpace(): Color4;
  790. /**
  791. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  792. * @param convertedColor defines the Color4 object where to store the gamma space version
  793. * @returns the unmodified Color4
  794. */
  795. toGammaSpaceToRef(convertedColor: Color4): Color4;
  796. /**
  797. * Creates a new Color4 from the string containing valid hexadecimal values
  798. * @param hex defines a string containing valid hexadecimal values
  799. * @returns a new Color4 object
  800. */
  801. static FromHexString(hex: string): Color4;
  802. /**
  803. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  804. * @param left defines the start value
  805. * @param right defines the end value
  806. * @param amount defines the gradient factor
  807. * @returns a new Color4 object
  808. */
  809. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  810. /**
  811. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  812. * @param left defines the start value
  813. * @param right defines the end value
  814. * @param amount defines the gradient factor
  815. * @param result defines the Color4 object where to store data
  816. */
  817. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  818. /**
  819. * Creates a new Color4 from a Color3 and an alpha value
  820. * @param color3 defines the source Color3 to read from
  821. * @param alpha defines the alpha component (1.0 by default)
  822. * @returns a new Color4 object
  823. */
  824. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  825. /**
  826. * Creates a new Color4 from the starting index element of the given array
  827. * @param array defines the source array to read from
  828. * @param offset defines the offset in the source array
  829. * @returns a new Color4 object
  830. */
  831. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  832. /**
  833. * Creates a new Color3 from integer values (< 256)
  834. * @param r defines the red component to read from (value between 0 and 255)
  835. * @param g defines the green component to read from (value between 0 and 255)
  836. * @param b defines the blue component to read from (value between 0 and 255)
  837. * @param a defines the alpha component to read from (value between 0 and 255)
  838. * @returns a new Color3 object
  839. */
  840. static FromInts(r: number, g: number, b: number, a: number): Color4;
  841. /**
  842. * Check the content of a given array and convert it to an array containing RGBA data
  843. * If the original array was already containing count * 4 values then it is returned directly
  844. * @param colors defines the array to check
  845. * @param count defines the number of RGBA data to expect
  846. * @returns an array containing count * 4 values (RGBA)
  847. */
  848. static CheckColors4(colors: number[], count: number): number[];
  849. }
  850. /**
  851. * Class representing a vector containing 2 coordinates
  852. */
  853. export class Vector2 {
  854. /** defines the first coordinate */
  855. x: number;
  856. /** defines the second coordinate */
  857. y: number;
  858. /**
  859. * Creates a new Vector2 from the given x and y coordinates
  860. * @param x defines the first coordinate
  861. * @param y defines the second coordinate
  862. */
  863. constructor(
  864. /** defines the first coordinate */
  865. x?: number,
  866. /** defines the second coordinate */
  867. y?: number);
  868. /**
  869. * Gets a string with the Vector2 coordinates
  870. * @returns a string with the Vector2 coordinates
  871. */
  872. toString(): string;
  873. /**
  874. * Gets class name
  875. * @returns the string "Vector2"
  876. */
  877. getClassName(): string;
  878. /**
  879. * Gets current vector hash code
  880. * @returns the Vector2 hash code as a number
  881. */
  882. getHashCode(): number;
  883. /**
  884. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  885. * @param array defines the source array
  886. * @param index defines the offset in source array
  887. * @returns the current Vector2
  888. */
  889. toArray(array: FloatArray, index?: number): Vector2;
  890. /**
  891. * Copy the current vector to an array
  892. * @returns a new array with 2 elements: the Vector2 coordinates.
  893. */
  894. asArray(): number[];
  895. /**
  896. * Sets the Vector2 coordinates with the given Vector2 coordinates
  897. * @param source defines the source Vector2
  898. * @returns the current updated Vector2
  899. */
  900. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. copyFromFloats(x: number, y: number): Vector2;
  908. /**
  909. * Sets the Vector2 coordinates with the given floats
  910. * @param x defines the first coordinate
  911. * @param y defines the second coordinate
  912. * @returns the current updated Vector2
  913. */
  914. set(x: number, y: number): Vector2;
  915. /**
  916. * Add another vector with the current one
  917. * @param otherVector defines the other vector
  918. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  919. */
  920. add(otherVector: DeepImmutable<Vector2>): Vector2;
  921. /**
  922. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  923. * @param otherVector defines the other vector
  924. * @param result defines the target vector
  925. * @returns the unmodified current Vector2
  926. */
  927. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  928. /**
  929. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  930. * @param otherVector defines the other vector
  931. * @returns the current updated Vector2
  932. */
  933. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  936. * @param otherVector defines the other vector
  937. * @returns a new Vector2
  938. */
  939. addVector3(otherVector: Vector3): Vector2;
  940. /**
  941. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  942. * @param otherVector defines the other vector
  943. * @returns a new Vector2
  944. */
  945. subtract(otherVector: Vector2): Vector2;
  946. /**
  947. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  948. * @param otherVector defines the other vector
  949. * @param result defines the target vector
  950. * @returns the unmodified current Vector2
  951. */
  952. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  953. /**
  954. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @returns the current updated Vector2
  957. */
  958. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  959. /**
  960. * Multiplies in place the current Vector2 coordinates by the given ones
  961. * @param otherVector defines the other vector
  962. * @returns the current updated Vector2
  963. */
  964. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  971. /**
  972. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  980. * @param x defines the first coordinate
  981. * @param y defines the second coordinate
  982. * @returns a new Vector2
  983. */
  984. multiplyByFloats(x: number, y: number): Vector2;
  985. /**
  986. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  987. * @param otherVector defines the other vector
  988. * @returns a new Vector2
  989. */
  990. divide(otherVector: Vector2): Vector2;
  991. /**
  992. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  993. * @param otherVector defines the other vector
  994. * @param result defines the target vector
  995. * @returns the unmodified current Vector2
  996. */
  997. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  998. /**
  999. * Divides the current Vector2 coordinates by the given ones
  1000. * @param otherVector defines the other vector
  1001. * @returns the current updated Vector2
  1002. */
  1003. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1004. /**
  1005. * Gets a new Vector2 with current Vector2 negated coordinates
  1006. * @returns a new Vector2
  1007. */
  1008. negate(): Vector2;
  1009. /**
  1010. * Multiply the Vector2 coordinates by scale
  1011. * @param scale defines the scaling factor
  1012. * @returns the current updated Vector2
  1013. */
  1014. scaleInPlace(scale: number): Vector2;
  1015. /**
  1016. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1017. * @param scale defines the scaling factor
  1018. * @returns a new Vector2
  1019. */
  1020. scale(scale: number): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1030. * @param scale defines the scale factor
  1031. * @param result defines the Vector2 object where to store the result
  1032. * @returns the unmodified current Vector2
  1033. */
  1034. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1035. /**
  1036. * Gets a boolean if two vectors are equals
  1037. * @param otherVector defines the other vector
  1038. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1039. */
  1040. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1041. /**
  1042. * Gets a boolean if two vectors are equals (using an epsilon value)
  1043. * @param otherVector defines the other vector
  1044. * @param epsilon defines the minimal distance to consider equality
  1045. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1046. */
  1047. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1048. /**
  1049. * Gets a new Vector2 from current Vector2 floored values
  1050. * @returns a new Vector2
  1051. */
  1052. floor(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 from current Vector2 floored values
  1055. * @returns a new Vector2
  1056. */
  1057. fract(): Vector2;
  1058. /**
  1059. * Gets the length of the vector
  1060. * @returns the vector length (float)
  1061. */
  1062. length(): number;
  1063. /**
  1064. * Gets the vector squared length
  1065. * @returns the vector squared length (float)
  1066. */
  1067. lengthSquared(): number;
  1068. /**
  1069. * Normalize the vector
  1070. * @returns the current updated Vector2
  1071. */
  1072. normalize(): Vector2;
  1073. /**
  1074. * Gets a new Vector2 copied from the Vector2
  1075. * @returns a new Vector2
  1076. */
  1077. clone(): Vector2;
  1078. /**
  1079. * Gets a new Vector2(0, 0)
  1080. * @returns a new Vector2
  1081. */
  1082. static Zero(): Vector2;
  1083. /**
  1084. * Gets a new Vector2(1, 1)
  1085. * @returns a new Vector2
  1086. */
  1087. static One(): Vector2;
  1088. /**
  1089. * Gets a new Vector2 set from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @returns a new Vector2
  1093. */
  1094. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1095. /**
  1096. * Sets "result" from the given index element of the given array
  1097. * @param array defines the data source
  1098. * @param offset defines the offset in the data source
  1099. * @param result defines the target vector
  1100. */
  1101. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1102. /**
  1103. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1104. * @param value1 defines 1st point of control
  1105. * @param value2 defines 2nd point of control
  1106. * @param value3 defines 3rd point of control
  1107. * @param value4 defines 4th point of control
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * 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".
  1114. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1115. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1116. * @param value defines the value to clamp
  1117. * @param min defines the lower limit
  1118. * @param max defines the upper limit
  1119. * @returns a new Vector2
  1120. */
  1121. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1122. /**
  1123. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1124. * @param value1 defines the 1st control point
  1125. * @param tangent1 defines the outgoing tangent
  1126. * @param value2 defines the 2nd control point
  1127. * @param tangent2 defines the incoming tangent
  1128. * @param amount defines the interpolation factor
  1129. * @returns a new Vector2
  1130. */
  1131. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1132. /**
  1133. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1134. * @param start defines the start vector
  1135. * @param end defines the end vector
  1136. * @param amount defines the interpolation factor
  1137. * @returns a new Vector2
  1138. */
  1139. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1140. /**
  1141. * Gets the dot product of the vector "left" and the vector "right"
  1142. * @param left defines first vector
  1143. * @param right defines second vector
  1144. * @returns the dot product (float)
  1145. */
  1146. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1147. /**
  1148. * Returns a new Vector2 equal to the normalized given vector
  1149. * @param vector defines the vector to normalize
  1150. * @returns a new Vector2
  1151. */
  1152. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1162. * @param left defines 1st vector
  1163. * @param right defines 2nd vector
  1164. * @returns a new Vector2
  1165. */
  1166. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1167. /**
  1168. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @returns a new Vector2
  1172. */
  1173. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1174. /**
  1175. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1176. * @param vector defines the vector to transform
  1177. * @param transformation defines the matrix to apply
  1178. * @param result defines the target vector
  1179. */
  1180. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1181. /**
  1182. * Determines if a given vector is included in a triangle
  1183. * @param p defines the vector to test
  1184. * @param p0 defines 1st triangle point
  1185. * @param p1 defines 2nd triangle point
  1186. * @param p2 defines 3rd triangle point
  1187. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1188. */
  1189. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1190. /**
  1191. * Gets the distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the distance between vectors
  1195. */
  1196. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Returns the squared distance between the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns the squared distance between vectors
  1202. */
  1203. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1204. /**
  1205. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1206. * @param value1 defines first vector
  1207. * @param value2 defines second vector
  1208. * @returns a new Vector2
  1209. */
  1210. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1211. /**
  1212. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1213. * @param p defines the middle point
  1214. * @param segA defines one point of the segment
  1215. * @param segB defines the other point of the segment
  1216. * @returns the shortest distance
  1217. */
  1218. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1219. }
  1220. /**
  1221. * Classed used to store (x,y,z) vector representation
  1222. * A Vector3 is the main object used in 3D geometry
  1223. * It can represent etiher the coordinates of a point the space, either a direction
  1224. * Reminder: js uses a left handed forward facing system
  1225. */
  1226. export class Vector3 {
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x: number;
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y: number;
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z: number;
  1239. private static _UpReadOnly;
  1240. private static _ZeroReadOnly;
  1241. /**
  1242. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1243. * @param x defines the first coordinates (on X axis)
  1244. * @param y defines the second coordinates (on Y axis)
  1245. * @param z defines the third coordinates (on Z axis)
  1246. */
  1247. constructor(
  1248. /**
  1249. * Defines the first coordinates (on X axis)
  1250. */
  1251. x?: number,
  1252. /**
  1253. * Defines the second coordinates (on Y axis)
  1254. */
  1255. y?: number,
  1256. /**
  1257. * Defines the third coordinates (on Z axis)
  1258. */
  1259. z?: number);
  1260. /**
  1261. * Creates a string representation of the Vector3
  1262. * @returns a string with the Vector3 coordinates.
  1263. */
  1264. toString(): string;
  1265. /**
  1266. * Gets the class name
  1267. * @returns the string "Vector3"
  1268. */
  1269. getClassName(): string;
  1270. /**
  1271. * Creates the Vector3 hash code
  1272. * @returns a number which tends to be unique between Vector3 instances
  1273. */
  1274. getHashCode(): number;
  1275. /**
  1276. * Creates an array containing three elements : the coordinates of the Vector3
  1277. * @returns a new array of numbers
  1278. */
  1279. asArray(): number[];
  1280. /**
  1281. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1282. * @param array defines the destination array
  1283. * @param index defines the offset in the destination array
  1284. * @returns the current Vector3
  1285. */
  1286. toArray(array: FloatArray, index?: number): Vector3;
  1287. /**
  1288. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1289. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1290. */
  1291. toQuaternion(): Quaternion;
  1292. /**
  1293. * Adds the given vector to the current Vector3
  1294. * @param otherVector defines the second operand
  1295. * @returns the current updated Vector3
  1296. */
  1297. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1298. /**
  1299. * Adds the given coordinates to the current Vector3
  1300. * @param x defines the x coordinate of the operand
  1301. * @param y defines the y coordinate of the operand
  1302. * @param z defines the z coordinate of the operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1306. /**
  1307. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Subtract the given vector from the current Vector3
  1321. * @param otherVector defines the second operand
  1322. * @returns the current updated Vector3
  1323. */
  1324. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1327. * @param otherVector defines the second operand
  1328. * @returns the resulting Vector3
  1329. */
  1330. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1331. /**
  1332. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1333. * @param otherVector defines the second operand
  1334. * @param result defines the Vector3 object where to store the result
  1335. * @returns the current Vector3
  1336. */
  1337. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1338. /**
  1339. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1340. * @param x defines the x coordinate of the operand
  1341. * @param y defines the y coordinate of the operand
  1342. * @param z defines the z coordinate of the operand
  1343. * @returns the resulting Vector3
  1344. */
  1345. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1346. /**
  1347. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1348. * @param x defines the x coordinate of the operand
  1349. * @param y defines the y coordinate of the operand
  1350. * @param z defines the z coordinate of the operand
  1351. * @param result defines the Vector3 object where to store the result
  1352. * @returns the current Vector3
  1353. */
  1354. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1355. /**
  1356. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1357. * @returns a new Vector3
  1358. */
  1359. negate(): Vector3;
  1360. /**
  1361. * Multiplies the Vector3 coordinates by the float "scale"
  1362. * @param scale defines the multiplier factor
  1363. * @returns the current updated Vector3
  1364. */
  1365. scaleInPlace(scale: number): Vector3;
  1366. /**
  1367. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1368. * @param scale defines the multiplier factor
  1369. * @returns a new Vector3
  1370. */
  1371. scale(scale: number): Vector3;
  1372. /**
  1373. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1374. * @param scale defines the multiplier factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the current Vector3
  1377. */
  1378. scaleToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1381. * @param scale defines the scale factor
  1382. * @param result defines the Vector3 object where to store the result
  1383. * @returns the unmodified current Vector3
  1384. */
  1385. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1386. /**
  1387. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1388. * @param otherVector defines the second operand
  1389. * @returns true if both vectors are equals
  1390. */
  1391. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1394. * @param otherVector defines the second operand
  1395. * @param epsilon defines the minimal distance to define values as equals
  1396. * @returns true if both vectors are distant less than epsilon
  1397. */
  1398. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1399. /**
  1400. * Returns true if the current Vector3 coordinates equals the given floats
  1401. * @param x defines the x coordinate of the operand
  1402. * @param y defines the y coordinate of the operand
  1403. * @param z defines the z coordinate of the operand
  1404. * @returns true if both vectors are equals
  1405. */
  1406. equalsToFloats(x: number, y: number, z: number): boolean;
  1407. /**
  1408. * Multiplies the current Vector3 coordinates by the given ones
  1409. * @param otherVector defines the second operand
  1410. * @returns the current updated Vector3
  1411. */
  1412. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1413. /**
  1414. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1428. * @param x defines the x coordinate of the operand
  1429. * @param y defines the y coordinate of the operand
  1430. * @param z defines the z coordinate of the operand
  1431. * @returns the new Vector3
  1432. */
  1433. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1436. * @param otherVector defines the second operand
  1437. * @returns the new Vector3
  1438. */
  1439. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1442. * @param otherVector defines the second operand
  1443. * @param result defines the Vector3 object where to store the result
  1444. * @returns the current Vector3
  1445. */
  1446. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1447. /**
  1448. * Divides the current Vector3 coordinates by the given ones.
  1449. * @param otherVector defines the second operand
  1450. * @returns the current updated Vector3
  1451. */
  1452. divideInPlace(otherVector: Vector3): Vector3;
  1453. /**
  1454. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1455. * @param other defines the second operand
  1456. * @returns the current updated Vector3
  1457. */
  1458. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1459. /**
  1460. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1461. * @param other defines the second operand
  1462. * @returns the current updated Vector3
  1463. */
  1464. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1465. /**
  1466. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1467. * @param x defines the x coordinate of the operand
  1468. * @param y defines the y coordinate of the operand
  1469. * @param z defines the z coordinate of the operand
  1470. * @returns the current updated Vector3
  1471. */
  1472. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1473. /**
  1474. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1475. * @param x defines the x coordinate of the operand
  1476. * @param y defines the y coordinate of the operand
  1477. * @param z defines the z coordinate of the operand
  1478. * @returns the current updated Vector3
  1479. */
  1480. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1481. /**
  1482. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1483. * Check if is non uniform within a certain amount of decimal places to account for this
  1484. * @param epsilon the amount the values can differ
  1485. * @returns if the the vector is non uniform to a certain number of decimal places
  1486. */
  1487. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1488. /**
  1489. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1490. */
  1491. readonly isNonUniform: boolean;
  1492. /**
  1493. * Gets a new Vector3 from current Vector3 floored values
  1494. * @returns a new Vector3
  1495. */
  1496. floor(): Vector3;
  1497. /**
  1498. * Gets a new Vector3 from current Vector3 floored values
  1499. * @returns a new Vector3
  1500. */
  1501. fract(): Vector3;
  1502. /**
  1503. * Gets the length of the Vector3
  1504. * @returns the length of the Vecto3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 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. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * 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)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * 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
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. 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;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. 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;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * 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"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * 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".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * 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"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * 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".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * 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.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * 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.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * 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).
  4352. * 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.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @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.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** 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 */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** 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 */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** 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 */
  4523. static readonly GEQUAL: number;
  4524. /** 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 */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * 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.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * 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.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5297. /** @hidden */
  5298. export interface IShaderProcessor {
  5299. attributeProcessor?: (attribute: string) => string;
  5300. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5301. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5302. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5303. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5304. lineProcessor?: (line: string, isFragment: boolean) => string;
  5305. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5306. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5307. }
  5308. }
  5309. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5310. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5311. /** @hidden */
  5312. export interface ProcessingOptions {
  5313. defines: string[];
  5314. indexParameters: any;
  5315. isFragment: boolean;
  5316. shouldUseHighPrecisionShader: boolean;
  5317. supportsUniformBuffers: boolean;
  5318. shadersRepository: string;
  5319. includesShadersStore: {
  5320. [key: string]: string;
  5321. };
  5322. processor?: IShaderProcessor;
  5323. version: string;
  5324. platformName: string;
  5325. lookForClosingBracketForUniformBuffer?: boolean;
  5326. }
  5327. }
  5328. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5329. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5330. /** @hidden */
  5331. export class ShaderCodeNode {
  5332. line: string;
  5333. children: ShaderCodeNode[];
  5334. additionalDefineKey?: string;
  5335. additionalDefineValue?: string;
  5336. isValid(preprocessors: {
  5337. [key: string]: string;
  5338. }): boolean;
  5339. process(preprocessors: {
  5340. [key: string]: string;
  5341. }, options: ProcessingOptions): string;
  5342. }
  5343. }
  5344. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5345. /** @hidden */
  5346. export class ShaderCodeCursor {
  5347. private _lines;
  5348. lineIndex: number;
  5349. readonly currentLine: string;
  5350. readonly canRead: boolean;
  5351. lines: string[];
  5352. }
  5353. }
  5354. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5355. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5356. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5357. /** @hidden */
  5358. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5359. process(preprocessors: {
  5360. [key: string]: string;
  5361. }, options: ProcessingOptions): string;
  5362. }
  5363. }
  5364. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5365. /** @hidden */
  5366. export class ShaderDefineExpression {
  5367. isTrue(preprocessors: {
  5368. [key: string]: string;
  5369. }): boolean;
  5370. }
  5371. }
  5372. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5373. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5374. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5375. /** @hidden */
  5376. export class ShaderCodeTestNode extends ShaderCodeNode {
  5377. testExpression: ShaderDefineExpression;
  5378. isValid(preprocessors: {
  5379. [key: string]: string;
  5380. }): boolean;
  5381. }
  5382. }
  5383. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5384. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5385. /** @hidden */
  5386. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5387. define: string;
  5388. not: boolean;
  5389. constructor(define: string, not?: boolean);
  5390. isTrue(preprocessors: {
  5391. [key: string]: string;
  5392. }): boolean;
  5393. }
  5394. }
  5395. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5396. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5397. /** @hidden */
  5398. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5399. leftOperand: ShaderDefineExpression;
  5400. rightOperand: ShaderDefineExpression;
  5401. isTrue(preprocessors: {
  5402. [key: string]: string;
  5403. }): boolean;
  5404. }
  5405. }
  5406. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5407. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5408. /** @hidden */
  5409. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5410. leftOperand: ShaderDefineExpression;
  5411. rightOperand: ShaderDefineExpression;
  5412. isTrue(preprocessors: {
  5413. [key: string]: string;
  5414. }): boolean;
  5415. }
  5416. }
  5417. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5418. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5419. /** @hidden */
  5420. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5421. define: string;
  5422. operand: string;
  5423. testValue: string;
  5424. constructor(define: string, operand: string, testValue: string);
  5425. isTrue(preprocessors: {
  5426. [key: string]: string;
  5427. }): boolean;
  5428. }
  5429. }
  5430. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5431. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5432. /** @hidden */
  5433. export class ShaderProcessor {
  5434. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5435. private static _ProcessPrecision;
  5436. private static _ExtractOperation;
  5437. private static _BuildSubExpression;
  5438. private static _BuildExpression;
  5439. private static _MoveCursorWithinIf;
  5440. private static _MoveCursor;
  5441. private static _EvaluatePreProcessors;
  5442. private static _PreparePreProcessors;
  5443. private static _ProcessShaderConversion;
  5444. private static _ProcessIncludes;
  5445. }
  5446. }
  5447. declare module "babylonjs/Misc/performanceMonitor" {
  5448. /**
  5449. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5450. */
  5451. export class PerformanceMonitor {
  5452. private _enabled;
  5453. private _rollingFrameTime;
  5454. private _lastFrameTimeMs;
  5455. /**
  5456. * constructor
  5457. * @param frameSampleSize The number of samples required to saturate the sliding window
  5458. */
  5459. constructor(frameSampleSize?: number);
  5460. /**
  5461. * Samples current frame
  5462. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5463. */
  5464. sampleFrame(timeMs?: number): void;
  5465. /**
  5466. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5467. */
  5468. readonly averageFrameTime: number;
  5469. /**
  5470. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTimeVariance: number;
  5473. /**
  5474. * Returns the frame time of the most recent frame
  5475. */
  5476. readonly instantaneousFrameTime: number;
  5477. /**
  5478. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5479. */
  5480. readonly averageFPS: number;
  5481. /**
  5482. * Returns the average framerate in frames per second using the most recent frame time
  5483. */
  5484. readonly instantaneousFPS: number;
  5485. /**
  5486. * Returns true if enough samples have been taken to completely fill the sliding window
  5487. */
  5488. readonly isSaturated: boolean;
  5489. /**
  5490. * Enables contributions to the sliding window sample set
  5491. */
  5492. enable(): void;
  5493. /**
  5494. * Disables contributions to the sliding window sample set
  5495. * Samples will not be interpolated over the disabled period
  5496. */
  5497. disable(): void;
  5498. /**
  5499. * Returns true if sampling is enabled
  5500. */
  5501. readonly isEnabled: boolean;
  5502. /**
  5503. * Resets performance monitor
  5504. */
  5505. reset(): void;
  5506. }
  5507. /**
  5508. * RollingAverage
  5509. *
  5510. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5511. */
  5512. export class RollingAverage {
  5513. /**
  5514. * Current average
  5515. */
  5516. average: number;
  5517. /**
  5518. * Current variance
  5519. */
  5520. variance: number;
  5521. protected _samples: Array<number>;
  5522. protected _sampleCount: number;
  5523. protected _pos: number;
  5524. protected _m2: number;
  5525. /**
  5526. * constructor
  5527. * @param length The number of samples required to saturate the sliding window
  5528. */
  5529. constructor(length: number);
  5530. /**
  5531. * Adds a sample to the sample set
  5532. * @param v The sample value
  5533. */
  5534. add(v: number): void;
  5535. /**
  5536. * Returns previously added values or null if outside of history or outside the sliding window domain
  5537. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5538. * @return Value previously recorded with add() or null if outside of range
  5539. */
  5540. history(i: number): number;
  5541. /**
  5542. * Returns true if enough samples have been taken to completely fill the sliding window
  5543. * @return true if sample-set saturated
  5544. */
  5545. isSaturated(): boolean;
  5546. /**
  5547. * Resets the rolling average (equivalent to 0 samples taken so far)
  5548. */
  5549. reset(): void;
  5550. /**
  5551. * Wraps a value around the sample range boundaries
  5552. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5553. * @return Wrapped position in sample range
  5554. */
  5555. protected _wrapPosition(i: number): number;
  5556. }
  5557. }
  5558. declare module "babylonjs/Misc/stringDictionary" {
  5559. import { Nullable } from "babylonjs/types";
  5560. /**
  5561. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5562. * The underlying implementation relies on an associative array to ensure the best performances.
  5563. * The value can be anything including 'null' but except 'undefined'
  5564. */
  5565. export class StringDictionary<T> {
  5566. /**
  5567. * This will clear this dictionary and copy the content from the 'source' one.
  5568. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5569. * @param source the dictionary to take the content from and copy to this dictionary
  5570. */
  5571. copyFrom(source: StringDictionary<T>): void;
  5572. /**
  5573. * Get a value based from its key
  5574. * @param key the given key to get the matching value from
  5575. * @return the value if found, otherwise undefined is returned
  5576. */
  5577. get(key: string): T | undefined;
  5578. /**
  5579. * Get a value from its key or add it if it doesn't exist.
  5580. * This method will ensure you that a given key/data will be present in the dictionary.
  5581. * @param key the given key to get the matching value from
  5582. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5583. * The factory will only be invoked if there's no data for the given key.
  5584. * @return the value corresponding to the key.
  5585. */
  5586. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5587. /**
  5588. * Get a value from its key if present in the dictionary otherwise add it
  5589. * @param key the key to get the value from
  5590. * @param val if there's no such key/value pair in the dictionary add it with this value
  5591. * @return the value corresponding to the key
  5592. */
  5593. getOrAdd(key: string, val: T): T;
  5594. /**
  5595. * Check if there's a given key in the dictionary
  5596. * @param key the key to check for
  5597. * @return true if the key is present, false otherwise
  5598. */
  5599. contains(key: string): boolean;
  5600. /**
  5601. * Add a new key and its corresponding value
  5602. * @param key the key to add
  5603. * @param value the value corresponding to the key
  5604. * @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
  5605. */
  5606. add(key: string, value: T): boolean;
  5607. /**
  5608. * Update a specific value associated to a key
  5609. * @param key defines the key to use
  5610. * @param value defines the value to store
  5611. * @returns true if the value was updated (or false if the key was not found)
  5612. */
  5613. set(key: string, value: T): boolean;
  5614. /**
  5615. * Get the element of the given key and remove it from the dictionary
  5616. * @param key defines the key to search
  5617. * @returns the value associated with the key or null if not found
  5618. */
  5619. getAndRemove(key: string): Nullable<T>;
  5620. /**
  5621. * Remove a key/value from the dictionary.
  5622. * @param key the key to remove
  5623. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5624. */
  5625. remove(key: string): boolean;
  5626. /**
  5627. * Clear the whole content of the dictionary
  5628. */
  5629. clear(): void;
  5630. /**
  5631. * Gets the current count
  5632. */
  5633. readonly count: number;
  5634. /**
  5635. * Execute a callback on each key/val of the dictionary.
  5636. * Note that you can remove any element in this dictionary in the callback implementation
  5637. * @param callback the callback to execute on a given key/value pair
  5638. */
  5639. forEach(callback: (key: string, val: T) => void): void;
  5640. /**
  5641. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5642. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5643. * Note that you can remove any element in this dictionary in the callback implementation
  5644. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5645. * @returns the first item
  5646. */
  5647. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5648. private _count;
  5649. private _data;
  5650. }
  5651. }
  5652. declare module "babylonjs/Misc/promise" {
  5653. /**
  5654. * Helper class that provides a small promise polyfill
  5655. */
  5656. export class PromisePolyfill {
  5657. /**
  5658. * Static function used to check if the polyfill is required
  5659. * If this is the case then the function will inject the polyfill to window.Promise
  5660. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5661. */
  5662. static Apply(force?: boolean): void;
  5663. }
  5664. }
  5665. declare module "babylonjs/Meshes/buffer" {
  5666. import { Nullable, DataArray } from "babylonjs/types";
  5667. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5668. /**
  5669. * Class used to store data that will be store in GPU memory
  5670. */
  5671. export class Buffer {
  5672. private _engine;
  5673. private _buffer;
  5674. /** @hidden */
  5675. _data: Nullable<DataArray>;
  5676. private _updatable;
  5677. private _instanced;
  5678. /**
  5679. * Gets the byte stride.
  5680. */
  5681. readonly byteStride: number;
  5682. /**
  5683. * Constructor
  5684. * @param engine the engine
  5685. * @param data the data to use for this buffer
  5686. * @param updatable whether the data is updatable
  5687. * @param stride the stride (optional)
  5688. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5689. * @param instanced whether the buffer is instanced (optional)
  5690. * @param useBytes set to true if the stride in in bytes (optional)
  5691. */
  5692. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5693. /**
  5694. * Create a new VertexBuffer based on the current buffer
  5695. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5696. * @param offset defines offset in the buffer (0 by default)
  5697. * @param size defines the size in floats of attributes (position is 3 for instance)
  5698. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5699. * @param instanced defines if the vertex buffer contains indexed data
  5700. * @param useBytes defines if the offset and stride are in bytes
  5701. * @returns the new vertex buffer
  5702. */
  5703. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5704. /**
  5705. * Gets a boolean indicating if the Buffer is updatable?
  5706. * @returns true if the buffer is updatable
  5707. */
  5708. isUpdatable(): boolean;
  5709. /**
  5710. * Gets current buffer's data
  5711. * @returns a DataArray or null
  5712. */
  5713. getData(): Nullable<DataArray>;
  5714. /**
  5715. * Gets underlying native buffer
  5716. * @returns underlying native buffer
  5717. */
  5718. getBuffer(): Nullable<DataBuffer>;
  5719. /**
  5720. * Gets the stride in float32 units (i.e. byte stride / 4).
  5721. * May not be an integer if the byte stride is not divisible by 4.
  5722. * DEPRECATED. Use byteStride instead.
  5723. * @returns the stride in float32 units
  5724. */
  5725. getStrideSize(): number;
  5726. /**
  5727. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5728. * @param data defines the data to store
  5729. */
  5730. create(data?: Nullable<DataArray>): void;
  5731. /** @hidden */
  5732. _rebuild(): void;
  5733. /**
  5734. * Update current buffer data
  5735. * @param data defines the data to store
  5736. */
  5737. update(data: DataArray): void;
  5738. /**
  5739. * Updates the data directly.
  5740. * @param data the new data
  5741. * @param offset the new offset
  5742. * @param vertexCount the vertex count (optional)
  5743. * @param useBytes set to true if the offset is in bytes
  5744. */
  5745. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5746. /**
  5747. * Release all resources
  5748. */
  5749. dispose(): void;
  5750. }
  5751. /**
  5752. * Specialized buffer used to store vertex data
  5753. */
  5754. export class VertexBuffer {
  5755. /** @hidden */
  5756. _buffer: Buffer;
  5757. private _kind;
  5758. private _size;
  5759. private _ownsBuffer;
  5760. private _instanced;
  5761. private _instanceDivisor;
  5762. /**
  5763. * The byte type.
  5764. */
  5765. static readonly BYTE: number;
  5766. /**
  5767. * The unsigned byte type.
  5768. */
  5769. static readonly UNSIGNED_BYTE: number;
  5770. /**
  5771. * The short type.
  5772. */
  5773. static readonly SHORT: number;
  5774. /**
  5775. * The unsigned short type.
  5776. */
  5777. static readonly UNSIGNED_SHORT: number;
  5778. /**
  5779. * The integer type.
  5780. */
  5781. static readonly INT: number;
  5782. /**
  5783. * The unsigned integer type.
  5784. */
  5785. static readonly UNSIGNED_INT: number;
  5786. /**
  5787. * The float type.
  5788. */
  5789. static readonly FLOAT: number;
  5790. /**
  5791. * Gets or sets the instance divisor when in instanced mode
  5792. */
  5793. instanceDivisor: number;
  5794. /**
  5795. * Gets the byte stride.
  5796. */
  5797. readonly byteStride: number;
  5798. /**
  5799. * Gets the byte offset.
  5800. */
  5801. readonly byteOffset: number;
  5802. /**
  5803. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5804. */
  5805. readonly normalized: boolean;
  5806. /**
  5807. * Gets the data type of each component in the array.
  5808. */
  5809. readonly type: number;
  5810. /**
  5811. * Constructor
  5812. * @param engine the engine
  5813. * @param data the data to use for this vertex buffer
  5814. * @param kind the vertex buffer kind
  5815. * @param updatable whether the data is updatable
  5816. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5817. * @param stride the stride (optional)
  5818. * @param instanced whether the buffer is instanced (optional)
  5819. * @param offset the offset of the data (optional)
  5820. * @param size the number of components (optional)
  5821. * @param type the type of the component (optional)
  5822. * @param normalized whether the data contains normalized data (optional)
  5823. * @param useBytes set to true if stride and offset are in bytes (optional)
  5824. */
  5825. 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);
  5826. /** @hidden */
  5827. _rebuild(): void;
  5828. /**
  5829. * Returns the kind of the VertexBuffer (string)
  5830. * @returns a string
  5831. */
  5832. getKind(): string;
  5833. /**
  5834. * Gets a boolean indicating if the VertexBuffer is updatable?
  5835. * @returns true if the buffer is updatable
  5836. */
  5837. isUpdatable(): boolean;
  5838. /**
  5839. * Gets current buffer's data
  5840. * @returns a DataArray or null
  5841. */
  5842. getData(): Nullable<DataArray>;
  5843. /**
  5844. * Gets underlying native buffer
  5845. * @returns underlying native buffer
  5846. */
  5847. getBuffer(): Nullable<DataBuffer>;
  5848. /**
  5849. * Gets the stride in float32 units (i.e. byte stride / 4).
  5850. * May not be an integer if the byte stride is not divisible by 4.
  5851. * DEPRECATED. Use byteStride instead.
  5852. * @returns the stride in float32 units
  5853. */
  5854. getStrideSize(): number;
  5855. /**
  5856. * Returns the offset as a multiple of the type byte length.
  5857. * DEPRECATED. Use byteOffset instead.
  5858. * @returns the offset in bytes
  5859. */
  5860. getOffset(): number;
  5861. /**
  5862. * Returns the number of components per vertex attribute (integer)
  5863. * @returns the size in float
  5864. */
  5865. getSize(): number;
  5866. /**
  5867. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5868. * @returns true if this buffer is instanced
  5869. */
  5870. getIsInstanced(): boolean;
  5871. /**
  5872. * Returns the instancing divisor, zero for non-instanced (integer).
  5873. * @returns a number
  5874. */
  5875. getInstanceDivisor(): number;
  5876. /**
  5877. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5878. * @param data defines the data to store
  5879. */
  5880. create(data?: DataArray): void;
  5881. /**
  5882. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5883. * This function will create a new buffer if the current one is not updatable
  5884. * @param data defines the data to store
  5885. */
  5886. update(data: DataArray): void;
  5887. /**
  5888. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5889. * Returns the directly updated WebGLBuffer.
  5890. * @param data the new data
  5891. * @param offset the new offset
  5892. * @param useBytes set to true if the offset is in bytes
  5893. */
  5894. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5895. /**
  5896. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5897. */
  5898. dispose(): void;
  5899. /**
  5900. * Enumerates each value of this vertex buffer as numbers.
  5901. * @param count the number of values to enumerate
  5902. * @param callback the callback function called for each value
  5903. */
  5904. forEach(count: number, callback: (value: number, index: number) => void): void;
  5905. /**
  5906. * Positions
  5907. */
  5908. static readonly PositionKind: string;
  5909. /**
  5910. * Normals
  5911. */
  5912. static readonly NormalKind: string;
  5913. /**
  5914. * Tangents
  5915. */
  5916. static readonly TangentKind: string;
  5917. /**
  5918. * Texture coordinates
  5919. */
  5920. static readonly UVKind: string;
  5921. /**
  5922. * Texture coordinates 2
  5923. */
  5924. static readonly UV2Kind: string;
  5925. /**
  5926. * Texture coordinates 3
  5927. */
  5928. static readonly UV3Kind: string;
  5929. /**
  5930. * Texture coordinates 4
  5931. */
  5932. static readonly UV4Kind: string;
  5933. /**
  5934. * Texture coordinates 5
  5935. */
  5936. static readonly UV5Kind: string;
  5937. /**
  5938. * Texture coordinates 6
  5939. */
  5940. static readonly UV6Kind: string;
  5941. /**
  5942. * Colors
  5943. */
  5944. static readonly ColorKind: string;
  5945. /**
  5946. * Matrix indices (for bones)
  5947. */
  5948. static readonly MatricesIndicesKind: string;
  5949. /**
  5950. * Matrix weights (for bones)
  5951. */
  5952. static readonly MatricesWeightsKind: string;
  5953. /**
  5954. * Additional matrix indices (for bones)
  5955. */
  5956. static readonly MatricesIndicesExtraKind: string;
  5957. /**
  5958. * Additional matrix weights (for bones)
  5959. */
  5960. static readonly MatricesWeightsExtraKind: string;
  5961. /**
  5962. * Deduces the stride given a kind.
  5963. * @param kind The kind string to deduce
  5964. * @returns The deduced stride
  5965. */
  5966. static DeduceStride(kind: string): number;
  5967. /**
  5968. * Gets the byte length of the given type.
  5969. * @param type the type
  5970. * @returns the number of bytes
  5971. */
  5972. static GetTypeByteLength(type: number): number;
  5973. /**
  5974. * Enumerates each value of the given parameters as numbers.
  5975. * @param data the data to enumerate
  5976. * @param byteOffset the byte offset of the data
  5977. * @param byteStride the byte stride of the data
  5978. * @param componentCount the number of components per element
  5979. * @param componentType the type of the component
  5980. * @param count the total number of components
  5981. * @param normalized whether the data is normalized
  5982. * @param callback the callback function called for each value
  5983. */
  5984. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5985. private static _GetFloatValue;
  5986. }
  5987. }
  5988. declare module "babylonjs/Maths/sphericalPolynomial" {
  5989. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5990. /**
  5991. * Class representing spherical harmonics coefficients to the 3rd degree
  5992. */
  5993. export class SphericalHarmonics {
  5994. /**
  5995. * Defines whether or not the harmonics have been prescaled for rendering.
  5996. */
  5997. preScaled: boolean;
  5998. /**
  5999. * The l0,0 coefficients of the spherical harmonics
  6000. */
  6001. l00: Vector3;
  6002. /**
  6003. * The l1,-1 coefficients of the spherical harmonics
  6004. */
  6005. l1_1: Vector3;
  6006. /**
  6007. * The l1,0 coefficients of the spherical harmonics
  6008. */
  6009. l10: Vector3;
  6010. /**
  6011. * The l1,1 coefficients of the spherical harmonics
  6012. */
  6013. l11: Vector3;
  6014. /**
  6015. * The l2,-2 coefficients of the spherical harmonics
  6016. */
  6017. l2_2: Vector3;
  6018. /**
  6019. * The l2,-1 coefficients of the spherical harmonics
  6020. */
  6021. l2_1: Vector3;
  6022. /**
  6023. * The l2,0 coefficients of the spherical harmonics
  6024. */
  6025. l20: Vector3;
  6026. /**
  6027. * The l2,1 coefficients of the spherical harmonics
  6028. */
  6029. l21: Vector3;
  6030. /**
  6031. * The l2,2 coefficients of the spherical harmonics
  6032. */
  6033. l22: Vector3;
  6034. /**
  6035. * Adds a light to the spherical harmonics
  6036. * @param direction the direction of the light
  6037. * @param color the color of the light
  6038. * @param deltaSolidAngle the delta solid angle of the light
  6039. */
  6040. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6041. /**
  6042. * Scales the spherical harmonics by the given amount
  6043. * @param scale the amount to scale
  6044. */
  6045. scaleInPlace(scale: number): void;
  6046. /**
  6047. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6048. *
  6049. * ```
  6050. * E_lm = A_l * L_lm
  6051. * ```
  6052. *
  6053. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6054. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6055. * the scaling factors are given in equation 9.
  6056. */
  6057. convertIncidentRadianceToIrradiance(): void;
  6058. /**
  6059. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6060. *
  6061. * ```
  6062. * L = (1/pi) * E * rho
  6063. * ```
  6064. *
  6065. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6066. */
  6067. convertIrradianceToLambertianRadiance(): void;
  6068. /**
  6069. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6070. * required operations at run time.
  6071. *
  6072. * This is simply done by scaling back the SH with Ylm constants parameter.
  6073. * The trigonometric part being applied by the shader at run time.
  6074. */
  6075. preScaleForRendering(): void;
  6076. /**
  6077. * Constructs a spherical harmonics from an array.
  6078. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6079. * @returns the spherical harmonics
  6080. */
  6081. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6082. /**
  6083. * Gets the spherical harmonics from polynomial
  6084. * @param polynomial the spherical polynomial
  6085. * @returns the spherical harmonics
  6086. */
  6087. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6088. }
  6089. /**
  6090. * Class representing spherical polynomial coefficients to the 3rd degree
  6091. */
  6092. export class SphericalPolynomial {
  6093. private _harmonics;
  6094. /**
  6095. * The spherical harmonics used to create the polynomials.
  6096. */
  6097. readonly preScaledHarmonics: SphericalHarmonics;
  6098. /**
  6099. * The x coefficients of the spherical polynomial
  6100. */
  6101. x: Vector3;
  6102. /**
  6103. * The y coefficients of the spherical polynomial
  6104. */
  6105. y: Vector3;
  6106. /**
  6107. * The z coefficients of the spherical polynomial
  6108. */
  6109. z: Vector3;
  6110. /**
  6111. * The xx coefficients of the spherical polynomial
  6112. */
  6113. xx: Vector3;
  6114. /**
  6115. * The yy coefficients of the spherical polynomial
  6116. */
  6117. yy: Vector3;
  6118. /**
  6119. * The zz coefficients of the spherical polynomial
  6120. */
  6121. zz: Vector3;
  6122. /**
  6123. * The xy coefficients of the spherical polynomial
  6124. */
  6125. xy: Vector3;
  6126. /**
  6127. * The yz coefficients of the spherical polynomial
  6128. */
  6129. yz: Vector3;
  6130. /**
  6131. * The zx coefficients of the spherical polynomial
  6132. */
  6133. zx: Vector3;
  6134. /**
  6135. * Adds an ambient color to the spherical polynomial
  6136. * @param color the color to add
  6137. */
  6138. addAmbient(color: Color3): void;
  6139. /**
  6140. * Scales the spherical polynomial by the given amount
  6141. * @param scale the amount to scale
  6142. */
  6143. scaleInPlace(scale: number): void;
  6144. /**
  6145. * Gets the spherical polynomial from harmonics
  6146. * @param harmonics the spherical harmonics
  6147. * @returns the spherical polynomial
  6148. */
  6149. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6150. /**
  6151. * Constructs a spherical polynomial from an array.
  6152. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6153. * @returns the spherical polynomial
  6154. */
  6155. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6156. }
  6157. }
  6158. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6159. import { Nullable } from "babylonjs/types";
  6160. /**
  6161. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6162. */
  6163. export interface CubeMapInfo {
  6164. /**
  6165. * The pixel array for the front face.
  6166. * This is stored in format, left to right, up to down format.
  6167. */
  6168. front: Nullable<ArrayBufferView>;
  6169. /**
  6170. * The pixel array for the back face.
  6171. * This is stored in format, left to right, up to down format.
  6172. */
  6173. back: Nullable<ArrayBufferView>;
  6174. /**
  6175. * The pixel array for the left face.
  6176. * This is stored in format, left to right, up to down format.
  6177. */
  6178. left: Nullable<ArrayBufferView>;
  6179. /**
  6180. * The pixel array for the right face.
  6181. * This is stored in format, left to right, up to down format.
  6182. */
  6183. right: Nullable<ArrayBufferView>;
  6184. /**
  6185. * The pixel array for the up face.
  6186. * This is stored in format, left to right, up to down format.
  6187. */
  6188. up: Nullable<ArrayBufferView>;
  6189. /**
  6190. * The pixel array for the down face.
  6191. * This is stored in format, left to right, up to down format.
  6192. */
  6193. down: Nullable<ArrayBufferView>;
  6194. /**
  6195. * The size of the cubemap stored.
  6196. *
  6197. * Each faces will be size * size pixels.
  6198. */
  6199. size: number;
  6200. /**
  6201. * The format of the texture.
  6202. *
  6203. * RGBA, RGB.
  6204. */
  6205. format: number;
  6206. /**
  6207. * The type of the texture data.
  6208. *
  6209. * UNSIGNED_INT, FLOAT.
  6210. */
  6211. type: number;
  6212. /**
  6213. * Specifies whether the texture is in gamma space.
  6214. */
  6215. gammaSpace: boolean;
  6216. }
  6217. /**
  6218. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6219. */
  6220. export class PanoramaToCubeMapTools {
  6221. private static FACE_FRONT;
  6222. private static FACE_BACK;
  6223. private static FACE_RIGHT;
  6224. private static FACE_LEFT;
  6225. private static FACE_DOWN;
  6226. private static FACE_UP;
  6227. /**
  6228. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6229. *
  6230. * @param float32Array The source data.
  6231. * @param inputWidth The width of the input panorama.
  6232. * @param inputHeight The height of the input panorama.
  6233. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6234. * @return The cubemap data
  6235. */
  6236. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6237. private static CreateCubemapTexture;
  6238. private static CalcProjectionSpherical;
  6239. }
  6240. }
  6241. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6242. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6244. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6245. /**
  6246. * Helper class dealing with the extraction of spherical polynomial dataArray
  6247. * from a cube map.
  6248. */
  6249. export class CubeMapToSphericalPolynomialTools {
  6250. private static FileFaces;
  6251. /**
  6252. * Converts a texture to the according Spherical Polynomial data.
  6253. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6254. *
  6255. * @param texture The texture to extract the information from.
  6256. * @return The Spherical Polynomial data.
  6257. */
  6258. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6259. /**
  6260. * Converts a cubemap to the according Spherical Polynomial data.
  6261. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6262. *
  6263. * @param cubeInfo The Cube map to extract the information from.
  6264. * @return The Spherical Polynomial data.
  6265. */
  6266. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6267. }
  6268. }
  6269. declare module "babylonjs/Engines/engineStore" {
  6270. import { Nullable } from "babylonjs/types";
  6271. import { Engine } from "babylonjs/Engines/engine";
  6272. import { Scene } from "babylonjs/scene";
  6273. /**
  6274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6275. * during the life time of the application.
  6276. */
  6277. export class EngineStore {
  6278. /** Gets the list of created engines */
  6279. static Instances: import("babylonjs/Engines/engine").Engine[];
  6280. /** @hidden */
  6281. static _LastCreatedScene: Nullable<Scene>;
  6282. /**
  6283. * Gets the latest created engine
  6284. */
  6285. static readonly LastCreatedEngine: Nullable<Engine>;
  6286. /**
  6287. * Gets the latest created scene
  6288. */
  6289. static readonly LastCreatedScene: Nullable<Scene>;
  6290. }
  6291. }
  6292. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6293. /**
  6294. * Define options used to create a render target texture
  6295. */
  6296. export class RenderTargetCreationOptions {
  6297. /**
  6298. * Specifies is mipmaps must be generated
  6299. */
  6300. generateMipMaps?: boolean;
  6301. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6302. generateDepthBuffer?: boolean;
  6303. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6304. generateStencilBuffer?: boolean;
  6305. /** Defines texture type (int by default) */
  6306. type?: number;
  6307. /** Defines sampling mode (trilinear by default) */
  6308. samplingMode?: number;
  6309. /** Defines format (RGBA by default) */
  6310. format?: number;
  6311. }
  6312. }
  6313. declare module "babylonjs/States/alphaCullingState" {
  6314. /**
  6315. * @hidden
  6316. **/
  6317. export class _AlphaState {
  6318. private _isAlphaBlendDirty;
  6319. private _isBlendFunctionParametersDirty;
  6320. private _isBlendEquationParametersDirty;
  6321. private _isBlendConstantsDirty;
  6322. private _alphaBlend;
  6323. private _blendFunctionParameters;
  6324. private _blendEquationParameters;
  6325. private _blendConstants;
  6326. /**
  6327. * Initializes the state.
  6328. */
  6329. constructor();
  6330. readonly isDirty: boolean;
  6331. alphaBlend: boolean;
  6332. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6333. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6334. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6335. reset(): void;
  6336. apply(gl: WebGLRenderingContext): void;
  6337. }
  6338. }
  6339. declare module "babylonjs/States/depthCullingState" {
  6340. import { Nullable } from "babylonjs/types";
  6341. /**
  6342. * @hidden
  6343. **/
  6344. export class _DepthCullingState {
  6345. private _isDepthTestDirty;
  6346. private _isDepthMaskDirty;
  6347. private _isDepthFuncDirty;
  6348. private _isCullFaceDirty;
  6349. private _isCullDirty;
  6350. private _isZOffsetDirty;
  6351. private _isFrontFaceDirty;
  6352. private _depthTest;
  6353. private _depthMask;
  6354. private _depthFunc;
  6355. private _cull;
  6356. private _cullFace;
  6357. private _zOffset;
  6358. private _frontFace;
  6359. /**
  6360. * Initializes the state.
  6361. */
  6362. constructor();
  6363. readonly isDirty: boolean;
  6364. zOffset: number;
  6365. cullFace: Nullable<number>;
  6366. cull: Nullable<boolean>;
  6367. depthFunc: Nullable<number>;
  6368. depthMask: boolean;
  6369. depthTest: boolean;
  6370. frontFace: Nullable<number>;
  6371. reset(): void;
  6372. apply(gl: WebGLRenderingContext): void;
  6373. }
  6374. }
  6375. declare module "babylonjs/States/stencilState" {
  6376. /**
  6377. * @hidden
  6378. **/
  6379. export class _StencilState {
  6380. /** 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 */
  6381. static readonly ALWAYS: number;
  6382. /** Passed to stencilOperation to specify that stencil value must be kept */
  6383. static readonly KEEP: number;
  6384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6385. static readonly REPLACE: number;
  6386. private _isStencilTestDirty;
  6387. private _isStencilMaskDirty;
  6388. private _isStencilFuncDirty;
  6389. private _isStencilOpDirty;
  6390. private _stencilTest;
  6391. private _stencilMask;
  6392. private _stencilFunc;
  6393. private _stencilFuncRef;
  6394. private _stencilFuncMask;
  6395. private _stencilOpStencilFail;
  6396. private _stencilOpDepthFail;
  6397. private _stencilOpStencilDepthPass;
  6398. readonly isDirty: boolean;
  6399. stencilFunc: number;
  6400. stencilFuncRef: number;
  6401. stencilFuncMask: number;
  6402. stencilOpStencilFail: number;
  6403. stencilOpDepthFail: number;
  6404. stencilOpStencilDepthPass: number;
  6405. stencilMask: number;
  6406. stencilTest: boolean;
  6407. constructor();
  6408. reset(): void;
  6409. apply(gl: WebGLRenderingContext): void;
  6410. }
  6411. }
  6412. declare module "babylonjs/States/index" {
  6413. export * from "babylonjs/States/alphaCullingState";
  6414. export * from "babylonjs/States/depthCullingState";
  6415. export * from "babylonjs/States/stencilState";
  6416. }
  6417. declare module "babylonjs/Instrumentation/timeToken" {
  6418. import { Nullable } from "babylonjs/types";
  6419. /**
  6420. * @hidden
  6421. **/
  6422. export class _TimeToken {
  6423. _startTimeQuery: Nullable<WebGLQuery>;
  6424. _endTimeQuery: Nullable<WebGLQuery>;
  6425. _timeElapsedQuery: Nullable<WebGLQuery>;
  6426. _timeElapsedQueryEnded: boolean;
  6427. }
  6428. }
  6429. declare module "babylonjs/Materials/Textures/internalTexture" {
  6430. import { Observable } from "babylonjs/Misc/observable";
  6431. import { Nullable, int } from "babylonjs/types";
  6432. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6433. import { Engine } from "babylonjs/Engines/engine";
  6434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6435. /**
  6436. * Class used to store data associated with WebGL texture data for the engine
  6437. * This class should not be used directly
  6438. */
  6439. export class InternalTexture {
  6440. /** @hidden */
  6441. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6442. /**
  6443. * The source of the texture data is unknown
  6444. */
  6445. static DATASOURCE_UNKNOWN: number;
  6446. /**
  6447. * Texture data comes from an URL
  6448. */
  6449. static DATASOURCE_URL: number;
  6450. /**
  6451. * Texture data is only used for temporary storage
  6452. */
  6453. static DATASOURCE_TEMP: number;
  6454. /**
  6455. * Texture data comes from raw data (ArrayBuffer)
  6456. */
  6457. static DATASOURCE_RAW: number;
  6458. /**
  6459. * Texture content is dynamic (video or dynamic texture)
  6460. */
  6461. static DATASOURCE_DYNAMIC: number;
  6462. /**
  6463. * Texture content is generated by rendering to it
  6464. */
  6465. static DATASOURCE_RENDERTARGET: number;
  6466. /**
  6467. * Texture content is part of a multi render target process
  6468. */
  6469. static DATASOURCE_MULTIRENDERTARGET: number;
  6470. /**
  6471. * Texture data comes from a cube data file
  6472. */
  6473. static DATASOURCE_CUBE: number;
  6474. /**
  6475. * Texture data comes from a raw cube data
  6476. */
  6477. static DATASOURCE_CUBERAW: number;
  6478. /**
  6479. * Texture data come from a prefiltered cube data file
  6480. */
  6481. static DATASOURCE_CUBEPREFILTERED: number;
  6482. /**
  6483. * Texture content is raw 3D data
  6484. */
  6485. static DATASOURCE_RAW3D: number;
  6486. /**
  6487. * Texture content is a depth texture
  6488. */
  6489. static DATASOURCE_DEPTHTEXTURE: number;
  6490. /**
  6491. * Texture data comes from a raw cube data encoded with RGBD
  6492. */
  6493. static DATASOURCE_CUBERAW_RGBD: number;
  6494. /**
  6495. * Defines if the texture is ready
  6496. */
  6497. isReady: boolean;
  6498. /**
  6499. * Defines if the texture is a cube texture
  6500. */
  6501. isCube: boolean;
  6502. /**
  6503. * Defines if the texture contains 3D data
  6504. */
  6505. is3D: boolean;
  6506. /**
  6507. * Defines if the texture contains multiview data
  6508. */
  6509. isMultiview: boolean;
  6510. /**
  6511. * Gets the URL used to load this texture
  6512. */
  6513. url: string;
  6514. /**
  6515. * Gets the sampling mode of the texture
  6516. */
  6517. samplingMode: number;
  6518. /**
  6519. * Gets a boolean indicating if the texture needs mipmaps generation
  6520. */
  6521. generateMipMaps: boolean;
  6522. /**
  6523. * Gets the number of samples used by the texture (WebGL2+ only)
  6524. */
  6525. samples: number;
  6526. /**
  6527. * Gets the type of the texture (int, float...)
  6528. */
  6529. type: number;
  6530. /**
  6531. * Gets the format of the texture (RGB, RGBA...)
  6532. */
  6533. format: number;
  6534. /**
  6535. * Observable called when the texture is loaded
  6536. */
  6537. onLoadedObservable: Observable<InternalTexture>;
  6538. /**
  6539. * Gets the width of the texture
  6540. */
  6541. width: number;
  6542. /**
  6543. * Gets the height of the texture
  6544. */
  6545. height: number;
  6546. /**
  6547. * Gets the depth of the texture
  6548. */
  6549. depth: number;
  6550. /**
  6551. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6552. */
  6553. baseWidth: number;
  6554. /**
  6555. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseHeight: number;
  6558. /**
  6559. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseDepth: number;
  6562. /**
  6563. * Gets a boolean indicating if the texture is inverted on Y axis
  6564. */
  6565. invertY: boolean;
  6566. /** @hidden */
  6567. _invertVScale: boolean;
  6568. /** @hidden */
  6569. _associatedChannel: number;
  6570. /** @hidden */
  6571. _dataSource: number;
  6572. /** @hidden */
  6573. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6574. /** @hidden */
  6575. _bufferView: Nullable<ArrayBufferView>;
  6576. /** @hidden */
  6577. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6578. /** @hidden */
  6579. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6580. /** @hidden */
  6581. _size: number;
  6582. /** @hidden */
  6583. _extension: string;
  6584. /** @hidden */
  6585. _files: Nullable<string[]>;
  6586. /** @hidden */
  6587. _workingCanvas: Nullable<HTMLCanvasElement>;
  6588. /** @hidden */
  6589. _workingContext: Nullable<CanvasRenderingContext2D>;
  6590. /** @hidden */
  6591. _framebuffer: Nullable<WebGLFramebuffer>;
  6592. /** @hidden */
  6593. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6594. /** @hidden */
  6595. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _attachments: Nullable<number[]>;
  6600. /** @hidden */
  6601. _cachedCoordinatesMode: Nullable<number>;
  6602. /** @hidden */
  6603. _cachedWrapU: Nullable<number>;
  6604. /** @hidden */
  6605. _cachedWrapV: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapR: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6610. /** @hidden */
  6611. _isDisabled: boolean;
  6612. /** @hidden */
  6613. _compression: Nullable<string>;
  6614. /** @hidden */
  6615. _generateStencilBuffer: boolean;
  6616. /** @hidden */
  6617. _generateDepthBuffer: boolean;
  6618. /** @hidden */
  6619. _comparisonFunction: number;
  6620. /** @hidden */
  6621. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6622. /** @hidden */
  6623. _lodGenerationScale: number;
  6624. /** @hidden */
  6625. _lodGenerationOffset: number;
  6626. /** @hidden */
  6627. _colorTextureArray: Nullable<WebGLTexture>;
  6628. /** @hidden */
  6629. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6630. /** @hidden */
  6631. _lodTextureHigh: Nullable<BaseTexture>;
  6632. /** @hidden */
  6633. _lodTextureMid: Nullable<BaseTexture>;
  6634. /** @hidden */
  6635. _lodTextureLow: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _isRGBD: boolean;
  6638. /** @hidden */
  6639. _linearSpecularLOD: boolean;
  6640. /** @hidden */
  6641. _irradianceTexture: Nullable<BaseTexture>;
  6642. /** @hidden */
  6643. _webGLTexture: Nullable<WebGLTexture>;
  6644. /** @hidden */
  6645. _references: number;
  6646. private _engine;
  6647. /**
  6648. * Gets the Engine the texture belongs to.
  6649. * @returns The babylon engine
  6650. */
  6651. getEngine(): Engine;
  6652. /**
  6653. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6654. */
  6655. readonly dataSource: number;
  6656. /**
  6657. * Creates a new InternalTexture
  6658. * @param engine defines the engine to use
  6659. * @param dataSource defines the type of data that will be used
  6660. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6661. */
  6662. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6663. /**
  6664. * Increments the number of references (ie. the number of Texture that point to it)
  6665. */
  6666. incrementReferences(): void;
  6667. /**
  6668. * Change the size of the texture (not the size of the content)
  6669. * @param width defines the new width
  6670. * @param height defines the new height
  6671. * @param depth defines the new depth (1 by default)
  6672. */
  6673. updateSize(width: int, height: int, depth?: int): void;
  6674. /** @hidden */
  6675. _rebuild(): void;
  6676. /** @hidden */
  6677. _swapAndDie(target: InternalTexture): void;
  6678. /**
  6679. * Dispose the current allocated resources
  6680. */
  6681. dispose(): void;
  6682. }
  6683. }
  6684. declare module "babylonjs/Animations/easing" {
  6685. /**
  6686. * This represents the main contract an easing function should follow.
  6687. * Easing functions are used throughout the animation system.
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export interface IEasingFunction {
  6691. /**
  6692. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6693. * of the easing function.
  6694. * The link below provides some of the most common examples of easing functions.
  6695. * @see https://easings.net/
  6696. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6697. * @returns the corresponding value on the curve defined by the easing function
  6698. */
  6699. ease(gradient: number): number;
  6700. }
  6701. /**
  6702. * Base class used for every default easing function.
  6703. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6704. */
  6705. export class EasingFunction implements IEasingFunction {
  6706. /**
  6707. * Interpolation follows the mathematical formula associated with the easing function.
  6708. */
  6709. static readonly EASINGMODE_EASEIN: number;
  6710. /**
  6711. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEOUT: number;
  6714. /**
  6715. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6716. */
  6717. static readonly EASINGMODE_EASEINOUT: number;
  6718. private _easingMode;
  6719. /**
  6720. * Sets the easing mode of the current function.
  6721. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6722. */
  6723. setEasingMode(easingMode: number): void;
  6724. /**
  6725. * Gets the current easing mode.
  6726. * @returns the easing mode
  6727. */
  6728. getEasingMode(): number;
  6729. /**
  6730. * @hidden
  6731. */
  6732. easeInCore(gradient: number): number;
  6733. /**
  6734. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6735. * of the easing function.
  6736. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6737. * @returns the corresponding value on the curve defined by the easing function
  6738. */
  6739. ease(gradient: number): number;
  6740. }
  6741. /**
  6742. * Easing function with a circle shape (see link below).
  6743. * @see https://easings.net/#easeInCirc
  6744. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6745. */
  6746. export class CircleEase extends EasingFunction implements IEasingFunction {
  6747. /** @hidden */
  6748. easeInCore(gradient: number): number;
  6749. }
  6750. /**
  6751. * Easing function with a ease back shape (see link below).
  6752. * @see https://easings.net/#easeInBack
  6753. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6754. */
  6755. export class BackEase extends EasingFunction implements IEasingFunction {
  6756. /** Defines the amplitude of the function */
  6757. amplitude: number;
  6758. /**
  6759. * Instantiates a back ease easing
  6760. * @see https://easings.net/#easeInBack
  6761. * @param amplitude Defines the amplitude of the function
  6762. */
  6763. constructor(
  6764. /** Defines the amplitude of the function */
  6765. amplitude?: number);
  6766. /** @hidden */
  6767. easeInCore(gradient: number): number;
  6768. }
  6769. /**
  6770. * Easing function with a bouncing shape (see link below).
  6771. * @see https://easings.net/#easeInBounce
  6772. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6773. */
  6774. export class BounceEase extends EasingFunction implements IEasingFunction {
  6775. /** Defines the number of bounces */
  6776. bounces: number;
  6777. /** Defines the amplitude of the bounce */
  6778. bounciness: number;
  6779. /**
  6780. * Instantiates a bounce easing
  6781. * @see https://easings.net/#easeInBounce
  6782. * @param bounces Defines the number of bounces
  6783. * @param bounciness Defines the amplitude of the bounce
  6784. */
  6785. constructor(
  6786. /** Defines the number of bounces */
  6787. bounces?: number,
  6788. /** Defines the amplitude of the bounce */
  6789. bounciness?: number);
  6790. /** @hidden */
  6791. easeInCore(gradient: number): number;
  6792. }
  6793. /**
  6794. * Easing function with a power of 3 shape (see link below).
  6795. * @see https://easings.net/#easeInCubic
  6796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6797. */
  6798. export class CubicEase extends EasingFunction implements IEasingFunction {
  6799. /** @hidden */
  6800. easeInCore(gradient: number): number;
  6801. }
  6802. /**
  6803. * Easing function with an elastic shape (see link below).
  6804. * @see https://easings.net/#easeInElastic
  6805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6806. */
  6807. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6808. /** Defines the number of oscillations*/
  6809. oscillations: number;
  6810. /** Defines the amplitude of the oscillations*/
  6811. springiness: number;
  6812. /**
  6813. * Instantiates an elastic easing function
  6814. * @see https://easings.net/#easeInElastic
  6815. * @param oscillations Defines the number of oscillations
  6816. * @param springiness Defines the amplitude of the oscillations
  6817. */
  6818. constructor(
  6819. /** Defines the number of oscillations*/
  6820. oscillations?: number,
  6821. /** Defines the amplitude of the oscillations*/
  6822. springiness?: number);
  6823. /** @hidden */
  6824. easeInCore(gradient: number): number;
  6825. }
  6826. /**
  6827. * Easing function with an exponential shape (see link below).
  6828. * @see https://easings.net/#easeInExpo
  6829. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6830. */
  6831. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6832. /** Defines the exponent of the function */
  6833. exponent: number;
  6834. /**
  6835. * Instantiates an exponential easing function
  6836. * @see https://easings.net/#easeInExpo
  6837. * @param exponent Defines the exponent of the function
  6838. */
  6839. constructor(
  6840. /** Defines the exponent of the function */
  6841. exponent?: number);
  6842. /** @hidden */
  6843. easeInCore(gradient: number): number;
  6844. }
  6845. /**
  6846. * Easing function with a power shape (see link below).
  6847. * @see https://easings.net/#easeInQuad
  6848. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6849. */
  6850. export class PowerEase extends EasingFunction implements IEasingFunction {
  6851. /** Defines the power of the function */
  6852. power: number;
  6853. /**
  6854. * Instantiates an power base easing function
  6855. * @see https://easings.net/#easeInQuad
  6856. * @param power Defines the power of the function
  6857. */
  6858. constructor(
  6859. /** Defines the power of the function */
  6860. power?: number);
  6861. /** @hidden */
  6862. easeInCore(gradient: number): number;
  6863. }
  6864. /**
  6865. * Easing function with a power of 2 shape (see link below).
  6866. * @see https://easings.net/#easeInQuad
  6867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6868. */
  6869. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6870. /** @hidden */
  6871. easeInCore(gradient: number): number;
  6872. }
  6873. /**
  6874. * Easing function with a power of 4 shape (see link below).
  6875. * @see https://easings.net/#easeInQuart
  6876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6877. */
  6878. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6879. /** @hidden */
  6880. easeInCore(gradient: number): number;
  6881. }
  6882. /**
  6883. * Easing function with a power of 5 shape (see link below).
  6884. * @see https://easings.net/#easeInQuint
  6885. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6886. */
  6887. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6888. /** @hidden */
  6889. easeInCore(gradient: number): number;
  6890. }
  6891. /**
  6892. * Easing function with a sin shape (see link below).
  6893. * @see https://easings.net/#easeInSine
  6894. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6895. */
  6896. export class SineEase extends EasingFunction implements IEasingFunction {
  6897. /** @hidden */
  6898. easeInCore(gradient: number): number;
  6899. }
  6900. /**
  6901. * Easing function with a bezier shape (see link below).
  6902. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6903. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6904. */
  6905. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6906. /** Defines the x component of the start tangent in the bezier curve */
  6907. x1: number;
  6908. /** Defines the y component of the start tangent in the bezier curve */
  6909. y1: number;
  6910. /** Defines the x component of the end tangent in the bezier curve */
  6911. x2: number;
  6912. /** Defines the y component of the end tangent in the bezier curve */
  6913. y2: number;
  6914. /**
  6915. * Instantiates a bezier function
  6916. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6917. * @param x1 Defines the x component of the start tangent in the bezier curve
  6918. * @param y1 Defines the y component of the start tangent in the bezier curve
  6919. * @param x2 Defines the x component of the end tangent in the bezier curve
  6920. * @param y2 Defines the y component of the end tangent in the bezier curve
  6921. */
  6922. constructor(
  6923. /** Defines the x component of the start tangent in the bezier curve */
  6924. x1?: number,
  6925. /** Defines the y component of the start tangent in the bezier curve */
  6926. y1?: number,
  6927. /** Defines the x component of the end tangent in the bezier curve */
  6928. x2?: number,
  6929. /** Defines the y component of the end tangent in the bezier curve */
  6930. y2?: number);
  6931. /** @hidden */
  6932. easeInCore(gradient: number): number;
  6933. }
  6934. }
  6935. declare module "babylonjs/Animations/animationKey" {
  6936. /**
  6937. * Defines an interface which represents an animation key frame
  6938. */
  6939. export interface IAnimationKey {
  6940. /**
  6941. * Frame of the key frame
  6942. */
  6943. frame: number;
  6944. /**
  6945. * Value at the specifies key frame
  6946. */
  6947. value: any;
  6948. /**
  6949. * The input tangent for the cubic hermite spline
  6950. */
  6951. inTangent?: any;
  6952. /**
  6953. * The output tangent for the cubic hermite spline
  6954. */
  6955. outTangent?: any;
  6956. /**
  6957. * The animation interpolation type
  6958. */
  6959. interpolation?: AnimationKeyInterpolation;
  6960. }
  6961. /**
  6962. * Enum for the animation key frame interpolation type
  6963. */
  6964. export enum AnimationKeyInterpolation {
  6965. /**
  6966. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6967. */
  6968. STEP = 1
  6969. }
  6970. }
  6971. declare module "babylonjs/Animations/animationRange" {
  6972. /**
  6973. * Represents the range of an animation
  6974. */
  6975. export class AnimationRange {
  6976. /**The name of the animation range**/
  6977. name: string;
  6978. /**The starting frame of the animation */
  6979. from: number;
  6980. /**The ending frame of the animation*/
  6981. to: number;
  6982. /**
  6983. * Initializes the range of an animation
  6984. * @param name The name of the animation range
  6985. * @param from The starting frame of the animation
  6986. * @param to The ending frame of the animation
  6987. */
  6988. constructor(
  6989. /**The name of the animation range**/
  6990. name: string,
  6991. /**The starting frame of the animation */
  6992. from: number,
  6993. /**The ending frame of the animation*/
  6994. to: number);
  6995. /**
  6996. * Makes a copy of the animation range
  6997. * @returns A copy of the animation range
  6998. */
  6999. clone(): AnimationRange;
  7000. }
  7001. }
  7002. declare module "babylonjs/Animations/animationEvent" {
  7003. /**
  7004. * Composed of a frame, and an action function
  7005. */
  7006. export class AnimationEvent {
  7007. /** The frame for which the event is triggered **/
  7008. frame: number;
  7009. /** The event to perform when triggered **/
  7010. action: (currentFrame: number) => void;
  7011. /** Specifies if the event should be triggered only once**/
  7012. onlyOnce?: boolean | undefined;
  7013. /**
  7014. * Specifies if the animation event is done
  7015. */
  7016. isDone: boolean;
  7017. /**
  7018. * Initializes the animation event
  7019. * @param frame The frame for which the event is triggered
  7020. * @param action The event to perform when triggered
  7021. * @param onlyOnce Specifies if the event should be triggered only once
  7022. */
  7023. constructor(
  7024. /** The frame for which the event is triggered **/
  7025. frame: number,
  7026. /** The event to perform when triggered **/
  7027. action: (currentFrame: number) => void,
  7028. /** Specifies if the event should be triggered only once**/
  7029. onlyOnce?: boolean | undefined);
  7030. /** @hidden */
  7031. _clone(): AnimationEvent;
  7032. }
  7033. }
  7034. declare module "babylonjs/Behaviors/behavior" {
  7035. import { Nullable } from "babylonjs/types";
  7036. /**
  7037. * Interface used to define a behavior
  7038. */
  7039. export interface Behavior<T> {
  7040. /** gets or sets behavior's name */
  7041. name: string;
  7042. /**
  7043. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7044. */
  7045. init(): void;
  7046. /**
  7047. * Called when the behavior is attached to a target
  7048. * @param target defines the target where the behavior is attached to
  7049. */
  7050. attach(target: T): void;
  7051. /**
  7052. * Called when the behavior is detached from its target
  7053. */
  7054. detach(): void;
  7055. }
  7056. /**
  7057. * Interface implemented by classes supporting behaviors
  7058. */
  7059. export interface IBehaviorAware<T> {
  7060. /**
  7061. * Attach a behavior
  7062. * @param behavior defines the behavior to attach
  7063. * @returns the current host
  7064. */
  7065. addBehavior(behavior: Behavior<T>): T;
  7066. /**
  7067. * Remove a behavior from the current object
  7068. * @param behavior defines the behavior to detach
  7069. * @returns the current host
  7070. */
  7071. removeBehavior(behavior: Behavior<T>): T;
  7072. /**
  7073. * Gets a behavior using its name to search
  7074. * @param name defines the name to search
  7075. * @returns the behavior or null if not found
  7076. */
  7077. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7078. }
  7079. }
  7080. declare module "babylonjs/Collisions/intersectionInfo" {
  7081. import { Nullable } from "babylonjs/types";
  7082. /**
  7083. * @hidden
  7084. */
  7085. export class IntersectionInfo {
  7086. bu: Nullable<number>;
  7087. bv: Nullable<number>;
  7088. distance: number;
  7089. faceId: number;
  7090. subMeshId: number;
  7091. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7092. }
  7093. }
  7094. declare module "babylonjs/Culling/boundingSphere" {
  7095. import { DeepImmutable } from "babylonjs/types";
  7096. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7097. /**
  7098. * Class used to store bounding sphere information
  7099. */
  7100. export class BoundingSphere {
  7101. /**
  7102. * Gets the center of the bounding sphere in local space
  7103. */
  7104. readonly center: Vector3;
  7105. /**
  7106. * Radius of the bounding sphere in local space
  7107. */
  7108. radius: number;
  7109. /**
  7110. * Gets the center of the bounding sphere in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Radius of the bounding sphere in world space
  7115. */
  7116. radiusWorld: number;
  7117. /**
  7118. * Gets the minimum vector in local space
  7119. */
  7120. readonly minimum: Vector3;
  7121. /**
  7122. * Gets the maximum vector in local space
  7123. */
  7124. readonly maximum: Vector3;
  7125. private _worldMatrix;
  7126. private static readonly TmpVector3;
  7127. /**
  7128. * Creates a new bounding sphere
  7129. * @param min defines the minimum vector (in local space)
  7130. * @param max defines the maximum vector (in local space)
  7131. * @param worldMatrix defines the new world matrix
  7132. */
  7133. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7134. /**
  7135. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7136. * @param min defines the new minimum vector (in local space)
  7137. * @param max defines the new maximum vector (in local space)
  7138. * @param worldMatrix defines the new world matrix
  7139. */
  7140. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Scale the current bounding sphere by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding box
  7145. */
  7146. scale(factor: number): BoundingSphere;
  7147. /**
  7148. * Gets the world matrix of the bounding box
  7149. * @returns a matrix
  7150. */
  7151. getWorldMatrix(): DeepImmutable<Matrix>;
  7152. /** @hidden */
  7153. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7154. /**
  7155. * Tests if the bounding sphere is intersecting the frustum planes
  7156. * @param frustumPlanes defines the frustum planes to test
  7157. * @returns true if there is an intersection
  7158. */
  7159. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7160. /**
  7161. * Tests if the bounding sphere center is in between the frustum planes.
  7162. * Used for optimistic fast inclusion.
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @returns true if the sphere center is in between the frustum planes
  7165. */
  7166. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a point is inside the bounding sphere
  7169. * @param point defines the point to test
  7170. * @returns true if the point is inside the bounding sphere
  7171. */
  7172. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7173. /**
  7174. * Checks if two sphere intersct
  7175. * @param sphere0 sphere 0
  7176. * @param sphere1 sphere 1
  7177. * @returns true if the speres intersect
  7178. */
  7179. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7180. }
  7181. }
  7182. declare module "babylonjs/Culling/boundingBox" {
  7183. import { DeepImmutable } from "babylonjs/types";
  7184. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7185. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7186. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7187. /**
  7188. * Class used to store bounding box information
  7189. */
  7190. export class BoundingBox implements ICullable {
  7191. /**
  7192. * Gets the 8 vectors representing the bounding box in local space
  7193. */
  7194. readonly vectors: Vector3[];
  7195. /**
  7196. * Gets the center of the bounding box in local space
  7197. */
  7198. readonly center: Vector3;
  7199. /**
  7200. * Gets the center of the bounding box in world space
  7201. */
  7202. readonly centerWorld: Vector3;
  7203. /**
  7204. * Gets the extend size in local space
  7205. */
  7206. readonly extendSize: Vector3;
  7207. /**
  7208. * Gets the extend size in world space
  7209. */
  7210. readonly extendSizeWorld: Vector3;
  7211. /**
  7212. * Gets the OBB (object bounding box) directions
  7213. */
  7214. readonly directions: Vector3[];
  7215. /**
  7216. * Gets the 8 vectors representing the bounding box in world space
  7217. */
  7218. readonly vectorsWorld: Vector3[];
  7219. /**
  7220. * Gets the minimum vector in world space
  7221. */
  7222. readonly minimumWorld: Vector3;
  7223. /**
  7224. * Gets the maximum vector in world space
  7225. */
  7226. readonly maximumWorld: Vector3;
  7227. /**
  7228. * Gets the minimum vector in local space
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * Gets the maximum vector in local space
  7233. */
  7234. readonly maximum: Vector3;
  7235. private _worldMatrix;
  7236. private static readonly TmpVector3;
  7237. /**
  7238. * @hidden
  7239. */
  7240. _tag: number;
  7241. /**
  7242. * Creates a new bounding box
  7243. * @param min defines the minimum vector (in local space)
  7244. * @param max defines the maximum vector (in local space)
  7245. * @param worldMatrix defines the new world matrix
  7246. */
  7247. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7248. /**
  7249. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7250. * @param min defines the new minimum vector (in local space)
  7251. * @param max defines the new maximum vector (in local space)
  7252. * @param worldMatrix defines the new world matrix
  7253. */
  7254. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Scale the current bounding box by applying a scale factor
  7257. * @param factor defines the scale factor to apply
  7258. * @returns the current bounding box
  7259. */
  7260. scale(factor: number): BoundingBox;
  7261. /**
  7262. * Gets the world matrix of the bounding box
  7263. * @returns a matrix
  7264. */
  7265. getWorldMatrix(): DeepImmutable<Matrix>;
  7266. /** @hidden */
  7267. _update(world: DeepImmutable<Matrix>): void;
  7268. /**
  7269. * Tests if the bounding box is intersecting the frustum planes
  7270. * @param frustumPlanes defines the frustum planes to test
  7271. * @returns true if there is an intersection
  7272. */
  7273. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /**
  7275. * Tests if the bounding box is entirely inside the frustum planes
  7276. * @param frustumPlanes defines the frustum planes to test
  7277. * @returns true if there is an inclusion
  7278. */
  7279. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7280. /**
  7281. * Tests if a point is inside the bounding box
  7282. * @param point defines the point to test
  7283. * @returns true if the point is inside the bounding box
  7284. */
  7285. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7286. /**
  7287. * Tests if the bounding box intersects with a bounding sphere
  7288. * @param sphere defines the sphere to test
  7289. * @returns true if there is an intersection
  7290. */
  7291. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7292. /**
  7293. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7294. * @param min defines the min vector to use
  7295. * @param max defines the max vector to use
  7296. * @returns true if there is an intersection
  7297. */
  7298. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7299. /**
  7300. * Tests if two bounding boxes are intersections
  7301. * @param box0 defines the first box to test
  7302. * @param box1 defines the second box to test
  7303. * @returns true if there is an intersection
  7304. */
  7305. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7306. /**
  7307. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7308. * @param minPoint defines the minimum vector of the bounding box
  7309. * @param maxPoint defines the maximum vector of the bounding box
  7310. * @param sphereCenter defines the sphere center
  7311. * @param sphereRadius defines the sphere radius
  7312. * @returns true if there is an intersection
  7313. */
  7314. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7315. /**
  7316. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7317. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7318. * @param frustumPlanes defines the frustum planes to test
  7319. * @return true if there is an inclusion
  7320. */
  7321. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /**
  7323. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7324. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7325. * @param frustumPlanes defines the frustum planes to test
  7326. * @return true if there is an intersection
  7327. */
  7328. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7329. }
  7330. }
  7331. declare module "babylonjs/Collisions/collider" {
  7332. import { Nullable, IndicesArray } from "babylonjs/types";
  7333. import { Vector3, Plane } from "babylonjs/Maths/math";
  7334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7335. /** @hidden */
  7336. export class Collider {
  7337. /** Define if a collision was found */
  7338. collisionFound: boolean;
  7339. /**
  7340. * Define last intersection point in local space
  7341. */
  7342. intersectionPoint: Vector3;
  7343. /**
  7344. * Define last collided mesh
  7345. */
  7346. collidedMesh: Nullable<AbstractMesh>;
  7347. private _collisionPoint;
  7348. private _planeIntersectionPoint;
  7349. private _tempVector;
  7350. private _tempVector2;
  7351. private _tempVector3;
  7352. private _tempVector4;
  7353. private _edge;
  7354. private _baseToVertex;
  7355. private _destinationPoint;
  7356. private _slidePlaneNormal;
  7357. private _displacementVector;
  7358. /** @hidden */
  7359. _radius: Vector3;
  7360. /** @hidden */
  7361. _retry: number;
  7362. private _velocity;
  7363. private _basePoint;
  7364. private _epsilon;
  7365. /** @hidden */
  7366. _velocityWorldLength: number;
  7367. /** @hidden */
  7368. _basePointWorld: Vector3;
  7369. private _velocityWorld;
  7370. private _normalizedVelocity;
  7371. /** @hidden */
  7372. _initialVelocity: Vector3;
  7373. /** @hidden */
  7374. _initialPosition: Vector3;
  7375. private _nearestDistance;
  7376. private _collisionMask;
  7377. collisionMask: number;
  7378. /**
  7379. * Gets the plane normal used to compute the sliding response (in local space)
  7380. */
  7381. readonly slidePlaneNormal: Vector3;
  7382. /** @hidden */
  7383. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7384. /** @hidden */
  7385. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7386. /** @hidden */
  7387. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7388. /** @hidden */
  7389. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7390. /** @hidden */
  7391. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7392. /** @hidden */
  7393. _getResponse(pos: Vector3, vel: Vector3): void;
  7394. }
  7395. }
  7396. declare module "babylonjs/Culling/boundingInfo" {
  7397. import { DeepImmutable } from "babylonjs/types";
  7398. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7399. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7400. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7401. import { Collider } from "babylonjs/Collisions/collider";
  7402. /**
  7403. * Interface for cullable objects
  7404. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7405. */
  7406. export interface ICullable {
  7407. /**
  7408. * Checks if the object or part of the object is in the frustum
  7409. * @param frustumPlanes Camera near/planes
  7410. * @returns true if the object is in frustum otherwise false
  7411. */
  7412. isInFrustum(frustumPlanes: Plane[]): boolean;
  7413. /**
  7414. * Checks if a cullable object (mesh...) is in the camera frustum
  7415. * Unlike isInFrustum this cheks the full bounding box
  7416. * @param frustumPlanes Camera near/planes
  7417. * @returns true if the object is in frustum otherwise false
  7418. */
  7419. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7420. }
  7421. /**
  7422. * Info for a bounding data of a mesh
  7423. */
  7424. export class BoundingInfo implements ICullable {
  7425. /**
  7426. * Bounding box for the mesh
  7427. */
  7428. readonly boundingBox: BoundingBox;
  7429. /**
  7430. * Bounding sphere for the mesh
  7431. */
  7432. readonly boundingSphere: BoundingSphere;
  7433. private _isLocked;
  7434. private static readonly TmpVector3;
  7435. /**
  7436. * Constructs bounding info
  7437. * @param minimum min vector of the bounding box/sphere
  7438. * @param maximum max vector of the bounding box/sphere
  7439. * @param worldMatrix defines the new world matrix
  7440. */
  7441. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7442. /**
  7443. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7444. * @param min defines the new minimum vector (in local space)
  7445. * @param max defines the new maximum vector (in local space)
  7446. * @param worldMatrix defines the new world matrix
  7447. */
  7448. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7449. /**
  7450. * min vector of the bounding box/sphere
  7451. */
  7452. readonly minimum: Vector3;
  7453. /**
  7454. * max vector of the bounding box/sphere
  7455. */
  7456. readonly maximum: Vector3;
  7457. /**
  7458. * If the info is locked and won't be updated to avoid perf overhead
  7459. */
  7460. isLocked: boolean;
  7461. /**
  7462. * Updates the bounding sphere and box
  7463. * @param world world matrix to be used to update
  7464. */
  7465. update(world: DeepImmutable<Matrix>): void;
  7466. /**
  7467. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7468. * @param center New center of the bounding info
  7469. * @param extend New extend of the bounding info
  7470. * @returns the current bounding info
  7471. */
  7472. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7473. /**
  7474. * Scale the current bounding info by applying a scale factor
  7475. * @param factor defines the scale factor to apply
  7476. * @returns the current bounding info
  7477. */
  7478. scale(factor: number): BoundingInfo;
  7479. /**
  7480. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7481. * @param frustumPlanes defines the frustum to test
  7482. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7483. * @returns true if the bounding info is in the frustum planes
  7484. */
  7485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7486. /**
  7487. * Gets the world distance between the min and max points of the bounding box
  7488. */
  7489. readonly diagonalLength: number;
  7490. /**
  7491. * Checks if a cullable object (mesh...) is in the camera frustum
  7492. * Unlike isInFrustum this cheks the full bounding box
  7493. * @param frustumPlanes Camera near/planes
  7494. * @returns true if the object is in frustum otherwise false
  7495. */
  7496. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7497. /** @hidden */
  7498. _checkCollision(collider: Collider): boolean;
  7499. /**
  7500. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7501. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7502. * @param point the point to check intersection with
  7503. * @returns if the point intersects
  7504. */
  7505. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7506. /**
  7507. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7508. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7509. * @param boundingInfo the bounding info to check intersection with
  7510. * @param precise if the intersection should be done using OBB
  7511. * @returns if the bounding info intersects
  7512. */
  7513. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7514. }
  7515. }
  7516. declare module "babylonjs/Misc/smartArray" {
  7517. /**
  7518. * Defines an array and its length.
  7519. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7520. */
  7521. export interface ISmartArrayLike<T> {
  7522. /**
  7523. * The data of the array.
  7524. */
  7525. data: Array<T>;
  7526. /**
  7527. * The active length of the array.
  7528. */
  7529. length: number;
  7530. }
  7531. /**
  7532. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7533. */
  7534. export class SmartArray<T> implements ISmartArrayLike<T> {
  7535. /**
  7536. * The full set of data from the array.
  7537. */
  7538. data: Array<T>;
  7539. /**
  7540. * The active length of the array.
  7541. */
  7542. length: number;
  7543. protected _id: number;
  7544. /**
  7545. * Instantiates a Smart Array.
  7546. * @param capacity defines the default capacity of the array.
  7547. */
  7548. constructor(capacity: number);
  7549. /**
  7550. * Pushes a value at the end of the active data.
  7551. * @param value defines the object to push in the array.
  7552. */
  7553. push(value: T): void;
  7554. /**
  7555. * Iterates over the active data and apply the lambda to them.
  7556. * @param func defines the action to apply on each value.
  7557. */
  7558. forEach(func: (content: T) => void): void;
  7559. /**
  7560. * Sorts the full sets of data.
  7561. * @param compareFn defines the comparison function to apply.
  7562. */
  7563. sort(compareFn: (a: T, b: T) => number): void;
  7564. /**
  7565. * Resets the active data to an empty array.
  7566. */
  7567. reset(): void;
  7568. /**
  7569. * Releases all the data from the array as well as the array.
  7570. */
  7571. dispose(): void;
  7572. /**
  7573. * Concats the active data with a given array.
  7574. * @param array defines the data to concatenate with.
  7575. */
  7576. concat(array: any): void;
  7577. /**
  7578. * Returns the position of a value in the active data.
  7579. * @param value defines the value to find the index for
  7580. * @returns the index if found in the active data otherwise -1
  7581. */
  7582. indexOf(value: T): number;
  7583. /**
  7584. * Returns whether an element is part of the active data.
  7585. * @param value defines the value to look for
  7586. * @returns true if found in the active data otherwise false
  7587. */
  7588. contains(value: T): boolean;
  7589. private static _GlobalId;
  7590. }
  7591. /**
  7592. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7593. * The data in this array can only be present once
  7594. */
  7595. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7596. private _duplicateId;
  7597. /**
  7598. * Pushes a value at the end of the active data.
  7599. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7600. * @param value defines the object to push in the array.
  7601. */
  7602. push(value: T): void;
  7603. /**
  7604. * Pushes a value at the end of the active data.
  7605. * If the data is already present, it won t be added again
  7606. * @param value defines the object to push in the array.
  7607. * @returns true if added false if it was already present
  7608. */
  7609. pushNoDuplicate(value: T): boolean;
  7610. /**
  7611. * Resets the active data to an empty array.
  7612. */
  7613. reset(): void;
  7614. /**
  7615. * Concats the active data with a given array.
  7616. * This ensures no dupplicate will be present in the result.
  7617. * @param array defines the data to concatenate with.
  7618. */
  7619. concatWithNoDuplicate(array: any): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Materials/multiMaterial" {
  7623. import { Nullable } from "babylonjs/types";
  7624. import { Scene } from "babylonjs/scene";
  7625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7626. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7627. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7628. import { Material } from "babylonjs/Materials/material";
  7629. /**
  7630. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7631. * separate meshes. This can be use to improve performances.
  7632. * @see http://doc.babylonjs.com/how_to/multi_materials
  7633. */
  7634. export class MultiMaterial extends Material {
  7635. private _subMaterials;
  7636. /**
  7637. * Gets or Sets the list of Materials used within the multi material.
  7638. * They need to be ordered according to the submeshes order in the associated mesh
  7639. */
  7640. subMaterials: Nullable<Material>[];
  7641. /**
  7642. * Function used to align with Node.getChildren()
  7643. * @returns the list of Materials used within the multi material
  7644. */
  7645. getChildren(): Nullable<Material>[];
  7646. /**
  7647. * Instantiates a new Multi Material
  7648. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7649. * separate meshes. This can be use to improve performances.
  7650. * @see http://doc.babylonjs.com/how_to/multi_materials
  7651. * @param name Define the name in the scene
  7652. * @param scene Define the scene the material belongs to
  7653. */
  7654. constructor(name: string, scene: Scene);
  7655. private _hookArray;
  7656. /**
  7657. * Get one of the submaterial by its index in the submaterials array
  7658. * @param index The index to look the sub material at
  7659. * @returns The Material if the index has been defined
  7660. */
  7661. getSubMaterial(index: number): Nullable<Material>;
  7662. /**
  7663. * Get the list of active textures for the whole sub materials list.
  7664. * @returns All the textures that will be used during the rendering
  7665. */
  7666. getActiveTextures(): BaseTexture[];
  7667. /**
  7668. * Gets the current class name of the material e.g. "MultiMaterial"
  7669. * Mainly use in serialization.
  7670. * @returns the class name
  7671. */
  7672. getClassName(): string;
  7673. /**
  7674. * Checks if the material is ready to render the requested sub mesh
  7675. * @param mesh Define the mesh the submesh belongs to
  7676. * @param subMesh Define the sub mesh to look readyness for
  7677. * @param useInstances Define whether or not the material is used with instances
  7678. * @returns true if ready, otherwise false
  7679. */
  7680. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7681. /**
  7682. * Clones the current material and its related sub materials
  7683. * @param name Define the name of the newly cloned material
  7684. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7685. * @returns the cloned material
  7686. */
  7687. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7688. /**
  7689. * Serializes the materials into a JSON representation.
  7690. * @returns the JSON representation
  7691. */
  7692. serialize(): any;
  7693. /**
  7694. * Dispose the material and release its associated resources
  7695. * @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)
  7696. * @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)
  7697. * @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)
  7698. */
  7699. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7700. /**
  7701. * Creates a MultiMaterial from parsed MultiMaterial data.
  7702. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7703. * @param scene defines the hosting scene
  7704. * @returns a new MultiMaterial
  7705. */
  7706. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7707. }
  7708. }
  7709. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7710. /**
  7711. * Class used to represent data loading progression
  7712. */
  7713. export class SceneLoaderFlags {
  7714. private static _ForceFullSceneLoadingForIncremental;
  7715. private static _ShowLoadingScreen;
  7716. private static _CleanBoneMatrixWeights;
  7717. private static _loggingLevel;
  7718. /**
  7719. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7720. */
  7721. static ForceFullSceneLoadingForIncremental: boolean;
  7722. /**
  7723. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7724. */
  7725. static ShowLoadingScreen: boolean;
  7726. /**
  7727. * Defines the current logging level (while loading the scene)
  7728. * @ignorenaming
  7729. */
  7730. static loggingLevel: number;
  7731. /**
  7732. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7733. */
  7734. static CleanBoneMatrixWeights: boolean;
  7735. }
  7736. }
  7737. declare module "babylonjs/Meshes/transformNode" {
  7738. import { DeepImmutable } from "babylonjs/types";
  7739. import { Observable } from "babylonjs/Misc/observable";
  7740. import { Nullable } from "babylonjs/types";
  7741. import { Camera } from "babylonjs/Cameras/camera";
  7742. import { Scene } from "babylonjs/scene";
  7743. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7744. import { Node } from "babylonjs/node";
  7745. import { Bone } from "babylonjs/Bones/bone";
  7746. /**
  7747. * 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.
  7748. * @see https://doc.babylonjs.com/how_to/transformnode
  7749. */
  7750. export class TransformNode extends Node {
  7751. /**
  7752. * Object will not rotate to face the camera
  7753. */
  7754. static BILLBOARDMODE_NONE: number;
  7755. /**
  7756. * Object will rotate to face the camera but only on the x axis
  7757. */
  7758. static BILLBOARDMODE_X: number;
  7759. /**
  7760. * Object will rotate to face the camera but only on the y axis
  7761. */
  7762. static BILLBOARDMODE_Y: number;
  7763. /**
  7764. * Object will rotate to face the camera but only on the z axis
  7765. */
  7766. static BILLBOARDMODE_Z: number;
  7767. /**
  7768. * Object will rotate to face the camera
  7769. */
  7770. static BILLBOARDMODE_ALL: number;
  7771. private _forward;
  7772. private _forwardInverted;
  7773. private _up;
  7774. private _right;
  7775. private _rightInverted;
  7776. private _position;
  7777. private _rotation;
  7778. private _rotationQuaternion;
  7779. protected _scaling: Vector3;
  7780. protected _isDirty: boolean;
  7781. private _transformToBoneReferal;
  7782. private _billboardMode;
  7783. /**
  7784. * Gets or sets the billboard mode. Default is 0.
  7785. *
  7786. * | Value | Type | Description |
  7787. * | --- | --- | --- |
  7788. * | 0 | BILLBOARDMODE_NONE | |
  7789. * | 1 | BILLBOARDMODE_X | |
  7790. * | 2 | BILLBOARDMODE_Y | |
  7791. * | 4 | BILLBOARDMODE_Z | |
  7792. * | 7 | BILLBOARDMODE_ALL | |
  7793. *
  7794. */
  7795. billboardMode: number;
  7796. private _preserveParentRotationForBillboard;
  7797. /**
  7798. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7799. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7800. */
  7801. preserveParentRotationForBillboard: boolean;
  7802. /**
  7803. * 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
  7804. */
  7805. scalingDeterminant: number;
  7806. private _infiniteDistance;
  7807. /**
  7808. * Gets or sets the distance of the object to max, often used by skybox
  7809. */
  7810. infiniteDistance: boolean;
  7811. /**
  7812. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7813. * By default the system will update normals to compensate
  7814. */
  7815. ignoreNonUniformScaling: boolean;
  7816. /**
  7817. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7818. */
  7819. reIntegrateRotationIntoRotationQuaternion: boolean;
  7820. /** @hidden */
  7821. _poseMatrix: Nullable<Matrix>;
  7822. /** @hidden */
  7823. _localMatrix: Matrix;
  7824. private _usePivotMatrix;
  7825. private _absolutePosition;
  7826. private _pivotMatrix;
  7827. private _pivotMatrixInverse;
  7828. protected _postMultiplyPivotMatrix: boolean;
  7829. protected _isWorldMatrixFrozen: boolean;
  7830. /** @hidden */
  7831. _indexInSceneTransformNodesArray: number;
  7832. /**
  7833. * An event triggered after the world matrix is updated
  7834. */
  7835. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7836. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7837. /**
  7838. * Gets a string identifying the name of the class
  7839. * @returns "TransformNode" string
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7844. */
  7845. position: Vector3;
  7846. /**
  7847. * 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)).
  7848. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7849. */
  7850. rotation: Vector3;
  7851. /**
  7852. * 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)).
  7853. */
  7854. scaling: Vector3;
  7855. /**
  7856. * 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).
  7857. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7858. */
  7859. rotationQuaternion: Nullable<Quaternion>;
  7860. /**
  7861. * The forward direction of that transform in world space.
  7862. */
  7863. readonly forward: Vector3;
  7864. /**
  7865. * The up direction of that transform in world space.
  7866. */
  7867. readonly up: Vector3;
  7868. /**
  7869. * The right direction of that transform in world space.
  7870. */
  7871. readonly right: Vector3;
  7872. /**
  7873. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7874. * @param matrix the matrix to copy the pose from
  7875. * @returns this TransformNode.
  7876. */
  7877. updatePoseMatrix(matrix: Matrix): TransformNode;
  7878. /**
  7879. * Returns the mesh Pose matrix.
  7880. * @returns the pose matrix
  7881. */
  7882. getPoseMatrix(): Matrix;
  7883. /** @hidden */
  7884. _isSynchronized(): boolean;
  7885. /** @hidden */
  7886. _initCache(): void;
  7887. /**
  7888. * Flag the transform node as dirty (Forcing it to update everything)
  7889. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7890. * @returns this transform node
  7891. */
  7892. markAsDirty(property: string): TransformNode;
  7893. /**
  7894. * Returns the current mesh absolute position.
  7895. * Returns a Vector3.
  7896. */
  7897. readonly absolutePosition: Vector3;
  7898. /**
  7899. * Sets a new matrix to apply before all other transformation
  7900. * @param matrix defines the transform matrix
  7901. * @returns the current TransformNode
  7902. */
  7903. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7904. /**
  7905. * Sets a new pivot matrix to the current node
  7906. * @param matrix defines the new pivot matrix to use
  7907. * @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
  7908. * @returns the current TransformNode
  7909. */
  7910. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7911. /**
  7912. * Returns the mesh pivot matrix.
  7913. * Default : Identity.
  7914. * @returns the matrix
  7915. */
  7916. getPivotMatrix(): Matrix;
  7917. /**
  7918. * Prevents the World matrix to be computed any longer.
  7919. * @returns the TransformNode.
  7920. */
  7921. freezeWorldMatrix(): TransformNode;
  7922. /**
  7923. * Allows back the World matrix computation.
  7924. * @returns the TransformNode.
  7925. */
  7926. unfreezeWorldMatrix(): this;
  7927. /**
  7928. * True if the World matrix has been frozen.
  7929. */
  7930. readonly isWorldMatrixFrozen: boolean;
  7931. /**
  7932. * Retuns the mesh absolute position in the World.
  7933. * @returns a Vector3.
  7934. */
  7935. getAbsolutePosition(): Vector3;
  7936. /**
  7937. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7938. * @param absolutePosition the absolute position to set
  7939. * @returns the TransformNode.
  7940. */
  7941. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7942. /**
  7943. * Sets the mesh position in its local space.
  7944. * @param vector3 the position to set in localspace
  7945. * @returns the TransformNode.
  7946. */
  7947. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7948. /**
  7949. * Returns the mesh position in the local space from the current World matrix values.
  7950. * @returns a new Vector3.
  7951. */
  7952. getPositionExpressedInLocalSpace(): Vector3;
  7953. /**
  7954. * Translates the mesh along the passed Vector3 in its local space.
  7955. * @param vector3 the distance to translate in localspace
  7956. * @returns the TransformNode.
  7957. */
  7958. locallyTranslate(vector3: Vector3): TransformNode;
  7959. private static _lookAtVectorCache;
  7960. /**
  7961. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7962. * @param targetPoint the position (must be in same space as current mesh) to look at
  7963. * @param yawCor optional yaw (y-axis) correction in radians
  7964. * @param pitchCor optional pitch (x-axis) correction in radians
  7965. * @param rollCor optional roll (z-axis) correction in radians
  7966. * @param space the choosen space of the target
  7967. * @returns the TransformNode.
  7968. */
  7969. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7970. /**
  7971. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7972. * This Vector3 is expressed in the World space.
  7973. * @param localAxis axis to rotate
  7974. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7975. */
  7976. getDirection(localAxis: Vector3): Vector3;
  7977. /**
  7978. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7979. * localAxis is expressed in the mesh local space.
  7980. * result is computed in the Wordl space from the mesh World matrix.
  7981. * @param localAxis axis to rotate
  7982. * @param result the resulting transformnode
  7983. * @returns this TransformNode.
  7984. */
  7985. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7986. /**
  7987. * Sets this transform node rotation to the given local axis.
  7988. * @param localAxis the axis in local space
  7989. * @param yawCor optional yaw (y-axis) correction in radians
  7990. * @param pitchCor optional pitch (x-axis) correction in radians
  7991. * @param rollCor optional roll (z-axis) correction in radians
  7992. * @returns this TransformNode
  7993. */
  7994. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7995. /**
  7996. * Sets a new pivot point to the current node
  7997. * @param point defines the new pivot point to use
  7998. * @param space defines if the point is in world or local space (local by default)
  7999. * @returns the current TransformNode
  8000. */
  8001. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8002. /**
  8003. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8004. * @returns the pivot point
  8005. */
  8006. getPivotPoint(): Vector3;
  8007. /**
  8008. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8009. * @param result the vector3 to store the result
  8010. * @returns this TransformNode.
  8011. */
  8012. getPivotPointToRef(result: Vector3): TransformNode;
  8013. /**
  8014. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8015. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8016. */
  8017. getAbsolutePivotPoint(): Vector3;
  8018. /**
  8019. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8020. * @param result vector3 to store the result
  8021. * @returns this TransformNode.
  8022. */
  8023. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8024. /**
  8025. * Defines the passed node as the parent of the current node.
  8026. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8027. * @see https://doc.babylonjs.com/how_to/parenting
  8028. * @param node the node ot set as the parent
  8029. * @returns this TransformNode.
  8030. */
  8031. setParent(node: Nullable<Node>): TransformNode;
  8032. private _nonUniformScaling;
  8033. /**
  8034. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8035. */
  8036. readonly nonUniformScaling: boolean;
  8037. /** @hidden */
  8038. _updateNonUniformScalingState(value: boolean): boolean;
  8039. /**
  8040. * Attach the current TransformNode to another TransformNode associated with a bone
  8041. * @param bone Bone affecting the TransformNode
  8042. * @param affectedTransformNode TransformNode associated with the bone
  8043. * @returns this object
  8044. */
  8045. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8046. /**
  8047. * Detach the transform node if its associated with a bone
  8048. * @returns this object
  8049. */
  8050. detachFromBone(): TransformNode;
  8051. private static _rotationAxisCache;
  8052. /**
  8053. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8054. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8055. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8056. * The passed axis is also normalized.
  8057. * @param axis the axis to rotate around
  8058. * @param amount the amount to rotate in radians
  8059. * @param space Space to rotate in (Default: local)
  8060. * @returns the TransformNode.
  8061. */
  8062. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8063. /**
  8064. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8065. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8066. * The passed axis is also normalized. .
  8067. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8068. * @param point the point to rotate around
  8069. * @param axis the axis to rotate around
  8070. * @param amount the amount to rotate in radians
  8071. * @returns the TransformNode
  8072. */
  8073. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8074. /**
  8075. * Translates the mesh along the axis vector for the passed distance in the given space.
  8076. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8077. * @param axis the axis to translate in
  8078. * @param distance the distance to translate
  8079. * @param space Space to rotate in (Default: local)
  8080. * @returns the TransformNode.
  8081. */
  8082. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8083. /**
  8084. * Adds a rotation step to the mesh current rotation.
  8085. * x, y, z are Euler angles expressed in radians.
  8086. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8087. * This means this rotation is made in the mesh local space only.
  8088. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8089. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8090. * ```javascript
  8091. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8092. * ```
  8093. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8094. * 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.
  8095. * @param x Rotation to add
  8096. * @param y Rotation to add
  8097. * @param z Rotation to add
  8098. * @returns the TransformNode.
  8099. */
  8100. addRotation(x: number, y: number, z: number): TransformNode;
  8101. /**
  8102. * @hidden
  8103. */
  8104. protected _getEffectiveParent(): Nullable<Node>;
  8105. /**
  8106. * Computes the world matrix of the node
  8107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8108. * @returns the world matrix
  8109. */
  8110. computeWorldMatrix(force?: boolean): Matrix;
  8111. protected _afterComputeWorldMatrix(): void;
  8112. /**
  8113. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8114. * @param func callback function to add
  8115. *
  8116. * @returns the TransformNode.
  8117. */
  8118. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8119. /**
  8120. * Removes a registered callback function.
  8121. * @param func callback function to remove
  8122. * @returns the TransformNode.
  8123. */
  8124. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8125. /**
  8126. * Gets the position of the current mesh in camera space
  8127. * @param camera defines the camera to use
  8128. * @returns a position
  8129. */
  8130. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8131. /**
  8132. * Returns the distance from the mesh to the active camera
  8133. * @param camera defines the camera to use
  8134. * @returns the distance
  8135. */
  8136. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8137. /**
  8138. * Clone the current transform node
  8139. * @param name Name of the new clone
  8140. * @param newParent New parent for the clone
  8141. * @param doNotCloneChildren Do not clone children hierarchy
  8142. * @returns the new transform node
  8143. */
  8144. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8145. /**
  8146. * Serializes the objects information.
  8147. * @param currentSerializationObject defines the object to serialize in
  8148. * @returns the serialized object
  8149. */
  8150. serialize(currentSerializationObject?: any): any;
  8151. /**
  8152. * Returns a new TransformNode object parsed from the source provided.
  8153. * @param parsedTransformNode is the source.
  8154. * @param scene the scne the object belongs to
  8155. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8156. * @returns a new TransformNode object parsed from the source provided.
  8157. */
  8158. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8159. /**
  8160. * Get all child-transformNodes of this node
  8161. * @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
  8162. * @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
  8163. * @returns an array of TransformNode
  8164. */
  8165. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8166. /**
  8167. * Releases resources associated with this transform node.
  8168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8170. */
  8171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8172. }
  8173. }
  8174. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8175. /**
  8176. * Class used to override all child animations of a given target
  8177. */
  8178. export class AnimationPropertiesOverride {
  8179. /**
  8180. * Gets or sets a value indicating if animation blending must be used
  8181. */
  8182. enableBlending: boolean;
  8183. /**
  8184. * Gets or sets the blending speed to use when enableBlending is true
  8185. */
  8186. blendingSpeed: number;
  8187. /**
  8188. * Gets or sets the default loop mode to use
  8189. */
  8190. loopMode: number;
  8191. }
  8192. }
  8193. declare module "babylonjs/Bones/bone" {
  8194. import { Skeleton } from "babylonjs/Bones/skeleton";
  8195. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8196. import { Nullable } from "babylonjs/types";
  8197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8198. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8199. import { Node } from "babylonjs/node";
  8200. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8201. /**
  8202. * Class used to store bone information
  8203. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8204. */
  8205. export class Bone extends Node {
  8206. /**
  8207. * defines the bone name
  8208. */
  8209. name: string;
  8210. private static _tmpVecs;
  8211. private static _tmpQuat;
  8212. private static _tmpMats;
  8213. /**
  8214. * Gets the list of child bones
  8215. */
  8216. children: Bone[];
  8217. /** Gets the animations associated with this bone */
  8218. animations: import("babylonjs/Animations/animation").Animation[];
  8219. /**
  8220. * Gets or sets bone length
  8221. */
  8222. length: number;
  8223. /**
  8224. * @hidden Internal only
  8225. * Set this value to map this bone to a different index in the transform matrices
  8226. * Set this value to -1 to exclude the bone from the transform matrices
  8227. */
  8228. _index: Nullable<number>;
  8229. private _skeleton;
  8230. private _localMatrix;
  8231. private _restPose;
  8232. private _baseMatrix;
  8233. private _absoluteTransform;
  8234. private _invertedAbsoluteTransform;
  8235. private _parent;
  8236. private _scalingDeterminant;
  8237. private _worldTransform;
  8238. private _localScaling;
  8239. private _localRotation;
  8240. private _localPosition;
  8241. private _needToDecompose;
  8242. private _needToCompose;
  8243. /** @hidden */
  8244. _linkedTransformNode: Nullable<TransformNode>;
  8245. /** @hidden */
  8246. _waitingTransformNodeId: Nullable<string>;
  8247. /** @hidden */
  8248. /** @hidden */
  8249. _matrix: Matrix;
  8250. /**
  8251. * Create a new bone
  8252. * @param name defines the bone name
  8253. * @param skeleton defines the parent skeleton
  8254. * @param parentBone defines the parent (can be null if the bone is the root)
  8255. * @param localMatrix defines the local matrix
  8256. * @param restPose defines the rest pose matrix
  8257. * @param baseMatrix defines the base matrix
  8258. * @param index defines index of the bone in the hiearchy
  8259. */
  8260. constructor(
  8261. /**
  8262. * defines the bone name
  8263. */
  8264. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8265. /**
  8266. * Gets the current object class name.
  8267. * @return the class name
  8268. */
  8269. getClassName(): string;
  8270. /**
  8271. * Gets the parent skeleton
  8272. * @returns a skeleton
  8273. */
  8274. getSkeleton(): Skeleton;
  8275. /**
  8276. * Gets parent bone
  8277. * @returns a bone or null if the bone is the root of the bone hierarchy
  8278. */
  8279. getParent(): Nullable<Bone>;
  8280. /**
  8281. * Returns an array containing the root bones
  8282. * @returns an array containing the root bones
  8283. */
  8284. getChildren(): Array<Bone>;
  8285. /**
  8286. * Sets the parent bone
  8287. * @param parent defines the parent (can be null if the bone is the root)
  8288. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8289. */
  8290. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8291. /**
  8292. * Gets the local matrix
  8293. * @returns a matrix
  8294. */
  8295. getLocalMatrix(): Matrix;
  8296. /**
  8297. * Gets the base matrix (initial matrix which remains unchanged)
  8298. * @returns a matrix
  8299. */
  8300. getBaseMatrix(): Matrix;
  8301. /**
  8302. * Gets the rest pose matrix
  8303. * @returns a matrix
  8304. */
  8305. getRestPose(): Matrix;
  8306. /**
  8307. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8308. */
  8309. getWorldMatrix(): Matrix;
  8310. /**
  8311. * Sets the local matrix to rest pose matrix
  8312. */
  8313. returnToRest(): void;
  8314. /**
  8315. * Gets the inverse of the absolute transform matrix.
  8316. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8317. * @returns a matrix
  8318. */
  8319. getInvertedAbsoluteTransform(): Matrix;
  8320. /**
  8321. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8322. * @returns a matrix
  8323. */
  8324. getAbsoluteTransform(): Matrix;
  8325. /**
  8326. * Links with the given transform node.
  8327. * The local matrix of this bone is copied from the transform node every frame.
  8328. * @param transformNode defines the transform node to link to
  8329. */
  8330. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8331. /** Gets or sets current position (in local space) */
  8332. position: Vector3;
  8333. /** Gets or sets current rotation (in local space) */
  8334. rotation: Vector3;
  8335. /** Gets or sets current rotation quaternion (in local space) */
  8336. rotationQuaternion: Quaternion;
  8337. /** Gets or sets current scaling (in local space) */
  8338. scaling: Vector3;
  8339. /**
  8340. * Gets the animation properties override
  8341. */
  8342. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8343. private _decompose;
  8344. private _compose;
  8345. /**
  8346. * Update the base and local matrices
  8347. * @param matrix defines the new base or local matrix
  8348. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8349. * @param updateLocalMatrix defines if the local matrix should be updated
  8350. */
  8351. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8352. /** @hidden */
  8353. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8354. /**
  8355. * Flag the bone as dirty (Forcing it to update everything)
  8356. */
  8357. markAsDirty(): void;
  8358. /** @hidden */
  8359. _markAsDirtyAndCompose(): void;
  8360. private _markAsDirtyAndDecompose;
  8361. /**
  8362. * Translate the bone in local or world space
  8363. * @param vec The amount to translate the bone
  8364. * @param space The space that the translation is in
  8365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8366. */
  8367. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8368. /**
  8369. * Set the postion of the bone in local or world space
  8370. * @param position The position to set the bone
  8371. * @param space The space that the position is in
  8372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8373. */
  8374. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8375. /**
  8376. * Set the absolute position of the bone (world space)
  8377. * @param position The position to set the bone
  8378. * @param mesh The mesh that this bone is attached to
  8379. */
  8380. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8381. /**
  8382. * Scale the bone on the x, y and z axes (in local space)
  8383. * @param x The amount to scale the bone on the x axis
  8384. * @param y The amount to scale the bone on the y axis
  8385. * @param z The amount to scale the bone on the z axis
  8386. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8387. */
  8388. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8389. /**
  8390. * Set the bone scaling in local space
  8391. * @param scale defines the scaling vector
  8392. */
  8393. setScale(scale: Vector3): void;
  8394. /**
  8395. * Gets the current scaling in local space
  8396. * @returns the current scaling vector
  8397. */
  8398. getScale(): Vector3;
  8399. /**
  8400. * Gets the current scaling in local space and stores it in a target vector
  8401. * @param result defines the target vector
  8402. */
  8403. getScaleToRef(result: Vector3): void;
  8404. /**
  8405. * Set the yaw, pitch, and roll of the bone in local or world space
  8406. * @param yaw The rotation of the bone on the y axis
  8407. * @param pitch The rotation of the bone on the x axis
  8408. * @param roll The rotation of the bone on the z axis
  8409. * @param space The space that the axes of rotation are in
  8410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8411. */
  8412. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8413. /**
  8414. * Add a rotation to the bone on an axis in local or world space
  8415. * @param axis The axis to rotate the bone on
  8416. * @param amount The amount to rotate the bone
  8417. * @param space The space that the axis is in
  8418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8419. */
  8420. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8421. /**
  8422. * Set the rotation of the bone to a particular axis angle in local or world space
  8423. * @param axis The axis to rotate the bone on
  8424. * @param angle The angle that the bone should be rotated to
  8425. * @param space The space that the axis is in
  8426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8427. */
  8428. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8429. /**
  8430. * Set the euler rotation of the bone in local of world space
  8431. * @param rotation The euler rotation that the bone should be set to
  8432. * @param space The space that the rotation is in
  8433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8434. */
  8435. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8436. /**
  8437. * Set the quaternion rotation of the bone in local of world space
  8438. * @param quat The quaternion rotation that the bone should be set to
  8439. * @param space The space that the rotation is in
  8440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8441. */
  8442. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8443. /**
  8444. * Set the rotation matrix of the bone in local of world space
  8445. * @param rotMat The rotation matrix that the bone should be set to
  8446. * @param space The space that the rotation is in
  8447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8448. */
  8449. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8450. private _rotateWithMatrix;
  8451. private _getNegativeRotationToRef;
  8452. /**
  8453. * Get the position of the bone in local or world space
  8454. * @param space The space that the returned position is in
  8455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8456. * @returns The position of the bone
  8457. */
  8458. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8459. /**
  8460. * Copy the position of the bone to a vector3 in local or world space
  8461. * @param space The space that the returned position is in
  8462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8463. * @param result The vector3 to copy the position to
  8464. */
  8465. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8466. /**
  8467. * Get the absolute position of the bone (world space)
  8468. * @param mesh The mesh that this bone is attached to
  8469. * @returns The absolute position of the bone
  8470. */
  8471. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8472. /**
  8473. * Copy the absolute position of the bone (world space) to the result param
  8474. * @param mesh The mesh that this bone is attached to
  8475. * @param result The vector3 to copy the absolute position to
  8476. */
  8477. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8478. /**
  8479. * Compute the absolute transforms of this bone and its children
  8480. */
  8481. computeAbsoluteTransforms(): void;
  8482. /**
  8483. * Get the world direction from an axis that is in the local space of the bone
  8484. * @param localAxis The local direction that is used to compute the world direction
  8485. * @param mesh The mesh that this bone is attached to
  8486. * @returns The world direction
  8487. */
  8488. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8489. /**
  8490. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8491. * @param localAxis The local direction that is used to compute the world direction
  8492. * @param mesh The mesh that this bone is attached to
  8493. * @param result The vector3 that the world direction will be copied to
  8494. */
  8495. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8496. /**
  8497. * Get the euler rotation of the bone in local or world space
  8498. * @param space The space that the rotation should be in
  8499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8500. * @returns The euler rotation
  8501. */
  8502. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8503. /**
  8504. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8505. * @param space The space that the rotation should be in
  8506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8507. * @param result The vector3 that the rotation should be copied to
  8508. */
  8509. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8510. /**
  8511. * Get the quaternion rotation of the bone in either local or world space
  8512. * @param space The space that the rotation should be in
  8513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8514. * @returns The quaternion rotation
  8515. */
  8516. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8517. /**
  8518. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8519. * @param space The space that the rotation should be in
  8520. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8521. * @param result The quaternion that the rotation should be copied to
  8522. */
  8523. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8524. /**
  8525. * Get the rotation matrix of the bone in local or world space
  8526. * @param space The space that the rotation should be in
  8527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8528. * @returns The rotation matrix
  8529. */
  8530. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8531. /**
  8532. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8533. * @param space The space that the rotation should be in
  8534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8535. * @param result The quaternion that the rotation should be copied to
  8536. */
  8537. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8538. /**
  8539. * Get the world position of a point that is in the local space of the bone
  8540. * @param position The local position
  8541. * @param mesh The mesh that this bone is attached to
  8542. * @returns The world position
  8543. */
  8544. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8545. /**
  8546. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8547. * @param position The local position
  8548. * @param mesh The mesh that this bone is attached to
  8549. * @param result The vector3 that the world position should be copied to
  8550. */
  8551. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8552. /**
  8553. * Get the local position of a point that is in world space
  8554. * @param position The world position
  8555. * @param mesh The mesh that this bone is attached to
  8556. * @returns The local position
  8557. */
  8558. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8559. /**
  8560. * Get the local position of a point that is in world space and copy it to the result param
  8561. * @param position The world position
  8562. * @param mesh The mesh that this bone is attached to
  8563. * @param result The vector3 that the local position should be copied to
  8564. */
  8565. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8566. }
  8567. }
  8568. declare module "babylonjs/Misc/iInspectable" {
  8569. /**
  8570. * Enum that determines the text-wrapping mode to use.
  8571. */
  8572. export enum InspectableType {
  8573. /**
  8574. * Checkbox for booleans
  8575. */
  8576. Checkbox = 0,
  8577. /**
  8578. * Sliders for numbers
  8579. */
  8580. Slider = 1,
  8581. /**
  8582. * Vector3
  8583. */
  8584. Vector3 = 2,
  8585. /**
  8586. * Quaternions
  8587. */
  8588. Quaternion = 3,
  8589. /**
  8590. * Color3
  8591. */
  8592. Color3 = 4
  8593. }
  8594. /**
  8595. * Interface used to define custom inspectable properties.
  8596. * This interface is used by the inspector to display custom property grids
  8597. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8598. */
  8599. export interface IInspectable {
  8600. /**
  8601. * Gets the label to display
  8602. */
  8603. label: string;
  8604. /**
  8605. * Gets the name of the property to edit
  8606. */
  8607. propertyName: string;
  8608. /**
  8609. * Gets the type of the editor to use
  8610. */
  8611. type: InspectableType;
  8612. /**
  8613. * Gets the minimum value of the property when using in "slider" mode
  8614. */
  8615. min?: number;
  8616. /**
  8617. * Gets the maximum value of the property when using in "slider" mode
  8618. */
  8619. max?: number;
  8620. /**
  8621. * Gets the setp to use when using in "slider" mode
  8622. */
  8623. step?: number;
  8624. }
  8625. }
  8626. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8627. import { Nullable } from "babylonjs/types";
  8628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8629. /**
  8630. * This represents the required contract to create a new type of texture loader.
  8631. */
  8632. export interface IInternalTextureLoader {
  8633. /**
  8634. * Defines wether the loader supports cascade loading the different faces.
  8635. */
  8636. supportCascades: boolean;
  8637. /**
  8638. * This returns if the loader support the current file information.
  8639. * @param extension defines the file extension of the file being loaded
  8640. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8641. * @param fallback defines the fallback internal texture if any
  8642. * @param isBase64 defines whether the texture is encoded as a base64
  8643. * @param isBuffer defines whether the texture data are stored as a buffer
  8644. * @returns true if the loader can load the specified file
  8645. */
  8646. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8647. /**
  8648. * Transform the url before loading if required.
  8649. * @param rootUrl the url of the texture
  8650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8651. * @returns the transformed texture
  8652. */
  8653. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8654. /**
  8655. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8656. * @param rootUrl the url of the texture
  8657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8658. * @returns the fallback texture
  8659. */
  8660. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8661. /**
  8662. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8663. * @param data contains the texture data
  8664. * @param texture defines the BabylonJS internal texture
  8665. * @param createPolynomials will be true if polynomials have been requested
  8666. * @param onLoad defines the callback to trigger once the texture is ready
  8667. * @param onError defines the callback to trigger in case of error
  8668. */
  8669. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8670. /**
  8671. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8672. * @param data contains the texture data
  8673. * @param texture defines the BabylonJS internal texture
  8674. * @param callback defines the method to call once ready to upload
  8675. */
  8676. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8677. }
  8678. }
  8679. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8680. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8681. import { Nullable } from "babylonjs/types";
  8682. import { Scene } from "babylonjs/scene";
  8683. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8684. module "babylonjs/Engines/engine" {
  8685. interface Engine {
  8686. /**
  8687. * Creates a depth stencil cube texture.
  8688. * This is only available in WebGL 2.
  8689. * @param size The size of face edge in the cube texture.
  8690. * @param options The options defining the cube texture.
  8691. * @returns The cube texture
  8692. */
  8693. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8694. /**
  8695. * Creates a cube texture
  8696. * @param rootUrl defines the url where the files to load is located
  8697. * @param scene defines the current scene
  8698. * @param files defines the list of files to load (1 per face)
  8699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8700. * @param onLoad defines an optional callback raised when the texture is loaded
  8701. * @param onError defines an optional callback raised if there is an issue to load the texture
  8702. * @param format defines the format of the data
  8703. * @param forcedExtension defines the extension to use to pick the right loader
  8704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8709. * @returns the cube texture as an InternalTexture
  8710. */
  8711. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8712. /**
  8713. * Creates a cube texture
  8714. * @param rootUrl defines the url where the files to load is located
  8715. * @param scene defines the current scene
  8716. * @param files defines the list of files to load (1 per face)
  8717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8718. * @param onLoad defines an optional callback raised when the texture is loaded
  8719. * @param onError defines an optional callback raised if there is an issue to load the texture
  8720. * @param format defines the format of the data
  8721. * @param forcedExtension defines the extension to use to pick the right loader
  8722. * @returns the cube texture as an InternalTexture
  8723. */
  8724. 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 | undefined, forcedExtension: any): InternalTexture;
  8725. /**
  8726. * Creates a cube texture
  8727. * @param rootUrl defines the url where the files to load is located
  8728. * @param scene defines the current scene
  8729. * @param files defines the list of files to load (1 per face)
  8730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8731. * @param onLoad defines an optional callback raised when the texture is loaded
  8732. * @param onError defines an optional callback raised if there is an issue to load the texture
  8733. * @param format defines the format of the data
  8734. * @param forcedExtension defines the extension to use to pick the right loader
  8735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8738. * @returns the cube texture as an InternalTexture
  8739. */
  8740. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8741. /** @hidden */
  8742. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8743. /** @hidden */
  8744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8745. /** @hidden */
  8746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8747. /** @hidden */
  8748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8749. }
  8750. }
  8751. }
  8752. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8753. import { Nullable } from "babylonjs/types";
  8754. import { Scene } from "babylonjs/scene";
  8755. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8756. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8757. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8758. /**
  8759. * Class for creating a cube texture
  8760. */
  8761. export class CubeTexture extends BaseTexture {
  8762. private _delayedOnLoad;
  8763. /**
  8764. * The url of the texture
  8765. */
  8766. url: string;
  8767. /**
  8768. * Gets or sets the center of the bounding box associated with the cube texture.
  8769. * It must define where the camera used to render the texture was set
  8770. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8771. */
  8772. boundingBoxPosition: Vector3;
  8773. private _boundingBoxSize;
  8774. /**
  8775. * Gets or sets the size of the bounding box associated with the cube texture
  8776. * When defined, the cubemap will switch to local mode
  8777. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8778. * @example https://www.babylonjs-playground.com/#RNASML
  8779. */
  8780. /**
  8781. * Returns the bounding box size
  8782. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8783. */
  8784. boundingBoxSize: Vector3;
  8785. protected _rotationY: number;
  8786. /**
  8787. * Sets texture matrix rotation angle around Y axis in radians.
  8788. */
  8789. /**
  8790. * Gets texture matrix rotation angle around Y axis radians.
  8791. */
  8792. rotationY: number;
  8793. /**
  8794. * Are mip maps generated for this texture or not.
  8795. */
  8796. readonly noMipmap: boolean;
  8797. private _noMipmap;
  8798. private _files;
  8799. private _extensions;
  8800. private _textureMatrix;
  8801. private _format;
  8802. private _createPolynomials;
  8803. /** @hidden */
  8804. _prefiltered: boolean;
  8805. /**
  8806. * Creates a cube texture from an array of image urls
  8807. * @param files defines an array of image urls
  8808. * @param scene defines the hosting scene
  8809. * @param noMipmap specifies if mip maps are not used
  8810. * @returns a cube texture
  8811. */
  8812. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8813. /**
  8814. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8815. * @param url defines the url of the prefiltered texture
  8816. * @param scene defines the scene the texture is attached to
  8817. * @param forcedExtension defines the extension of the file if different from the url
  8818. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8819. * @return the prefiltered texture
  8820. */
  8821. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8822. /**
  8823. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8824. * as prefiltered data.
  8825. * @param rootUrl defines the url of the texture or the root name of the six images
  8826. * @param scene defines the scene the texture is attached to
  8827. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8828. * @param noMipmap defines if mipmaps should be created or not
  8829. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8830. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8831. * @param onError defines a callback triggered in case of error during load
  8832. * @param format defines the internal format to use for the texture once loaded
  8833. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8834. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8835. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8838. * @return the cube texture
  8839. */
  8840. 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);
  8841. /**
  8842. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8843. */
  8844. readonly isPrefiltered: boolean;
  8845. /**
  8846. * Get the current class name of the texture useful for serialization or dynamic coding.
  8847. * @returns "CubeTexture"
  8848. */
  8849. getClassName(): string;
  8850. /**
  8851. * Update the url (and optional buffer) of this texture if url was null during construction.
  8852. * @param url the url of the texture
  8853. * @param forcedExtension defines the extension to use
  8854. * @param onLoad callback called when the texture is loaded (defaults to null)
  8855. */
  8856. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8857. /**
  8858. * Delays loading of the cube texture
  8859. * @param forcedExtension defines the extension to use
  8860. */
  8861. delayLoad(forcedExtension?: string): void;
  8862. /**
  8863. * Returns the reflection texture matrix
  8864. * @returns the reflection texture matrix
  8865. */
  8866. getReflectionTextureMatrix(): Matrix;
  8867. /**
  8868. * Sets the reflection texture matrix
  8869. * @param value Reflection texture matrix
  8870. */
  8871. setReflectionTextureMatrix(value: Matrix): void;
  8872. /**
  8873. * Parses text to create a cube texture
  8874. * @param parsedTexture define the serialized text to read from
  8875. * @param scene defines the hosting scene
  8876. * @param rootUrl defines the root url of the cube texture
  8877. * @returns a cube texture
  8878. */
  8879. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8880. /**
  8881. * Makes a clone, or deep copy, of the cube texture
  8882. * @returns a new cube texture
  8883. */
  8884. clone(): CubeTexture;
  8885. }
  8886. }
  8887. declare module "babylonjs/Shaders/postprocess.vertex" {
  8888. /** @hidden */
  8889. export var postprocessVertexShader: {
  8890. name: string;
  8891. shader: string;
  8892. };
  8893. }
  8894. declare module "babylonjs/Cameras/targetCamera" {
  8895. import { Nullable } from "babylonjs/types";
  8896. import { Camera } from "babylonjs/Cameras/camera";
  8897. import { Scene } from "babylonjs/scene";
  8898. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8899. /**
  8900. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8901. * This is the base of the follow, arc rotate cameras and Free camera
  8902. * @see http://doc.babylonjs.com/features/cameras
  8903. */
  8904. export class TargetCamera extends Camera {
  8905. private static _RigCamTransformMatrix;
  8906. private static _TargetTransformMatrix;
  8907. private static _TargetFocalPoint;
  8908. /**
  8909. * Define the current direction the camera is moving to
  8910. */
  8911. cameraDirection: Vector3;
  8912. /**
  8913. * Define the current rotation the camera is rotating to
  8914. */
  8915. cameraRotation: Vector2;
  8916. /**
  8917. * When set, the up vector of the camera will be updated by the rotation of the camera
  8918. */
  8919. updateUpVectorFromRotation: boolean;
  8920. private _tmpQuaternion;
  8921. /**
  8922. * Define the current rotation of the camera
  8923. */
  8924. rotation: Vector3;
  8925. /**
  8926. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8927. */
  8928. rotationQuaternion: Quaternion;
  8929. /**
  8930. * Define the current speed of the camera
  8931. */
  8932. speed: number;
  8933. /**
  8934. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8935. * around all axis.
  8936. */
  8937. noRotationConstraint: boolean;
  8938. /**
  8939. * Define the current target of the camera as an object or a position.
  8940. */
  8941. lockedTarget: any;
  8942. /** @hidden */
  8943. _currentTarget: Vector3;
  8944. /** @hidden */
  8945. _initialFocalDistance: number;
  8946. /** @hidden */
  8947. _viewMatrix: Matrix;
  8948. /** @hidden */
  8949. _camMatrix: Matrix;
  8950. /** @hidden */
  8951. _cameraTransformMatrix: Matrix;
  8952. /** @hidden */
  8953. _cameraRotationMatrix: Matrix;
  8954. /** @hidden */
  8955. _referencePoint: Vector3;
  8956. /** @hidden */
  8957. _transformedReferencePoint: Vector3;
  8958. protected _globalCurrentTarget: Vector3;
  8959. protected _globalCurrentUpVector: Vector3;
  8960. /** @hidden */
  8961. _reset: () => void;
  8962. private _defaultUp;
  8963. /**
  8964. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8965. * This is the base of the follow, arc rotate cameras and Free camera
  8966. * @see http://doc.babylonjs.com/features/cameras
  8967. * @param name Defines the name of the camera in the scene
  8968. * @param position Defines the start position of the camera in the scene
  8969. * @param scene Defines the scene the camera belongs to
  8970. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8971. */
  8972. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8973. /**
  8974. * Gets the position in front of the camera at a given distance.
  8975. * @param distance The distance from the camera we want the position to be
  8976. * @returns the position
  8977. */
  8978. getFrontPosition(distance: number): Vector3;
  8979. /** @hidden */
  8980. _getLockedTargetPosition(): Nullable<Vector3>;
  8981. private _storedPosition;
  8982. private _storedRotation;
  8983. private _storedRotationQuaternion;
  8984. /**
  8985. * Store current camera state of the camera (fov, position, rotation, etc..)
  8986. * @returns the camera
  8987. */
  8988. storeState(): Camera;
  8989. /**
  8990. * Restored camera state. You must call storeState() first
  8991. * @returns whether it was successful or not
  8992. * @hidden
  8993. */
  8994. _restoreStateValues(): boolean;
  8995. /** @hidden */
  8996. _initCache(): void;
  8997. /** @hidden */
  8998. _updateCache(ignoreParentClass?: boolean): void;
  8999. /** @hidden */
  9000. _isSynchronizedViewMatrix(): boolean;
  9001. /** @hidden */
  9002. _computeLocalCameraSpeed(): number;
  9003. /**
  9004. * Defines the target the camera should look at.
  9005. * This will automatically adapt alpha beta and radius to fit within the new target.
  9006. * @param target Defines the new target as a Vector or a mesh
  9007. */
  9008. setTarget(target: Vector3): void;
  9009. /**
  9010. * Return the current target position of the camera. This value is expressed in local space.
  9011. * @returns the target position
  9012. */
  9013. getTarget(): Vector3;
  9014. /** @hidden */
  9015. _decideIfNeedsToMove(): boolean;
  9016. /** @hidden */
  9017. _updatePosition(): void;
  9018. /** @hidden */
  9019. _checkInputs(): void;
  9020. protected _updateCameraRotationMatrix(): void;
  9021. /**
  9022. * 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)
  9023. * @returns the current camera
  9024. */
  9025. private _rotateUpVectorWithCameraRotationMatrix;
  9026. private _cachedRotationZ;
  9027. private _cachedQuaternionRotationZ;
  9028. /** @hidden */
  9029. _getViewMatrix(): Matrix;
  9030. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9031. /**
  9032. * @hidden
  9033. */
  9034. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9035. /**
  9036. * @hidden
  9037. */
  9038. _updateRigCameras(): void;
  9039. private _getRigCamPositionAndTarget;
  9040. /**
  9041. * Gets the current object class name.
  9042. * @return the class name
  9043. */
  9044. getClassName(): string;
  9045. }
  9046. }
  9047. declare module "babylonjs/Cameras/cameraInputsManager" {
  9048. import { Nullable } from "babylonjs/types";
  9049. import { Camera } from "babylonjs/Cameras/camera";
  9050. /**
  9051. * @ignore
  9052. * This is a list of all the different input types that are available in the application.
  9053. * Fo instance: ArcRotateCameraGamepadInput...
  9054. */
  9055. export var CameraInputTypes: {};
  9056. /**
  9057. * This is the contract to implement in order to create a new input class.
  9058. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9059. */
  9060. export interface ICameraInput<TCamera extends Camera> {
  9061. /**
  9062. * Defines the camera the input is attached to.
  9063. */
  9064. camera: Nullable<TCamera>;
  9065. /**
  9066. * Gets the class name of the current intput.
  9067. * @returns the class name
  9068. */
  9069. getClassName(): string;
  9070. /**
  9071. * Get the friendly name associated with the input class.
  9072. * @returns the input friendly name
  9073. */
  9074. getSimpleName(): string;
  9075. /**
  9076. * Attach the input controls to a specific dom element to get the input from.
  9077. * @param element Defines the element the controls should be listened from
  9078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9079. */
  9080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9081. /**
  9082. * Detach the current controls from the specified dom element.
  9083. * @param element Defines the element to stop listening the inputs from
  9084. */
  9085. detachControl(element: Nullable<HTMLElement>): void;
  9086. /**
  9087. * Update the current camera state depending on the inputs that have been used this frame.
  9088. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9089. */
  9090. checkInputs?: () => void;
  9091. }
  9092. /**
  9093. * Represents a map of input types to input instance or input index to input instance.
  9094. */
  9095. export interface CameraInputsMap<TCamera extends Camera> {
  9096. /**
  9097. * Accessor to the input by input type.
  9098. */
  9099. [name: string]: ICameraInput<TCamera>;
  9100. /**
  9101. * Accessor to the input by input index.
  9102. */
  9103. [idx: number]: ICameraInput<TCamera>;
  9104. }
  9105. /**
  9106. * This represents the input manager used within a camera.
  9107. * It helps dealing with all the different kind of input attached to a camera.
  9108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9109. */
  9110. export class CameraInputsManager<TCamera extends Camera> {
  9111. /**
  9112. * Defines the list of inputs attahed to the camera.
  9113. */
  9114. attached: CameraInputsMap<TCamera>;
  9115. /**
  9116. * Defines the dom element the camera is collecting inputs from.
  9117. * This is null if the controls have not been attached.
  9118. */
  9119. attachedElement: Nullable<HTMLElement>;
  9120. /**
  9121. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9122. */
  9123. noPreventDefault: boolean;
  9124. /**
  9125. * Defined the camera the input manager belongs to.
  9126. */
  9127. camera: TCamera;
  9128. /**
  9129. * Update the current camera state depending on the inputs that have been used this frame.
  9130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9131. */
  9132. checkInputs: () => void;
  9133. /**
  9134. * Instantiate a new Camera Input Manager.
  9135. * @param camera Defines the camera the input manager blongs to
  9136. */
  9137. constructor(camera: TCamera);
  9138. /**
  9139. * Add an input method to a camera
  9140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9141. * @param input camera input method
  9142. */
  9143. add(input: ICameraInput<TCamera>): void;
  9144. /**
  9145. * Remove a specific input method from a camera
  9146. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9147. * @param inputToRemove camera input method
  9148. */
  9149. remove(inputToRemove: ICameraInput<TCamera>): void;
  9150. /**
  9151. * Remove a specific input type from a camera
  9152. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9153. * @param inputType the type of the input to remove
  9154. */
  9155. removeByType(inputType: string): void;
  9156. private _addCheckInputs;
  9157. /**
  9158. * Attach the input controls to the currently attached dom element to listen the events from.
  9159. * @param input Defines the input to attach
  9160. */
  9161. attachInput(input: ICameraInput<TCamera>): void;
  9162. /**
  9163. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9164. * @param element Defines the dom element to collect the events from
  9165. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9166. */
  9167. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9168. /**
  9169. * Detach the current manager inputs controls from a specific dom element.
  9170. * @param element Defines the dom element to collect the events from
  9171. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9172. */
  9173. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9174. /**
  9175. * Rebuild the dynamic inputCheck function from the current list of
  9176. * defined inputs in the manager.
  9177. */
  9178. rebuildInputCheck(): void;
  9179. /**
  9180. * Remove all attached input methods from a camera
  9181. */
  9182. clear(): void;
  9183. /**
  9184. * Serialize the current input manager attached to a camera.
  9185. * This ensures than once parsed,
  9186. * the input associated to the camera will be identical to the current ones
  9187. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9188. */
  9189. serialize(serializedCamera: any): void;
  9190. /**
  9191. * Parses an input manager serialized JSON to restore the previous list of inputs
  9192. * and states associated to a camera.
  9193. * @param parsedCamera Defines the JSON to parse
  9194. */
  9195. parse(parsedCamera: any): void;
  9196. }
  9197. }
  9198. declare module "babylonjs/Events/keyboardEvents" {
  9199. /**
  9200. * Gather the list of keyboard event types as constants.
  9201. */
  9202. export class KeyboardEventTypes {
  9203. /**
  9204. * The keydown event is fired when a key becomes active (pressed).
  9205. */
  9206. static readonly KEYDOWN: number;
  9207. /**
  9208. * The keyup event is fired when a key has been released.
  9209. */
  9210. static readonly KEYUP: number;
  9211. }
  9212. /**
  9213. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9214. */
  9215. export class KeyboardInfo {
  9216. /**
  9217. * Defines the type of event (KeyboardEventTypes)
  9218. */
  9219. type: number;
  9220. /**
  9221. * Defines the related dom event
  9222. */
  9223. event: KeyboardEvent;
  9224. /**
  9225. * Instantiates a new keyboard info.
  9226. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9227. * @param type Defines the type of event (KeyboardEventTypes)
  9228. * @param event Defines the related dom event
  9229. */
  9230. constructor(
  9231. /**
  9232. * Defines the type of event (KeyboardEventTypes)
  9233. */
  9234. type: number,
  9235. /**
  9236. * Defines the related dom event
  9237. */
  9238. event: KeyboardEvent);
  9239. }
  9240. /**
  9241. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9242. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9243. */
  9244. export class KeyboardInfoPre extends KeyboardInfo {
  9245. /**
  9246. * Defines the type of event (KeyboardEventTypes)
  9247. */
  9248. type: number;
  9249. /**
  9250. * Defines the related dom event
  9251. */
  9252. event: KeyboardEvent;
  9253. /**
  9254. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9255. */
  9256. skipOnPointerObservable: boolean;
  9257. /**
  9258. * Instantiates a new keyboard pre info.
  9259. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9260. * @param type Defines the type of event (KeyboardEventTypes)
  9261. * @param event Defines the related dom event
  9262. */
  9263. constructor(
  9264. /**
  9265. * Defines the type of event (KeyboardEventTypes)
  9266. */
  9267. type: number,
  9268. /**
  9269. * Defines the related dom event
  9270. */
  9271. event: KeyboardEvent);
  9272. }
  9273. }
  9274. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9275. import { Nullable } from "babylonjs/types";
  9276. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9277. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9278. /**
  9279. * Manage the keyboard inputs to control the movement of a free camera.
  9280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9281. */
  9282. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9283. /**
  9284. * Defines the camera the input is attached to.
  9285. */
  9286. camera: FreeCamera;
  9287. /**
  9288. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9289. */
  9290. keysUp: number[];
  9291. /**
  9292. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9293. */
  9294. keysDown: number[];
  9295. /**
  9296. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9297. */
  9298. keysLeft: number[];
  9299. /**
  9300. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9301. */
  9302. keysRight: number[];
  9303. private _keys;
  9304. private _onCanvasBlurObserver;
  9305. private _onKeyboardObserver;
  9306. private _engine;
  9307. private _scene;
  9308. /**
  9309. * Attach the input controls to a specific dom element to get the input from.
  9310. * @param element Defines the element the controls should be listened from
  9311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9312. */
  9313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9314. /**
  9315. * Detach the current controls from the specified dom element.
  9316. * @param element Defines the element to stop listening the inputs from
  9317. */
  9318. detachControl(element: Nullable<HTMLElement>): void;
  9319. /**
  9320. * Update the current camera state depending on the inputs that have been used this frame.
  9321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9322. */
  9323. checkInputs(): void;
  9324. /**
  9325. * Gets the class name of the current intput.
  9326. * @returns the class name
  9327. */
  9328. getClassName(): string;
  9329. /** @hidden */
  9330. _onLostFocus(): void;
  9331. /**
  9332. * Get the friendly name associated with the input class.
  9333. * @returns the input friendly name
  9334. */
  9335. getSimpleName(): string;
  9336. }
  9337. }
  9338. declare module "babylonjs/Lights/shadowLight" {
  9339. import { Camera } from "babylonjs/Cameras/camera";
  9340. import { Scene } from "babylonjs/scene";
  9341. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9343. import { Light } from "babylonjs/Lights/light";
  9344. /**
  9345. * Interface describing all the common properties and methods a shadow light needs to implement.
  9346. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9347. * as well as binding the different shadow properties to the effects.
  9348. */
  9349. export interface IShadowLight extends Light {
  9350. /**
  9351. * The light id in the scene (used in scene.findLighById for instance)
  9352. */
  9353. id: string;
  9354. /**
  9355. * The position the shdow will be casted from.
  9356. */
  9357. position: Vector3;
  9358. /**
  9359. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9360. */
  9361. direction: Vector3;
  9362. /**
  9363. * The transformed position. Position of the light in world space taking parenting in account.
  9364. */
  9365. transformedPosition: Vector3;
  9366. /**
  9367. * The transformed direction. Direction of the light in world space taking parenting in account.
  9368. */
  9369. transformedDirection: Vector3;
  9370. /**
  9371. * The friendly name of the light in the scene.
  9372. */
  9373. name: string;
  9374. /**
  9375. * Defines the shadow projection clipping minimum z value.
  9376. */
  9377. shadowMinZ: number;
  9378. /**
  9379. * Defines the shadow projection clipping maximum z value.
  9380. */
  9381. shadowMaxZ: number;
  9382. /**
  9383. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9384. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9385. */
  9386. computeTransformedInformation(): boolean;
  9387. /**
  9388. * Gets the scene the light belongs to.
  9389. * @returns The scene
  9390. */
  9391. getScene(): Scene;
  9392. /**
  9393. * Callback defining a custom Projection Matrix Builder.
  9394. * This can be used to override the default projection matrix computation.
  9395. */
  9396. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9397. /**
  9398. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9399. * @param matrix The materix to updated with the projection information
  9400. * @param viewMatrix The transform matrix of the light
  9401. * @param renderList The list of mesh to render in the map
  9402. * @returns The current light
  9403. */
  9404. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9405. /**
  9406. * Gets the current depth scale used in ESM.
  9407. * @returns The scale
  9408. */
  9409. getDepthScale(): number;
  9410. /**
  9411. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9412. * @returns true if a cube texture needs to be use
  9413. */
  9414. needCube(): boolean;
  9415. /**
  9416. * Detects if the projection matrix requires to be recomputed this frame.
  9417. * @returns true if it requires to be recomputed otherwise, false.
  9418. */
  9419. needProjectionMatrixCompute(): boolean;
  9420. /**
  9421. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9422. */
  9423. forceProjectionMatrixCompute(): void;
  9424. /**
  9425. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9426. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9427. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9428. */
  9429. getShadowDirection(faceIndex?: number): Vector3;
  9430. /**
  9431. * Gets the minZ used for shadow according to both the scene and the light.
  9432. * @param activeCamera The camera we are returning the min for
  9433. * @returns the depth min z
  9434. */
  9435. getDepthMinZ(activeCamera: Camera): number;
  9436. /**
  9437. * Gets the maxZ used for shadow according to both the scene and the light.
  9438. * @param activeCamera The camera we are returning the max for
  9439. * @returns the depth max z
  9440. */
  9441. getDepthMaxZ(activeCamera: Camera): number;
  9442. }
  9443. /**
  9444. * Base implementation IShadowLight
  9445. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9446. */
  9447. export abstract class ShadowLight extends Light implements IShadowLight {
  9448. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9449. protected _position: Vector3;
  9450. protected _setPosition(value: Vector3): void;
  9451. /**
  9452. * Sets the position the shadow will be casted from. Also use as the light position for both
  9453. * point and spot lights.
  9454. */
  9455. /**
  9456. * Sets the position the shadow will be casted from. Also use as the light position for both
  9457. * point and spot lights.
  9458. */
  9459. position: Vector3;
  9460. protected _direction: Vector3;
  9461. protected _setDirection(value: Vector3): void;
  9462. /**
  9463. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9464. * Also use as the light direction on spot and directional lights.
  9465. */
  9466. /**
  9467. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9468. * Also use as the light direction on spot and directional lights.
  9469. */
  9470. direction: Vector3;
  9471. private _shadowMinZ;
  9472. /**
  9473. * Gets the shadow projection clipping minimum z value.
  9474. */
  9475. /**
  9476. * Sets the shadow projection clipping minimum z value.
  9477. */
  9478. shadowMinZ: number;
  9479. private _shadowMaxZ;
  9480. /**
  9481. * Sets the shadow projection clipping maximum z value.
  9482. */
  9483. /**
  9484. * Gets the shadow projection clipping maximum z value.
  9485. */
  9486. shadowMaxZ: number;
  9487. /**
  9488. * Callback defining a custom Projection Matrix Builder.
  9489. * This can be used to override the default projection matrix computation.
  9490. */
  9491. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9492. /**
  9493. * The transformed position. Position of the light in world space taking parenting in account.
  9494. */
  9495. transformedPosition: Vector3;
  9496. /**
  9497. * The transformed direction. Direction of the light in world space taking parenting in account.
  9498. */
  9499. transformedDirection: Vector3;
  9500. private _needProjectionMatrixCompute;
  9501. /**
  9502. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9503. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9504. */
  9505. computeTransformedInformation(): boolean;
  9506. /**
  9507. * Return the depth scale used for the shadow map.
  9508. * @returns the depth scale.
  9509. */
  9510. getDepthScale(): number;
  9511. /**
  9512. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9513. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9514. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9515. */
  9516. getShadowDirection(faceIndex?: number): Vector3;
  9517. /**
  9518. * Returns the ShadowLight absolute position in the World.
  9519. * @returns the position vector in world space
  9520. */
  9521. getAbsolutePosition(): Vector3;
  9522. /**
  9523. * Sets the ShadowLight direction toward the passed target.
  9524. * @param target The point to target in local space
  9525. * @returns the updated ShadowLight direction
  9526. */
  9527. setDirectionToTarget(target: Vector3): Vector3;
  9528. /**
  9529. * Returns the light rotation in euler definition.
  9530. * @returns the x y z rotation in local space.
  9531. */
  9532. getRotation(): Vector3;
  9533. /**
  9534. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9535. * @returns true if a cube texture needs to be use
  9536. */
  9537. needCube(): boolean;
  9538. /**
  9539. * Detects if the projection matrix requires to be recomputed this frame.
  9540. * @returns true if it requires to be recomputed otherwise, false.
  9541. */
  9542. needProjectionMatrixCompute(): boolean;
  9543. /**
  9544. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9545. */
  9546. forceProjectionMatrixCompute(): void;
  9547. /** @hidden */
  9548. _initCache(): void;
  9549. /** @hidden */
  9550. _isSynchronized(): boolean;
  9551. /**
  9552. * Computes the world matrix of the node
  9553. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9554. * @returns the world matrix
  9555. */
  9556. computeWorldMatrix(force?: boolean): Matrix;
  9557. /**
  9558. * Gets the minZ used for shadow according to both the scene and the light.
  9559. * @param activeCamera The camera we are returning the min for
  9560. * @returns the depth min z
  9561. */
  9562. getDepthMinZ(activeCamera: Camera): number;
  9563. /**
  9564. * Gets the maxZ used for shadow according to both the scene and the light.
  9565. * @param activeCamera The camera we are returning the max for
  9566. * @returns the depth max z
  9567. */
  9568. getDepthMaxZ(activeCamera: Camera): number;
  9569. /**
  9570. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9571. * @param matrix The materix to updated with the projection information
  9572. * @param viewMatrix The transform matrix of the light
  9573. * @param renderList The list of mesh to render in the map
  9574. * @returns The current light
  9575. */
  9576. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9577. }
  9578. }
  9579. declare module "babylonjs/Materials/materialHelper" {
  9580. import { Nullable } from "babylonjs/types";
  9581. import { Scene } from "babylonjs/scene";
  9582. import { Engine } from "babylonjs/Engines/engine";
  9583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9584. import { Light } from "babylonjs/Lights/light";
  9585. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9586. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9588. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9589. /**
  9590. * "Static Class" containing the most commonly used helper while dealing with material for
  9591. * rendering purpose.
  9592. *
  9593. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9594. *
  9595. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9596. */
  9597. export class MaterialHelper {
  9598. /**
  9599. * Bind the current view position to an effect.
  9600. * @param effect The effect to be bound
  9601. * @param scene The scene the eyes position is used from
  9602. */
  9603. static BindEyePosition(effect: Effect, scene: Scene): void;
  9604. /**
  9605. * Helps preparing the defines values about the UVs in used in the effect.
  9606. * UVs are shared as much as we can accross channels in the shaders.
  9607. * @param texture The texture we are preparing the UVs for
  9608. * @param defines The defines to update
  9609. * @param key The channel key "diffuse", "specular"... used in the shader
  9610. */
  9611. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9612. /**
  9613. * Binds a texture matrix value to its corrsponding uniform
  9614. * @param texture The texture to bind the matrix for
  9615. * @param uniformBuffer The uniform buffer receivin the data
  9616. * @param key The channel key "diffuse", "specular"... used in the shader
  9617. */
  9618. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9619. /**
  9620. * Gets the current status of the fog (should it be enabled?)
  9621. * @param mesh defines the mesh to evaluate for fog support
  9622. * @param scene defines the hosting scene
  9623. * @returns true if fog must be enabled
  9624. */
  9625. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9626. /**
  9627. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9628. * @param mesh defines the current mesh
  9629. * @param scene defines the current scene
  9630. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9631. * @param pointsCloud defines if point cloud rendering has to be turned on
  9632. * @param fogEnabled defines if fog has to be turned on
  9633. * @param alphaTest defines if alpha testing has to be turned on
  9634. * @param defines defines the current list of defines
  9635. */
  9636. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9637. /**
  9638. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9639. * @param scene defines the current scene
  9640. * @param engine defines the current engine
  9641. * @param defines specifies the list of active defines
  9642. * @param useInstances defines if instances have to be turned on
  9643. * @param useClipPlane defines if clip plane have to be turned on
  9644. */
  9645. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9646. /**
  9647. * Prepares the defines for bones
  9648. * @param mesh The mesh containing the geometry data we will draw
  9649. * @param defines The defines to update
  9650. */
  9651. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9652. /**
  9653. * Prepares the defines for morph targets
  9654. * @param mesh The mesh containing the geometry data we will draw
  9655. * @param defines The defines to update
  9656. */
  9657. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9658. /**
  9659. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9660. * @param mesh The mesh containing the geometry data we will draw
  9661. * @param defines The defines to update
  9662. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9663. * @param useBones Precise whether bones should be used or not (override mesh info)
  9664. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9665. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9666. * @returns false if defines are considered not dirty and have not been checked
  9667. */
  9668. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9669. /**
  9670. * Prepares the defines related to multiview
  9671. * @param scene The scene we are intending to draw
  9672. * @param defines The defines to update
  9673. */
  9674. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9675. /**
  9676. * Prepares the defines related to the light information passed in parameter
  9677. * @param scene The scene we are intending to draw
  9678. * @param mesh The mesh the effect is compiling for
  9679. * @param defines The defines to update
  9680. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9681. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9682. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9683. * @returns true if normals will be required for the rest of the effect
  9684. */
  9685. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9686. /**
  9687. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9688. * that won t be acctive due to defines being turned off.
  9689. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9690. * @param samplersList The samplers list
  9691. * @param defines The defines helping in the list generation
  9692. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9693. */
  9694. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9695. /**
  9696. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9697. * @param defines The defines to update while falling back
  9698. * @param fallbacks The authorized effect fallbacks
  9699. * @param maxSimultaneousLights The maximum number of lights allowed
  9700. * @param rank the current rank of the Effect
  9701. * @returns The newly affected rank
  9702. */
  9703. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9704. /**
  9705. * Prepares the list of attributes required for morph targets according to the effect defines.
  9706. * @param attribs The current list of supported attribs
  9707. * @param mesh The mesh to prepare the morph targets attributes for
  9708. * @param defines The current Defines of the effect
  9709. */
  9710. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9711. /**
  9712. * Prepares the list of attributes required for bones according to the effect defines.
  9713. * @param attribs The current list of supported attribs
  9714. * @param mesh The mesh to prepare the bones attributes for
  9715. * @param defines The current Defines of the effect
  9716. * @param fallbacks The current efffect fallback strategy
  9717. */
  9718. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9719. /**
  9720. * Check and prepare the list of attributes required for instances according to the effect defines.
  9721. * @param attribs The current list of supported attribs
  9722. * @param defines The current MaterialDefines of the effect
  9723. */
  9724. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9725. /**
  9726. * Add the list of attributes required for instances to the attribs array.
  9727. * @param attribs The current list of supported attribs
  9728. */
  9729. static PushAttributesForInstances(attribs: string[]): void;
  9730. /**
  9731. * Binds the light shadow information to the effect for the given mesh.
  9732. * @param light The light containing the generator
  9733. * @param scene The scene the lights belongs to
  9734. * @param mesh The mesh we are binding the information to render
  9735. * @param lightIndex The light index in the effect used to render the mesh
  9736. * @param effect The effect we are binding the data to
  9737. */
  9738. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9739. /**
  9740. * Binds the light information to the effect.
  9741. * @param light The light containing the generator
  9742. * @param effect The effect we are binding the data to
  9743. * @param lightIndex The light index in the effect used to render
  9744. */
  9745. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9746. /**
  9747. * Binds the lights information from the scene to the effect for the given mesh.
  9748. * @param scene The scene the lights belongs to
  9749. * @param mesh The mesh we are binding the information to render
  9750. * @param effect The effect we are binding the data to
  9751. * @param defines The generated defines for the effect
  9752. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9753. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9754. */
  9755. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9756. private static _tempFogColor;
  9757. /**
  9758. * Binds the fog information from the scene to the effect for the given mesh.
  9759. * @param scene The scene the lights belongs to
  9760. * @param mesh The mesh we are binding the information to render
  9761. * @param effect The effect we are binding the data to
  9762. * @param linearSpace Defines if the fog effect is applied in linear space
  9763. */
  9764. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9765. /**
  9766. * Binds the bones information from the mesh to the effect.
  9767. * @param mesh The mesh we are binding the information to render
  9768. * @param effect The effect we are binding the data to
  9769. */
  9770. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9771. /**
  9772. * Binds the morph targets information from the mesh to the effect.
  9773. * @param abstractMesh The mesh we are binding the information to render
  9774. * @param effect The effect we are binding the data to
  9775. */
  9776. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9777. /**
  9778. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9779. * @param defines The generated defines used in the effect
  9780. * @param effect The effect we are binding the data to
  9781. * @param scene The scene we are willing to render with logarithmic scale for
  9782. */
  9783. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9784. /**
  9785. * Binds the clip plane information from the scene to the effect.
  9786. * @param scene The scene the clip plane information are extracted from
  9787. * @param effect The effect we are binding the data to
  9788. */
  9789. static BindClipPlane(effect: Effect, scene: Scene): void;
  9790. }
  9791. }
  9792. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9793. /** @hidden */
  9794. export var kernelBlurVaryingDeclaration: {
  9795. name: string;
  9796. shader: string;
  9797. };
  9798. }
  9799. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9800. /** @hidden */
  9801. export var kernelBlurFragment: {
  9802. name: string;
  9803. shader: string;
  9804. };
  9805. }
  9806. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9807. /** @hidden */
  9808. export var kernelBlurFragment2: {
  9809. name: string;
  9810. shader: string;
  9811. };
  9812. }
  9813. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9814. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9815. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9816. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9817. /** @hidden */
  9818. export var kernelBlurPixelShader: {
  9819. name: string;
  9820. shader: string;
  9821. };
  9822. }
  9823. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9824. /** @hidden */
  9825. export var kernelBlurVertex: {
  9826. name: string;
  9827. shader: string;
  9828. };
  9829. }
  9830. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9831. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9832. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9833. /** @hidden */
  9834. export var kernelBlurVertexShader: {
  9835. name: string;
  9836. shader: string;
  9837. };
  9838. }
  9839. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9840. import { Vector2 } from "babylonjs/Maths/math";
  9841. import { Nullable } from "babylonjs/types";
  9842. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9843. import { Camera } from "babylonjs/Cameras/camera";
  9844. import { Effect } from "babylonjs/Materials/effect";
  9845. import { Engine } from "babylonjs/Engines/engine";
  9846. import "babylonjs/Shaders/kernelBlur.fragment";
  9847. import "babylonjs/Shaders/kernelBlur.vertex";
  9848. /**
  9849. * The Blur Post Process which blurs an image based on a kernel and direction.
  9850. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9851. */
  9852. export class BlurPostProcess extends PostProcess {
  9853. /** The direction in which to blur the image. */
  9854. direction: Vector2;
  9855. private blockCompilation;
  9856. protected _kernel: number;
  9857. protected _idealKernel: number;
  9858. protected _packedFloat: boolean;
  9859. private _staticDefines;
  9860. /**
  9861. * Sets the length in pixels of the blur sample region
  9862. */
  9863. /**
  9864. * Gets the length in pixels of the blur sample region
  9865. */
  9866. kernel: number;
  9867. /**
  9868. * Sets wether or not the blur needs to unpack/repack floats
  9869. */
  9870. /**
  9871. * Gets wether or not the blur is unpacking/repacking floats
  9872. */
  9873. packedFloat: boolean;
  9874. /**
  9875. * Creates a new instance BlurPostProcess
  9876. * @param name The name of the effect.
  9877. * @param direction The direction in which to blur the image.
  9878. * @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.
  9879. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9880. * @param camera The camera to apply the render pass to.
  9881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9882. * @param engine The engine which the post process will be applied. (default: current engine)
  9883. * @param reusable If the post process can be reused on the same frame. (default: false)
  9884. * @param textureType Type of textures used when performing the post process. (default: 0)
  9885. * @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)
  9886. */
  9887. constructor(name: string,
  9888. /** The direction in which to blur the image. */
  9889. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9890. /**
  9891. * Updates the effect with the current post process compile time values and recompiles the shader.
  9892. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9893. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9894. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9895. * @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
  9896. * @param onCompiled Called when the shader has been compiled.
  9897. * @param onError Called if there is an error when compiling a shader.
  9898. */
  9899. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9900. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9901. /**
  9902. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9903. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9904. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9905. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9906. * The gaps between physical kernels are compensated for in the weighting of the samples
  9907. * @param idealKernel Ideal blur kernel.
  9908. * @return Nearest best kernel.
  9909. */
  9910. protected _nearestBestKernel(idealKernel: number): number;
  9911. /**
  9912. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9913. * @param x The point on the Gaussian distribution to sample.
  9914. * @return the value of the Gaussian function at x.
  9915. */
  9916. protected _gaussianWeight(x: number): number;
  9917. /**
  9918. * Generates a string that can be used as a floating point number in GLSL.
  9919. * @param x Value to print.
  9920. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9921. * @return GLSL float string.
  9922. */
  9923. protected _glslFloat(x: number, decimalFigures?: number): string;
  9924. }
  9925. }
  9926. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9927. /** @hidden */
  9928. export var shadowMapPixelShader: {
  9929. name: string;
  9930. shader: string;
  9931. };
  9932. }
  9933. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9934. /** @hidden */
  9935. export var bonesDeclaration: {
  9936. name: string;
  9937. shader: string;
  9938. };
  9939. }
  9940. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9941. /** @hidden */
  9942. export var morphTargetsVertexGlobalDeclaration: {
  9943. name: string;
  9944. shader: string;
  9945. };
  9946. }
  9947. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9948. /** @hidden */
  9949. export var morphTargetsVertexDeclaration: {
  9950. name: string;
  9951. shader: string;
  9952. };
  9953. }
  9954. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9955. /** @hidden */
  9956. export var instancesDeclaration: {
  9957. name: string;
  9958. shader: string;
  9959. };
  9960. }
  9961. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9962. /** @hidden */
  9963. export var helperFunctions: {
  9964. name: string;
  9965. shader: string;
  9966. };
  9967. }
  9968. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9969. /** @hidden */
  9970. export var morphTargetsVertex: {
  9971. name: string;
  9972. shader: string;
  9973. };
  9974. }
  9975. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9976. /** @hidden */
  9977. export var instancesVertex: {
  9978. name: string;
  9979. shader: string;
  9980. };
  9981. }
  9982. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9983. /** @hidden */
  9984. export var bonesVertex: {
  9985. name: string;
  9986. shader: string;
  9987. };
  9988. }
  9989. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9990. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9993. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9994. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9995. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9996. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9997. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9998. /** @hidden */
  9999. export var shadowMapVertexShader: {
  10000. name: string;
  10001. shader: string;
  10002. };
  10003. }
  10004. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  10005. /** @hidden */
  10006. export var depthBoxBlurPixelShader: {
  10007. name: string;
  10008. shader: string;
  10009. };
  10010. }
  10011. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  10012. import { Nullable } from "babylonjs/types";
  10013. import { Scene } from "babylonjs/scene";
  10014. import { Matrix } from "babylonjs/Maths/math";
  10015. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10017. import { Mesh } from "babylonjs/Meshes/mesh";
  10018. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  10019. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  10020. import { Effect } from "babylonjs/Materials/effect";
  10021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10022. import "babylonjs/Shaders/shadowMap.fragment";
  10023. import "babylonjs/Shaders/shadowMap.vertex";
  10024. import "babylonjs/Shaders/depthBoxBlur.fragment";
  10025. import { Observable } from "babylonjs/Misc/observable";
  10026. /**
  10027. * Defines the options associated with the creation of a custom shader for a shadow generator.
  10028. */
  10029. export interface ICustomShaderOptions {
  10030. /**
  10031. * Gets or sets the custom shader name to use
  10032. */
  10033. shaderName: string;
  10034. /**
  10035. * The list of attribute names used in the shader
  10036. */
  10037. attributes?: string[];
  10038. /**
  10039. * The list of unifrom names used in the shader
  10040. */
  10041. uniforms?: string[];
  10042. /**
  10043. * The list of sampler names used in the shader
  10044. */
  10045. samplers?: string[];
  10046. /**
  10047. * The list of defines used in the shader
  10048. */
  10049. defines?: string[];
  10050. }
  10051. /**
  10052. * Interface to implement to create a shadow generator compatible with BJS.
  10053. */
  10054. export interface IShadowGenerator {
  10055. /**
  10056. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10057. * @returns The render target texture if present otherwise, null
  10058. */
  10059. getShadowMap(): Nullable<RenderTargetTexture>;
  10060. /**
  10061. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10062. * @returns The render target texture if the shadow map is present otherwise, null
  10063. */
  10064. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10065. /**
  10066. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10067. * @param subMesh The submesh we want to render in the shadow map
  10068. * @param useInstances Defines wether will draw in the map using instances
  10069. * @returns true if ready otherwise, false
  10070. */
  10071. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10072. /**
  10073. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10074. * @param defines Defines of the material we want to update
  10075. * @param lightIndex Index of the light in the enabled light list of the material
  10076. */
  10077. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10078. /**
  10079. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10080. * defined in the generator but impacting the effect).
  10081. * It implies the unifroms available on the materials are the standard BJS ones.
  10082. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10083. * @param effect The effect we are binfing the information for
  10084. */
  10085. bindShadowLight(lightIndex: string, effect: Effect): void;
  10086. /**
  10087. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10088. * (eq to shadow prjection matrix * light transform matrix)
  10089. * @returns The transform matrix used to create the shadow map
  10090. */
  10091. getTransformMatrix(): Matrix;
  10092. /**
  10093. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10094. * Cube and 2D textures for instance.
  10095. */
  10096. recreateShadowMap(): void;
  10097. /**
  10098. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10099. * @param onCompiled Callback triggered at the and of the effects compilation
  10100. * @param options Sets of optional options forcing the compilation with different modes
  10101. */
  10102. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10103. useInstances: boolean;
  10104. }>): void;
  10105. /**
  10106. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10107. * @param options Sets of optional options forcing the compilation with different modes
  10108. * @returns A promise that resolves when the compilation completes
  10109. */
  10110. forceCompilationAsync(options?: Partial<{
  10111. useInstances: boolean;
  10112. }>): Promise<void>;
  10113. /**
  10114. * Serializes the shadow generator setup to a json object.
  10115. * @returns The serialized JSON object
  10116. */
  10117. serialize(): any;
  10118. /**
  10119. * Disposes the Shadow map and related Textures and effects.
  10120. */
  10121. dispose(): void;
  10122. }
  10123. /**
  10124. * Default implementation IShadowGenerator.
  10125. * This is the main object responsible of generating shadows in the framework.
  10126. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10127. */
  10128. export class ShadowGenerator implements IShadowGenerator {
  10129. /**
  10130. * Shadow generator mode None: no filtering applied.
  10131. */
  10132. static readonly FILTER_NONE: number;
  10133. /**
  10134. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10135. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10136. */
  10137. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10138. /**
  10139. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10140. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10141. */
  10142. static readonly FILTER_POISSONSAMPLING: number;
  10143. /**
  10144. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10145. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10146. */
  10147. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10148. /**
  10149. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10150. * edge artifacts on steep falloff.
  10151. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10152. */
  10153. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10154. /**
  10155. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10156. * edge artifacts on steep falloff.
  10157. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10158. */
  10159. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10160. /**
  10161. * Shadow generator mode PCF: Percentage Closer Filtering
  10162. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10163. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10164. */
  10165. static readonly FILTER_PCF: number;
  10166. /**
  10167. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10168. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10169. * Contact Hardening
  10170. */
  10171. static readonly FILTER_PCSS: number;
  10172. /**
  10173. * Reserved for PCF and PCSS
  10174. * Highest Quality.
  10175. *
  10176. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10177. *
  10178. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10179. */
  10180. static readonly QUALITY_HIGH: number;
  10181. /**
  10182. * Reserved for PCF and PCSS
  10183. * Good tradeoff for quality/perf cross devices
  10184. *
  10185. * Execute PCF on a 3*3 kernel.
  10186. *
  10187. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10188. */
  10189. static readonly QUALITY_MEDIUM: number;
  10190. /**
  10191. * Reserved for PCF and PCSS
  10192. * The lowest quality but the fastest.
  10193. *
  10194. * Execute PCF on a 1*1 kernel.
  10195. *
  10196. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10197. */
  10198. static readonly QUALITY_LOW: number;
  10199. /** Gets or sets the custom shader name to use */
  10200. customShaderOptions: ICustomShaderOptions;
  10201. /**
  10202. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10203. */
  10204. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10205. /**
  10206. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10207. */
  10208. onAfterShadowMapRenderObservable: Observable<Effect>;
  10209. /**
  10210. * Observable triggered before a mesh is rendered in the shadow map.
  10211. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10212. */
  10213. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10214. /**
  10215. * Observable triggered after a mesh is rendered in the shadow map.
  10216. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10217. */
  10218. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10219. private _bias;
  10220. /**
  10221. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10222. */
  10223. /**
  10224. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10225. */
  10226. bias: number;
  10227. private _normalBias;
  10228. /**
  10229. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10230. */
  10231. /**
  10232. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10233. */
  10234. normalBias: number;
  10235. private _blurBoxOffset;
  10236. /**
  10237. * Gets the blur box offset: offset applied during the blur pass.
  10238. * Only useful if useKernelBlur = false
  10239. */
  10240. /**
  10241. * Sets the blur box offset: offset applied during the blur pass.
  10242. * Only useful if useKernelBlur = false
  10243. */
  10244. blurBoxOffset: number;
  10245. private _blurScale;
  10246. /**
  10247. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10248. * 2 means half of the size.
  10249. */
  10250. /**
  10251. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10252. * 2 means half of the size.
  10253. */
  10254. blurScale: number;
  10255. private _blurKernel;
  10256. /**
  10257. * Gets the blur kernel: kernel size of the blur pass.
  10258. * Only useful if useKernelBlur = true
  10259. */
  10260. /**
  10261. * Sets the blur kernel: kernel size of the blur pass.
  10262. * Only useful if useKernelBlur = true
  10263. */
  10264. blurKernel: number;
  10265. private _useKernelBlur;
  10266. /**
  10267. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10268. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10269. */
  10270. /**
  10271. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10272. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10273. */
  10274. useKernelBlur: boolean;
  10275. private _depthScale;
  10276. /**
  10277. * Gets the depth scale used in ESM mode.
  10278. */
  10279. /**
  10280. * Sets the depth scale used in ESM mode.
  10281. * This can override the scale stored on the light.
  10282. */
  10283. depthScale: number;
  10284. private _filter;
  10285. /**
  10286. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10287. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10288. */
  10289. /**
  10290. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10291. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10292. */
  10293. filter: number;
  10294. /**
  10295. * Gets if the current filter is set to Poisson Sampling.
  10296. */
  10297. /**
  10298. * Sets the current filter to Poisson Sampling.
  10299. */
  10300. usePoissonSampling: boolean;
  10301. /**
  10302. * Gets if the current filter is set to ESM.
  10303. */
  10304. /**
  10305. * Sets the current filter is to ESM.
  10306. */
  10307. useExponentialShadowMap: boolean;
  10308. /**
  10309. * Gets if the current filter is set to filtered ESM.
  10310. */
  10311. /**
  10312. * Gets if the current filter is set to filtered ESM.
  10313. */
  10314. useBlurExponentialShadowMap: boolean;
  10315. /**
  10316. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10317. * exponential to prevent steep falloff artifacts).
  10318. */
  10319. /**
  10320. * Sets the current filter to "close ESM" (using the inverse of the
  10321. * exponential to prevent steep falloff artifacts).
  10322. */
  10323. useCloseExponentialShadowMap: boolean;
  10324. /**
  10325. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10326. * exponential to prevent steep falloff artifacts).
  10327. */
  10328. /**
  10329. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10330. * exponential to prevent steep falloff artifacts).
  10331. */
  10332. useBlurCloseExponentialShadowMap: boolean;
  10333. /**
  10334. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10335. */
  10336. /**
  10337. * Sets the current filter to "PCF" (percentage closer filtering).
  10338. */
  10339. usePercentageCloserFiltering: boolean;
  10340. private _filteringQuality;
  10341. /**
  10342. * Gets the PCF or PCSS Quality.
  10343. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10344. */
  10345. /**
  10346. * Sets the PCF or PCSS Quality.
  10347. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10348. */
  10349. filteringQuality: number;
  10350. /**
  10351. * Gets if the current filter is set to "PCSS" (contact hardening).
  10352. */
  10353. /**
  10354. * Sets the current filter to "PCSS" (contact hardening).
  10355. */
  10356. useContactHardeningShadow: boolean;
  10357. private _contactHardeningLightSizeUVRatio;
  10358. /**
  10359. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10360. * Using a ratio helps keeping shape stability independently of the map size.
  10361. *
  10362. * It does not account for the light projection as it was having too much
  10363. * instability during the light setup or during light position changes.
  10364. *
  10365. * Only valid if useContactHardeningShadow is true.
  10366. */
  10367. /**
  10368. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10369. * Using a ratio helps keeping shape stability independently of the map size.
  10370. *
  10371. * It does not account for the light projection as it was having too much
  10372. * instability during the light setup or during light position changes.
  10373. *
  10374. * Only valid if useContactHardeningShadow is true.
  10375. */
  10376. contactHardeningLightSizeUVRatio: number;
  10377. private _darkness;
  10378. /** Gets or sets the actual darkness of a shadow */
  10379. darkness: number;
  10380. /**
  10381. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10382. * 0 means strongest and 1 would means no shadow.
  10383. * @returns the darkness.
  10384. */
  10385. getDarkness(): number;
  10386. /**
  10387. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10388. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10389. * @returns the shadow generator allowing fluent coding.
  10390. */
  10391. setDarkness(darkness: number): ShadowGenerator;
  10392. private _transparencyShadow;
  10393. /** Gets or sets the ability to have transparent shadow */
  10394. transparencyShadow: boolean;
  10395. /**
  10396. * Sets the ability to have transparent shadow (boolean).
  10397. * @param transparent True if transparent else False
  10398. * @returns the shadow generator allowing fluent coding
  10399. */
  10400. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10401. private _shadowMap;
  10402. private _shadowMap2;
  10403. /**
  10404. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10405. * @returns The render target texture if present otherwise, null
  10406. */
  10407. getShadowMap(): Nullable<RenderTargetTexture>;
  10408. /**
  10409. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10410. * @returns The render target texture if the shadow map is present otherwise, null
  10411. */
  10412. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10413. /**
  10414. * Gets the class name of that object
  10415. * @returns "ShadowGenerator"
  10416. */
  10417. getClassName(): string;
  10418. /**
  10419. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10420. * @param mesh Mesh to add
  10421. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10422. * @returns the Shadow Generator itself
  10423. */
  10424. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10425. /**
  10426. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10427. * @param mesh Mesh to remove
  10428. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10429. * @returns the Shadow Generator itself
  10430. */
  10431. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10432. /**
  10433. * Controls the extent to which the shadows fade out at the edge of the frustum
  10434. * Used only by directionals and spots
  10435. */
  10436. frustumEdgeFalloff: number;
  10437. private _light;
  10438. /**
  10439. * Returns the associated light object.
  10440. * @returns the light generating the shadow
  10441. */
  10442. getLight(): IShadowLight;
  10443. /**
  10444. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10445. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10446. * It might on the other hand introduce peter panning.
  10447. */
  10448. forceBackFacesOnly: boolean;
  10449. private _scene;
  10450. private _lightDirection;
  10451. private _effect;
  10452. private _viewMatrix;
  10453. private _projectionMatrix;
  10454. private _transformMatrix;
  10455. private _cachedPosition;
  10456. private _cachedDirection;
  10457. private _cachedDefines;
  10458. private _currentRenderID;
  10459. private _boxBlurPostprocess;
  10460. private _kernelBlurXPostprocess;
  10461. private _kernelBlurYPostprocess;
  10462. private _blurPostProcesses;
  10463. private _mapSize;
  10464. private _currentFaceIndex;
  10465. private _currentFaceIndexCache;
  10466. private _textureType;
  10467. private _defaultTextureMatrix;
  10468. /** @hidden */
  10469. static _SceneComponentInitialization: (scene: Scene) => void;
  10470. /**
  10471. * Creates a ShadowGenerator object.
  10472. * A ShadowGenerator is the required tool to use the shadows.
  10473. * Each light casting shadows needs to use its own ShadowGenerator.
  10474. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10475. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10476. * @param light The light object generating the shadows.
  10477. * @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.
  10478. */
  10479. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10480. private _initializeGenerator;
  10481. private _initializeShadowMap;
  10482. private _initializeBlurRTTAndPostProcesses;
  10483. private _renderForShadowMap;
  10484. private _renderSubMeshForShadowMap;
  10485. private _applyFilterValues;
  10486. /**
  10487. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10488. * @param onCompiled Callback triggered at the and of the effects compilation
  10489. * @param options Sets of optional options forcing the compilation with different modes
  10490. */
  10491. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10492. useInstances: boolean;
  10493. }>): void;
  10494. /**
  10495. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10496. * @param options Sets of optional options forcing the compilation with different modes
  10497. * @returns A promise that resolves when the compilation completes
  10498. */
  10499. forceCompilationAsync(options?: Partial<{
  10500. useInstances: boolean;
  10501. }>): Promise<void>;
  10502. /**
  10503. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10504. * @param subMesh The submesh we want to render in the shadow map
  10505. * @param useInstances Defines wether will draw in the map using instances
  10506. * @returns true if ready otherwise, false
  10507. */
  10508. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10509. /**
  10510. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10511. * @param defines Defines of the material we want to update
  10512. * @param lightIndex Index of the light in the enabled light list of the material
  10513. */
  10514. prepareDefines(defines: any, lightIndex: number): void;
  10515. /**
  10516. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10517. * defined in the generator but impacting the effect).
  10518. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10519. * @param effect The effect we are binfing the information for
  10520. */
  10521. bindShadowLight(lightIndex: string, effect: Effect): void;
  10522. /**
  10523. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10524. * (eq to shadow prjection matrix * light transform matrix)
  10525. * @returns The transform matrix used to create the shadow map
  10526. */
  10527. getTransformMatrix(): Matrix;
  10528. /**
  10529. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10530. * Cube and 2D textures for instance.
  10531. */
  10532. recreateShadowMap(): void;
  10533. private _disposeBlurPostProcesses;
  10534. private _disposeRTTandPostProcesses;
  10535. /**
  10536. * Disposes the ShadowGenerator.
  10537. * Returns nothing.
  10538. */
  10539. dispose(): void;
  10540. /**
  10541. * Serializes the shadow generator setup to a json object.
  10542. * @returns The serialized JSON object
  10543. */
  10544. serialize(): any;
  10545. /**
  10546. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10547. * @param parsedShadowGenerator The JSON object to parse
  10548. * @param scene The scene to create the shadow map for
  10549. * @returns The parsed shadow generator
  10550. */
  10551. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10552. }
  10553. }
  10554. declare module "babylonjs/Lights/light" {
  10555. import { Nullable } from "babylonjs/types";
  10556. import { Scene } from "babylonjs/scene";
  10557. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10558. import { Node } from "babylonjs/node";
  10559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10560. import { Effect } from "babylonjs/Materials/effect";
  10561. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10562. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10563. /**
  10564. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10565. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10566. * 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.
  10567. */
  10568. export abstract class Light extends Node {
  10569. /**
  10570. * Falloff Default: light is falling off following the material specification:
  10571. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10572. */
  10573. static readonly FALLOFF_DEFAULT: number;
  10574. /**
  10575. * Falloff Physical: light is falling off following the inverse squared distance law.
  10576. */
  10577. static readonly FALLOFF_PHYSICAL: number;
  10578. /**
  10579. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10580. * to enhance interoperability with other engines.
  10581. */
  10582. static readonly FALLOFF_GLTF: number;
  10583. /**
  10584. * Falloff Standard: light is falling off like in the standard material
  10585. * to enhance interoperability with other materials.
  10586. */
  10587. static readonly FALLOFF_STANDARD: number;
  10588. /**
  10589. * If every light affecting the material is in this lightmapMode,
  10590. * material.lightmapTexture adds or multiplies
  10591. * (depends on material.useLightmapAsShadowmap)
  10592. * after every other light calculations.
  10593. */
  10594. static readonly LIGHTMAP_DEFAULT: number;
  10595. /**
  10596. * material.lightmapTexture as only diffuse lighting from this light
  10597. * adds only specular lighting from this light
  10598. * adds dynamic shadows
  10599. */
  10600. static readonly LIGHTMAP_SPECULAR: number;
  10601. /**
  10602. * material.lightmapTexture as only lighting
  10603. * no light calculation from this light
  10604. * only adds dynamic shadows from this light
  10605. */
  10606. static readonly LIGHTMAP_SHADOWSONLY: number;
  10607. /**
  10608. * Each light type uses the default quantity according to its type:
  10609. * point/spot lights use luminous intensity
  10610. * directional lights use illuminance
  10611. */
  10612. static readonly INTENSITYMODE_AUTOMATIC: number;
  10613. /**
  10614. * lumen (lm)
  10615. */
  10616. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10617. /**
  10618. * candela (lm/sr)
  10619. */
  10620. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10621. /**
  10622. * lux (lm/m^2)
  10623. */
  10624. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10625. /**
  10626. * nit (cd/m^2)
  10627. */
  10628. static readonly INTENSITYMODE_LUMINANCE: number;
  10629. /**
  10630. * Light type const id of the point light.
  10631. */
  10632. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10633. /**
  10634. * Light type const id of the directional light.
  10635. */
  10636. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10637. /**
  10638. * Light type const id of the spot light.
  10639. */
  10640. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10641. /**
  10642. * Light type const id of the hemispheric light.
  10643. */
  10644. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10645. /**
  10646. * Diffuse gives the basic color to an object.
  10647. */
  10648. diffuse: Color3;
  10649. /**
  10650. * Specular produces a highlight color on an object.
  10651. * Note: This is note affecting PBR materials.
  10652. */
  10653. specular: Color3;
  10654. /**
  10655. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10656. * falling off base on range or angle.
  10657. * This can be set to any values in Light.FALLOFF_x.
  10658. *
  10659. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10660. * other types of materials.
  10661. */
  10662. falloffType: number;
  10663. /**
  10664. * Strength of the light.
  10665. * Note: By default it is define in the framework own unit.
  10666. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10667. */
  10668. intensity: number;
  10669. private _range;
  10670. protected _inverseSquaredRange: number;
  10671. /**
  10672. * Defines how far from the source the light is impacting in scene units.
  10673. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10674. */
  10675. /**
  10676. * Defines how far from the source the light is impacting in scene units.
  10677. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10678. */
  10679. range: number;
  10680. /**
  10681. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10682. * of light.
  10683. */
  10684. private _photometricScale;
  10685. private _intensityMode;
  10686. /**
  10687. * Gets the photometric scale used to interpret the intensity.
  10688. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10689. */
  10690. /**
  10691. * Sets the photometric scale used to interpret the intensity.
  10692. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10693. */
  10694. intensityMode: number;
  10695. private _radius;
  10696. /**
  10697. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10698. */
  10699. /**
  10700. * sets the light radius used by PBR Materials to simulate soft area lights.
  10701. */
  10702. radius: number;
  10703. private _renderPriority;
  10704. /**
  10705. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10706. * exceeding the number allowed of the materials.
  10707. */
  10708. renderPriority: number;
  10709. private _shadowEnabled;
  10710. /**
  10711. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10712. * the current shadow generator.
  10713. */
  10714. /**
  10715. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10716. * the current shadow generator.
  10717. */
  10718. shadowEnabled: boolean;
  10719. private _includedOnlyMeshes;
  10720. /**
  10721. * Gets the only meshes impacted by this light.
  10722. */
  10723. /**
  10724. * Sets the only meshes impacted by this light.
  10725. */
  10726. includedOnlyMeshes: AbstractMesh[];
  10727. private _excludedMeshes;
  10728. /**
  10729. * Gets the meshes not impacted by this light.
  10730. */
  10731. /**
  10732. * Sets the meshes not impacted by this light.
  10733. */
  10734. excludedMeshes: AbstractMesh[];
  10735. private _excludeWithLayerMask;
  10736. /**
  10737. * Gets the layer id use to find what meshes are not impacted by the light.
  10738. * Inactive if 0
  10739. */
  10740. /**
  10741. * Sets the layer id use to find what meshes are not impacted by the light.
  10742. * Inactive if 0
  10743. */
  10744. excludeWithLayerMask: number;
  10745. private _includeOnlyWithLayerMask;
  10746. /**
  10747. * Gets the layer id use to find what meshes are impacted by the light.
  10748. * Inactive if 0
  10749. */
  10750. /**
  10751. * Sets the layer id use to find what meshes are impacted by the light.
  10752. * Inactive if 0
  10753. */
  10754. includeOnlyWithLayerMask: number;
  10755. private _lightmapMode;
  10756. /**
  10757. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10758. */
  10759. /**
  10760. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10761. */
  10762. lightmapMode: number;
  10763. /**
  10764. * Shadow generator associted to the light.
  10765. * @hidden Internal use only.
  10766. */
  10767. _shadowGenerator: Nullable<IShadowGenerator>;
  10768. /**
  10769. * @hidden Internal use only.
  10770. */
  10771. _excludedMeshesIds: string[];
  10772. /**
  10773. * @hidden Internal use only.
  10774. */
  10775. _includedOnlyMeshesIds: string[];
  10776. /**
  10777. * The current light unifom buffer.
  10778. * @hidden Internal use only.
  10779. */
  10780. _uniformBuffer: UniformBuffer;
  10781. /**
  10782. * Creates a Light object in the scene.
  10783. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10784. * @param name The firendly name of the light
  10785. * @param scene The scene the light belongs too
  10786. */
  10787. constructor(name: string, scene: Scene);
  10788. protected abstract _buildUniformLayout(): void;
  10789. /**
  10790. * Sets the passed Effect "effect" with the Light information.
  10791. * @param effect The effect to update
  10792. * @param lightIndex The index of the light in the effect to update
  10793. * @returns The light
  10794. */
  10795. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10796. /**
  10797. * Returns the string "Light".
  10798. * @returns the class name
  10799. */
  10800. getClassName(): string;
  10801. /** @hidden */
  10802. readonly _isLight: boolean;
  10803. /**
  10804. * Converts the light information to a readable string for debug purpose.
  10805. * @param fullDetails Supports for multiple levels of logging within scene loading
  10806. * @returns the human readable light info
  10807. */
  10808. toString(fullDetails?: boolean): string;
  10809. /** @hidden */
  10810. protected _syncParentEnabledState(): void;
  10811. /**
  10812. * Set the enabled state of this node.
  10813. * @param value - the new enabled state
  10814. */
  10815. setEnabled(value: boolean): void;
  10816. /**
  10817. * Returns the Light associated shadow generator if any.
  10818. * @return the associated shadow generator.
  10819. */
  10820. getShadowGenerator(): Nullable<IShadowGenerator>;
  10821. /**
  10822. * Returns a Vector3, the absolute light position in the World.
  10823. * @returns the world space position of the light
  10824. */
  10825. getAbsolutePosition(): Vector3;
  10826. /**
  10827. * Specifies if the light will affect the passed mesh.
  10828. * @param mesh The mesh to test against the light
  10829. * @return true the mesh is affected otherwise, false.
  10830. */
  10831. canAffectMesh(mesh: AbstractMesh): boolean;
  10832. /**
  10833. * Sort function to order lights for rendering.
  10834. * @param a First Light object to compare to second.
  10835. * @param b Second Light object to compare first.
  10836. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10837. */
  10838. static CompareLightsPriority(a: Light, b: Light): number;
  10839. /**
  10840. * Releases resources associated with this node.
  10841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10843. */
  10844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10845. /**
  10846. * Returns the light type ID (integer).
  10847. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10848. */
  10849. getTypeID(): number;
  10850. /**
  10851. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10852. * @returns the scaled intensity in intensity mode unit
  10853. */
  10854. getScaledIntensity(): number;
  10855. /**
  10856. * Returns a new Light object, named "name", from the current one.
  10857. * @param name The name of the cloned light
  10858. * @returns the new created light
  10859. */
  10860. clone(name: string): Nullable<Light>;
  10861. /**
  10862. * Serializes the current light into a Serialization object.
  10863. * @returns the serialized object.
  10864. */
  10865. serialize(): any;
  10866. /**
  10867. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10868. * This new light is named "name" and added to the passed scene.
  10869. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10870. * @param name The friendly name of the light
  10871. * @param scene The scene the new light will belong to
  10872. * @returns the constructor function
  10873. */
  10874. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10875. /**
  10876. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10877. * @param parsedLight The JSON representation of the light
  10878. * @param scene The scene to create the parsed light in
  10879. * @returns the created light after parsing
  10880. */
  10881. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10882. private _hookArrayForExcluded;
  10883. private _hookArrayForIncludedOnly;
  10884. private _resyncMeshes;
  10885. /**
  10886. * Forces the meshes to update their light related information in their rendering used effects
  10887. * @hidden Internal Use Only
  10888. */
  10889. _markMeshesAsLightDirty(): void;
  10890. /**
  10891. * Recomputes the cached photometric scale if needed.
  10892. */
  10893. private _computePhotometricScale;
  10894. /**
  10895. * Returns the Photometric Scale according to the light type and intensity mode.
  10896. */
  10897. private _getPhotometricScale;
  10898. /**
  10899. * Reorder the light in the scene according to their defined priority.
  10900. * @hidden Internal Use Only
  10901. */
  10902. _reorderLightsInScene(): void;
  10903. /**
  10904. * Prepares the list of defines specific to the light type.
  10905. * @param defines the list of defines
  10906. * @param lightIndex defines the index of the light for the effect
  10907. */
  10908. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10909. }
  10910. }
  10911. declare module "babylonjs/Actions/action" {
  10912. import { Observable } from "babylonjs/Misc/observable";
  10913. import { Condition } from "babylonjs/Actions/condition";
  10914. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10915. import { ActionManager } from "babylonjs/Actions/actionManager";
  10916. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10917. /**
  10918. * Interface used to define Action
  10919. */
  10920. export interface IAction {
  10921. /**
  10922. * Trigger for the action
  10923. */
  10924. trigger: number;
  10925. /** Options of the trigger */
  10926. triggerOptions: any;
  10927. /**
  10928. * Gets the trigger parameters
  10929. * @returns the trigger parameters
  10930. */
  10931. getTriggerParameter(): any;
  10932. /**
  10933. * Internal only - executes current action event
  10934. * @hidden
  10935. */
  10936. _executeCurrent(evt?: ActionEvent): void;
  10937. /**
  10938. * Serialize placeholder for child classes
  10939. * @param parent of child
  10940. * @returns the serialized object
  10941. */
  10942. serialize(parent: any): any;
  10943. /**
  10944. * Internal only
  10945. * @hidden
  10946. */
  10947. _prepare(): void;
  10948. /**
  10949. * Internal only - manager for action
  10950. * @hidden
  10951. */
  10952. _actionManager: AbstractActionManager;
  10953. /**
  10954. * Adds action to chain of actions, may be a DoNothingAction
  10955. * @param action defines the next action to execute
  10956. * @returns The action passed in
  10957. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10958. */
  10959. then(action: IAction): IAction;
  10960. }
  10961. /**
  10962. * The action to be carried out following a trigger
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10964. */
  10965. export class Action implements IAction {
  10966. /** the trigger, with or without parameters, for the action */
  10967. triggerOptions: any;
  10968. /**
  10969. * Trigger for the action
  10970. */
  10971. trigger: number;
  10972. /**
  10973. * Internal only - manager for action
  10974. * @hidden
  10975. */
  10976. _actionManager: ActionManager;
  10977. private _nextActiveAction;
  10978. private _child;
  10979. private _condition?;
  10980. private _triggerParameter;
  10981. /**
  10982. * An event triggered prior to action being executed.
  10983. */
  10984. onBeforeExecuteObservable: Observable<Action>;
  10985. /**
  10986. * Creates a new Action
  10987. * @param triggerOptions the trigger, with or without parameters, for the action
  10988. * @param condition an optional determinant of action
  10989. */
  10990. constructor(
  10991. /** the trigger, with or without parameters, for the action */
  10992. triggerOptions: any, condition?: Condition);
  10993. /**
  10994. * Internal only
  10995. * @hidden
  10996. */
  10997. _prepare(): void;
  10998. /**
  10999. * Gets the trigger parameters
  11000. * @returns the trigger parameters
  11001. */
  11002. getTriggerParameter(): any;
  11003. /**
  11004. * Internal only - executes current action event
  11005. * @hidden
  11006. */
  11007. _executeCurrent(evt?: ActionEvent): void;
  11008. /**
  11009. * Execute placeholder for child classes
  11010. * @param evt optional action event
  11011. */
  11012. execute(evt?: ActionEvent): void;
  11013. /**
  11014. * Skips to next active action
  11015. */
  11016. skipToNextActiveAction(): void;
  11017. /**
  11018. * Adds action to chain of actions, may be a DoNothingAction
  11019. * @param action defines the next action to execute
  11020. * @returns The action passed in
  11021. * @see https://www.babylonjs-playground.com/#1T30HR#0
  11022. */
  11023. then(action: Action): Action;
  11024. /**
  11025. * Internal only
  11026. * @hidden
  11027. */
  11028. _getProperty(propertyPath: string): string;
  11029. /**
  11030. * Internal only
  11031. * @hidden
  11032. */
  11033. _getEffectiveTarget(target: any, propertyPath: string): any;
  11034. /**
  11035. * Serialize placeholder for child classes
  11036. * @param parent of child
  11037. * @returns the serialized object
  11038. */
  11039. serialize(parent: any): any;
  11040. /**
  11041. * Internal only called by serialize
  11042. * @hidden
  11043. */
  11044. protected _serialize(serializedAction: any, parent?: any): any;
  11045. /**
  11046. * Internal only
  11047. * @hidden
  11048. */
  11049. static _SerializeValueAsString: (value: any) => string;
  11050. /**
  11051. * Internal only
  11052. * @hidden
  11053. */
  11054. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  11055. name: string;
  11056. targetType: string;
  11057. value: string;
  11058. };
  11059. }
  11060. }
  11061. declare module "babylonjs/Actions/condition" {
  11062. import { ActionManager } from "babylonjs/Actions/actionManager";
  11063. /**
  11064. * A Condition applied to an Action
  11065. */
  11066. export class Condition {
  11067. /**
  11068. * Internal only - manager for action
  11069. * @hidden
  11070. */
  11071. _actionManager: ActionManager;
  11072. /**
  11073. * Internal only
  11074. * @hidden
  11075. */
  11076. _evaluationId: number;
  11077. /**
  11078. * Internal only
  11079. * @hidden
  11080. */
  11081. _currentResult: boolean;
  11082. /**
  11083. * Creates a new Condition
  11084. * @param actionManager the manager of the action the condition is applied to
  11085. */
  11086. constructor(actionManager: ActionManager);
  11087. /**
  11088. * Check if the current condition is valid
  11089. * @returns a boolean
  11090. */
  11091. isValid(): boolean;
  11092. /**
  11093. * Internal only
  11094. * @hidden
  11095. */
  11096. _getProperty(propertyPath: string): string;
  11097. /**
  11098. * Internal only
  11099. * @hidden
  11100. */
  11101. _getEffectiveTarget(target: any, propertyPath: string): any;
  11102. /**
  11103. * Serialize placeholder for child classes
  11104. * @returns the serialized object
  11105. */
  11106. serialize(): any;
  11107. /**
  11108. * Internal only
  11109. * @hidden
  11110. */
  11111. protected _serialize(serializedCondition: any): any;
  11112. }
  11113. /**
  11114. * Defines specific conditional operators as extensions of Condition
  11115. */
  11116. export class ValueCondition extends Condition {
  11117. /** path to specify the property of the target the conditional operator uses */
  11118. propertyPath: string;
  11119. /** the value compared by the conditional operator against the current value of the property */
  11120. value: any;
  11121. /** the conditional operator, default ValueCondition.IsEqual */
  11122. operator: number;
  11123. /**
  11124. * Internal only
  11125. * @hidden
  11126. */
  11127. private static _IsEqual;
  11128. /**
  11129. * Internal only
  11130. * @hidden
  11131. */
  11132. private static _IsDifferent;
  11133. /**
  11134. * Internal only
  11135. * @hidden
  11136. */
  11137. private static _IsGreater;
  11138. /**
  11139. * Internal only
  11140. * @hidden
  11141. */
  11142. private static _IsLesser;
  11143. /**
  11144. * returns the number for IsEqual
  11145. */
  11146. static readonly IsEqual: number;
  11147. /**
  11148. * Returns the number for IsDifferent
  11149. */
  11150. static readonly IsDifferent: number;
  11151. /**
  11152. * Returns the number for IsGreater
  11153. */
  11154. static readonly IsGreater: number;
  11155. /**
  11156. * Returns the number for IsLesser
  11157. */
  11158. static readonly IsLesser: number;
  11159. /**
  11160. * Internal only The action manager for the condition
  11161. * @hidden
  11162. */
  11163. _actionManager: ActionManager;
  11164. /**
  11165. * Internal only
  11166. * @hidden
  11167. */
  11168. private _target;
  11169. /**
  11170. * Internal only
  11171. * @hidden
  11172. */
  11173. private _effectiveTarget;
  11174. /**
  11175. * Internal only
  11176. * @hidden
  11177. */
  11178. private _property;
  11179. /**
  11180. * Creates a new ValueCondition
  11181. * @param actionManager manager for the action the condition applies to
  11182. * @param target for the action
  11183. * @param propertyPath path to specify the property of the target the conditional operator uses
  11184. * @param value the value compared by the conditional operator against the current value of the property
  11185. * @param operator the conditional operator, default ValueCondition.IsEqual
  11186. */
  11187. constructor(actionManager: ActionManager, target: any,
  11188. /** path to specify the property of the target the conditional operator uses */
  11189. propertyPath: string,
  11190. /** the value compared by the conditional operator against the current value of the property */
  11191. value: any,
  11192. /** the conditional operator, default ValueCondition.IsEqual */
  11193. operator?: number);
  11194. /**
  11195. * Compares the given value with the property value for the specified conditional operator
  11196. * @returns the result of the comparison
  11197. */
  11198. isValid(): boolean;
  11199. /**
  11200. * Serialize the ValueCondition into a JSON compatible object
  11201. * @returns serialization object
  11202. */
  11203. serialize(): any;
  11204. /**
  11205. * Gets the name of the conditional operator for the ValueCondition
  11206. * @param operator the conditional operator
  11207. * @returns the name
  11208. */
  11209. static GetOperatorName(operator: number): string;
  11210. }
  11211. /**
  11212. * Defines a predicate condition as an extension of Condition
  11213. */
  11214. export class PredicateCondition extends Condition {
  11215. /** defines the predicate function used to validate the condition */
  11216. predicate: () => boolean;
  11217. /**
  11218. * Internal only - manager for action
  11219. * @hidden
  11220. */
  11221. _actionManager: ActionManager;
  11222. /**
  11223. * Creates a new PredicateCondition
  11224. * @param actionManager manager for the action the condition applies to
  11225. * @param predicate defines the predicate function used to validate the condition
  11226. */
  11227. constructor(actionManager: ActionManager,
  11228. /** defines the predicate function used to validate the condition */
  11229. predicate: () => boolean);
  11230. /**
  11231. * @returns the validity of the predicate condition
  11232. */
  11233. isValid(): boolean;
  11234. }
  11235. /**
  11236. * Defines a state condition as an extension of Condition
  11237. */
  11238. export class StateCondition extends Condition {
  11239. /** Value to compare with target state */
  11240. value: string;
  11241. /**
  11242. * Internal only - manager for action
  11243. * @hidden
  11244. */
  11245. _actionManager: ActionManager;
  11246. /**
  11247. * Internal only
  11248. * @hidden
  11249. */
  11250. private _target;
  11251. /**
  11252. * Creates a new StateCondition
  11253. * @param actionManager manager for the action the condition applies to
  11254. * @param target of the condition
  11255. * @param value to compare with target state
  11256. */
  11257. constructor(actionManager: ActionManager, target: any,
  11258. /** Value to compare with target state */
  11259. value: string);
  11260. /**
  11261. * Gets a boolean indicating if the current condition is met
  11262. * @returns the validity of the state
  11263. */
  11264. isValid(): boolean;
  11265. /**
  11266. * Serialize the StateCondition into a JSON compatible object
  11267. * @returns serialization object
  11268. */
  11269. serialize(): any;
  11270. }
  11271. }
  11272. declare module "babylonjs/Actions/directActions" {
  11273. import { Action } from "babylonjs/Actions/action";
  11274. import { Condition } from "babylonjs/Actions/condition";
  11275. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11276. /**
  11277. * This defines an action responsible to toggle a boolean once triggered.
  11278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11279. */
  11280. export class SwitchBooleanAction extends Action {
  11281. /**
  11282. * The path to the boolean property in the target object
  11283. */
  11284. propertyPath: string;
  11285. private _target;
  11286. private _effectiveTarget;
  11287. private _property;
  11288. /**
  11289. * Instantiate the action
  11290. * @param triggerOptions defines the trigger options
  11291. * @param target defines the object containing the boolean
  11292. * @param propertyPath defines the path to the boolean property in the target object
  11293. * @param condition defines the trigger related conditions
  11294. */
  11295. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11296. /** @hidden */
  11297. _prepare(): void;
  11298. /**
  11299. * Execute the action toggle the boolean value.
  11300. */
  11301. execute(): void;
  11302. /**
  11303. * Serializes the actions and its related information.
  11304. * @param parent defines the object to serialize in
  11305. * @returns the serialized object
  11306. */
  11307. serialize(parent: any): any;
  11308. }
  11309. /**
  11310. * This defines an action responsible to set a the state field of the target
  11311. * to a desired value once triggered.
  11312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11313. */
  11314. export class SetStateAction extends Action {
  11315. /**
  11316. * The value to store in the state field.
  11317. */
  11318. value: string;
  11319. private _target;
  11320. /**
  11321. * Instantiate the action
  11322. * @param triggerOptions defines the trigger options
  11323. * @param target defines the object containing the state property
  11324. * @param value defines the value to store in the state field
  11325. * @param condition defines the trigger related conditions
  11326. */
  11327. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11328. /**
  11329. * Execute the action and store the value on the target state property.
  11330. */
  11331. execute(): void;
  11332. /**
  11333. * Serializes the actions and its related information.
  11334. * @param parent defines the object to serialize in
  11335. * @returns the serialized object
  11336. */
  11337. serialize(parent: any): any;
  11338. }
  11339. /**
  11340. * This defines an action responsible to set a property of the target
  11341. * to a desired value once triggered.
  11342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11343. */
  11344. export class SetValueAction extends Action {
  11345. /**
  11346. * The path of the property to set in the target.
  11347. */
  11348. propertyPath: string;
  11349. /**
  11350. * The value to set in the property
  11351. */
  11352. value: any;
  11353. private _target;
  11354. private _effectiveTarget;
  11355. private _property;
  11356. /**
  11357. * Instantiate the action
  11358. * @param triggerOptions defines the trigger options
  11359. * @param target defines the object containing the property
  11360. * @param propertyPath defines the path of the property to set in the target
  11361. * @param value defines the value to set in the property
  11362. * @param condition defines the trigger related conditions
  11363. */
  11364. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11365. /** @hidden */
  11366. _prepare(): void;
  11367. /**
  11368. * Execute the action and set the targetted property to the desired value.
  11369. */
  11370. execute(): void;
  11371. /**
  11372. * Serializes the actions and its related information.
  11373. * @param parent defines the object to serialize in
  11374. * @returns the serialized object
  11375. */
  11376. serialize(parent: any): any;
  11377. }
  11378. /**
  11379. * This defines an action responsible to increment the target value
  11380. * to a desired value once triggered.
  11381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11382. */
  11383. export class IncrementValueAction extends Action {
  11384. /**
  11385. * The path of the property to increment in the target.
  11386. */
  11387. propertyPath: string;
  11388. /**
  11389. * The value we should increment the property by.
  11390. */
  11391. value: any;
  11392. private _target;
  11393. private _effectiveTarget;
  11394. private _property;
  11395. /**
  11396. * Instantiate the action
  11397. * @param triggerOptions defines the trigger options
  11398. * @param target defines the object containing the property
  11399. * @param propertyPath defines the path of the property to increment in the target
  11400. * @param value defines the value value we should increment the property by
  11401. * @param condition defines the trigger related conditions
  11402. */
  11403. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11404. /** @hidden */
  11405. _prepare(): void;
  11406. /**
  11407. * Execute the action and increment the target of the value amount.
  11408. */
  11409. execute(): void;
  11410. /**
  11411. * Serializes the actions and its related information.
  11412. * @param parent defines the object to serialize in
  11413. * @returns the serialized object
  11414. */
  11415. serialize(parent: any): any;
  11416. }
  11417. /**
  11418. * This defines an action responsible to start an animation once triggered.
  11419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11420. */
  11421. export class PlayAnimationAction extends Action {
  11422. /**
  11423. * Where the animation should start (animation frame)
  11424. */
  11425. from: number;
  11426. /**
  11427. * Where the animation should stop (animation frame)
  11428. */
  11429. to: number;
  11430. /**
  11431. * Define if the animation should loop or stop after the first play.
  11432. */
  11433. loop?: boolean;
  11434. private _target;
  11435. /**
  11436. * Instantiate the action
  11437. * @param triggerOptions defines the trigger options
  11438. * @param target defines the target animation or animation name
  11439. * @param from defines from where the animation should start (animation frame)
  11440. * @param end defines where the animation should stop (animation frame)
  11441. * @param loop defines if the animation should loop or stop after the first play
  11442. * @param condition defines the trigger related conditions
  11443. */
  11444. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11445. /** @hidden */
  11446. _prepare(): void;
  11447. /**
  11448. * Execute the action and play the animation.
  11449. */
  11450. execute(): void;
  11451. /**
  11452. * Serializes the actions and its related information.
  11453. * @param parent defines the object to serialize in
  11454. * @returns the serialized object
  11455. */
  11456. serialize(parent: any): any;
  11457. }
  11458. /**
  11459. * This defines an action responsible to stop an animation once triggered.
  11460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11461. */
  11462. export class StopAnimationAction extends Action {
  11463. private _target;
  11464. /**
  11465. * Instantiate the action
  11466. * @param triggerOptions defines the trigger options
  11467. * @param target defines the target animation or animation name
  11468. * @param condition defines the trigger related conditions
  11469. */
  11470. constructor(triggerOptions: any, target: any, condition?: Condition);
  11471. /** @hidden */
  11472. _prepare(): void;
  11473. /**
  11474. * Execute the action and stop the animation.
  11475. */
  11476. execute(): void;
  11477. /**
  11478. * Serializes the actions and its related information.
  11479. * @param parent defines the object to serialize in
  11480. * @returns the serialized object
  11481. */
  11482. serialize(parent: any): any;
  11483. }
  11484. /**
  11485. * This defines an action responsible that does nothing once triggered.
  11486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11487. */
  11488. export class DoNothingAction extends Action {
  11489. /**
  11490. * Instantiate the action
  11491. * @param triggerOptions defines the trigger options
  11492. * @param condition defines the trigger related conditions
  11493. */
  11494. constructor(triggerOptions?: any, condition?: Condition);
  11495. /**
  11496. * Execute the action and do nothing.
  11497. */
  11498. execute(): void;
  11499. /**
  11500. * Serializes the actions and its related information.
  11501. * @param parent defines the object to serialize in
  11502. * @returns the serialized object
  11503. */
  11504. serialize(parent: any): any;
  11505. }
  11506. /**
  11507. * This defines an action responsible to trigger several actions once triggered.
  11508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11509. */
  11510. export class CombineAction extends Action {
  11511. /**
  11512. * The list of aggregated animations to run.
  11513. */
  11514. children: Action[];
  11515. /**
  11516. * Instantiate the action
  11517. * @param triggerOptions defines the trigger options
  11518. * @param children defines the list of aggregated animations to run
  11519. * @param condition defines the trigger related conditions
  11520. */
  11521. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11522. /** @hidden */
  11523. _prepare(): void;
  11524. /**
  11525. * Execute the action and executes all the aggregated actions.
  11526. */
  11527. execute(evt: ActionEvent): void;
  11528. /**
  11529. * Serializes the actions and its related information.
  11530. * @param parent defines the object to serialize in
  11531. * @returns the serialized object
  11532. */
  11533. serialize(parent: any): any;
  11534. }
  11535. /**
  11536. * This defines an action responsible to run code (external event) once triggered.
  11537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11538. */
  11539. export class ExecuteCodeAction extends Action {
  11540. /**
  11541. * The callback function to run.
  11542. */
  11543. func: (evt: ActionEvent) => void;
  11544. /**
  11545. * Instantiate the action
  11546. * @param triggerOptions defines the trigger options
  11547. * @param func defines the callback function to run
  11548. * @param condition defines the trigger related conditions
  11549. */
  11550. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11551. /**
  11552. * Execute the action and run the attached code.
  11553. */
  11554. execute(evt: ActionEvent): void;
  11555. }
  11556. /**
  11557. * This defines an action responsible to set the parent property of the target once triggered.
  11558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11559. */
  11560. export class SetParentAction extends Action {
  11561. private _parent;
  11562. private _target;
  11563. /**
  11564. * Instantiate the action
  11565. * @param triggerOptions defines the trigger options
  11566. * @param target defines the target containing the parent property
  11567. * @param parent defines from where the animation should start (animation frame)
  11568. * @param condition defines the trigger related conditions
  11569. */
  11570. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11571. /** @hidden */
  11572. _prepare(): void;
  11573. /**
  11574. * Execute the action and set the parent property.
  11575. */
  11576. execute(): void;
  11577. /**
  11578. * Serializes the actions and its related information.
  11579. * @param parent defines the object to serialize in
  11580. * @returns the serialized object
  11581. */
  11582. serialize(parent: any): any;
  11583. }
  11584. }
  11585. declare module "babylonjs/Actions/actionManager" {
  11586. import { Nullable } from "babylonjs/types";
  11587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11588. import { Scene } from "babylonjs/scene";
  11589. import { IAction } from "babylonjs/Actions/action";
  11590. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11591. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11592. /**
  11593. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11594. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11596. */
  11597. export class ActionManager extends AbstractActionManager {
  11598. /**
  11599. * Nothing
  11600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11601. */
  11602. static readonly NothingTrigger: number;
  11603. /**
  11604. * On pick
  11605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11606. */
  11607. static readonly OnPickTrigger: number;
  11608. /**
  11609. * On left pick
  11610. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11611. */
  11612. static readonly OnLeftPickTrigger: number;
  11613. /**
  11614. * On right pick
  11615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11616. */
  11617. static readonly OnRightPickTrigger: number;
  11618. /**
  11619. * On center pick
  11620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11621. */
  11622. static readonly OnCenterPickTrigger: number;
  11623. /**
  11624. * On pick down
  11625. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11626. */
  11627. static readonly OnPickDownTrigger: number;
  11628. /**
  11629. * On double pick
  11630. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11631. */
  11632. static readonly OnDoublePickTrigger: number;
  11633. /**
  11634. * On pick up
  11635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11636. */
  11637. static readonly OnPickUpTrigger: number;
  11638. /**
  11639. * On pick out.
  11640. * This trigger will only be raised if you also declared a OnPickDown
  11641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11642. */
  11643. static readonly OnPickOutTrigger: number;
  11644. /**
  11645. * On long press
  11646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11647. */
  11648. static readonly OnLongPressTrigger: number;
  11649. /**
  11650. * On pointer over
  11651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11652. */
  11653. static readonly OnPointerOverTrigger: number;
  11654. /**
  11655. * On pointer out
  11656. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11657. */
  11658. static readonly OnPointerOutTrigger: number;
  11659. /**
  11660. * On every frame
  11661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11662. */
  11663. static readonly OnEveryFrameTrigger: number;
  11664. /**
  11665. * On intersection enter
  11666. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11667. */
  11668. static readonly OnIntersectionEnterTrigger: number;
  11669. /**
  11670. * On intersection exit
  11671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11672. */
  11673. static readonly OnIntersectionExitTrigger: number;
  11674. /**
  11675. * On key down
  11676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11677. */
  11678. static readonly OnKeyDownTrigger: number;
  11679. /**
  11680. * On key up
  11681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11682. */
  11683. static readonly OnKeyUpTrigger: number;
  11684. private _scene;
  11685. /**
  11686. * Creates a new action manager
  11687. * @param scene defines the hosting scene
  11688. */
  11689. constructor(scene: Scene);
  11690. /**
  11691. * Releases all associated resources
  11692. */
  11693. dispose(): void;
  11694. /**
  11695. * Gets hosting scene
  11696. * @returns the hosting scene
  11697. */
  11698. getScene(): Scene;
  11699. /**
  11700. * Does this action manager handles actions of any of the given triggers
  11701. * @param triggers defines the triggers to be tested
  11702. * @return a boolean indicating whether one (or more) of the triggers is handled
  11703. */
  11704. hasSpecificTriggers(triggers: number[]): boolean;
  11705. /**
  11706. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11707. * speed.
  11708. * @param triggerA defines the trigger to be tested
  11709. * @param triggerB defines the trigger to be tested
  11710. * @return a boolean indicating whether one (or more) of the triggers is handled
  11711. */
  11712. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11713. /**
  11714. * Does this action manager handles actions of a given trigger
  11715. * @param trigger defines the trigger to be tested
  11716. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11717. * @return whether the trigger is handled
  11718. */
  11719. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11720. /**
  11721. * Does this action manager has pointer triggers
  11722. */
  11723. readonly hasPointerTriggers: boolean;
  11724. /**
  11725. * Does this action manager has pick triggers
  11726. */
  11727. readonly hasPickTriggers: boolean;
  11728. /**
  11729. * Registers an action to this action manager
  11730. * @param action defines the action to be registered
  11731. * @return the action amended (prepared) after registration
  11732. */
  11733. registerAction(action: IAction): Nullable<IAction>;
  11734. /**
  11735. * Unregisters an action to this action manager
  11736. * @param action defines the action to be unregistered
  11737. * @return a boolean indicating whether the action has been unregistered
  11738. */
  11739. unregisterAction(action: IAction): Boolean;
  11740. /**
  11741. * Process a specific trigger
  11742. * @param trigger defines the trigger to process
  11743. * @param evt defines the event details to be processed
  11744. */
  11745. processTrigger(trigger: number, evt?: IActionEvent): void;
  11746. /** @hidden */
  11747. _getEffectiveTarget(target: any, propertyPath: string): any;
  11748. /** @hidden */
  11749. _getProperty(propertyPath: string): string;
  11750. /**
  11751. * Serialize this manager to a JSON object
  11752. * @param name defines the property name to store this manager
  11753. * @returns a JSON representation of this manager
  11754. */
  11755. serialize(name: string): any;
  11756. /**
  11757. * Creates a new ActionManager from a JSON data
  11758. * @param parsedActions defines the JSON data to read from
  11759. * @param object defines the hosting mesh
  11760. * @param scene defines the hosting scene
  11761. */
  11762. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11763. /**
  11764. * Get a trigger name by index
  11765. * @param trigger defines the trigger index
  11766. * @returns a trigger name
  11767. */
  11768. static GetTriggerName(trigger: number): string;
  11769. }
  11770. }
  11771. declare module "babylonjs/Culling/ray" {
  11772. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11773. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11774. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11775. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11776. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11777. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11778. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11779. /**
  11780. * Class representing a ray with position and direction
  11781. */
  11782. export class Ray {
  11783. /** origin point */
  11784. origin: Vector3;
  11785. /** direction */
  11786. direction: Vector3;
  11787. /** length of the ray */
  11788. length: number;
  11789. private static readonly TmpVector3;
  11790. private _tmpRay;
  11791. /**
  11792. * Creates a new ray
  11793. * @param origin origin point
  11794. * @param direction direction
  11795. * @param length length of the ray
  11796. */
  11797. constructor(
  11798. /** origin point */
  11799. origin: Vector3,
  11800. /** direction */
  11801. direction: Vector3,
  11802. /** length of the ray */
  11803. length?: number);
  11804. /**
  11805. * Checks if the ray intersects a box
  11806. * @param minimum bound of the box
  11807. * @param maximum bound of the box
  11808. * @param intersectionTreshold extra extend to be added to the box in all direction
  11809. * @returns if the box was hit
  11810. */
  11811. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11812. /**
  11813. * Checks if the ray intersects a box
  11814. * @param box the bounding box to check
  11815. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11816. * @returns if the box was hit
  11817. */
  11818. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11819. /**
  11820. * If the ray hits a sphere
  11821. * @param sphere the bounding sphere to check
  11822. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11823. * @returns true if it hits the sphere
  11824. */
  11825. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11826. /**
  11827. * If the ray hits a triange
  11828. * @param vertex0 triangle vertex
  11829. * @param vertex1 triangle vertex
  11830. * @param vertex2 triangle vertex
  11831. * @returns intersection information if hit
  11832. */
  11833. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11834. /**
  11835. * Checks if ray intersects a plane
  11836. * @param plane the plane to check
  11837. * @returns the distance away it was hit
  11838. */
  11839. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11840. /**
  11841. * Checks if ray intersects a mesh
  11842. * @param mesh the mesh to check
  11843. * @param fastCheck if only the bounding box should checked
  11844. * @returns picking info of the intersecton
  11845. */
  11846. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11847. /**
  11848. * Checks if ray intersects a mesh
  11849. * @param meshes the meshes to check
  11850. * @param fastCheck if only the bounding box should checked
  11851. * @param results array to store result in
  11852. * @returns Array of picking infos
  11853. */
  11854. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11855. private _comparePickingInfo;
  11856. private static smallnum;
  11857. private static rayl;
  11858. /**
  11859. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11860. * @param sega the first point of the segment to test the intersection against
  11861. * @param segb the second point of the segment to test the intersection against
  11862. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11863. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11864. */
  11865. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11866. /**
  11867. * Update the ray from viewport position
  11868. * @param x position
  11869. * @param y y position
  11870. * @param viewportWidth viewport width
  11871. * @param viewportHeight viewport height
  11872. * @param world world matrix
  11873. * @param view view matrix
  11874. * @param projection projection matrix
  11875. * @returns this ray updated
  11876. */
  11877. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11878. /**
  11879. * Creates a ray with origin and direction of 0,0,0
  11880. * @returns the new ray
  11881. */
  11882. static Zero(): Ray;
  11883. /**
  11884. * Creates a new ray from screen space and viewport
  11885. * @param x position
  11886. * @param y y position
  11887. * @param viewportWidth viewport width
  11888. * @param viewportHeight viewport height
  11889. * @param world world matrix
  11890. * @param view view matrix
  11891. * @param projection projection matrix
  11892. * @returns new ray
  11893. */
  11894. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11895. /**
  11896. * 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
  11897. * transformed to the given world matrix.
  11898. * @param origin The origin point
  11899. * @param end The end point
  11900. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11901. * @returns the new ray
  11902. */
  11903. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11904. /**
  11905. * Transforms a ray by a matrix
  11906. * @param ray ray to transform
  11907. * @param matrix matrix to apply
  11908. * @returns the resulting new ray
  11909. */
  11910. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11911. /**
  11912. * Transforms a ray by a matrix
  11913. * @param ray ray to transform
  11914. * @param matrix matrix to apply
  11915. * @param result ray to store result in
  11916. */
  11917. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11918. /**
  11919. * Unproject a ray from screen space to object space
  11920. * @param sourceX defines the screen space x coordinate to use
  11921. * @param sourceY defines the screen space y coordinate to use
  11922. * @param viewportWidth defines the current width of the viewport
  11923. * @param viewportHeight defines the current height of the viewport
  11924. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11925. * @param view defines the view matrix to use
  11926. * @param projection defines the projection matrix to use
  11927. */
  11928. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11929. }
  11930. /**
  11931. * Type used to define predicate used to select faces when a mesh intersection is detected
  11932. */
  11933. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11934. module "babylonjs/scene" {
  11935. interface Scene {
  11936. /** @hidden */
  11937. _tempPickingRay: Nullable<Ray>;
  11938. /** @hidden */
  11939. _cachedRayForTransform: Ray;
  11940. /** @hidden */
  11941. _pickWithRayInverseMatrix: Matrix;
  11942. /** @hidden */
  11943. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11944. /** @hidden */
  11945. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11946. }
  11947. }
  11948. }
  11949. declare module "babylonjs/sceneComponent" {
  11950. import { Scene } from "babylonjs/scene";
  11951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11952. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11953. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11954. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11955. import { Nullable } from "babylonjs/types";
  11956. import { Camera } from "babylonjs/Cameras/camera";
  11957. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11958. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11959. import { AbstractScene } from "babylonjs/abstractScene";
  11960. /**
  11961. * Groups all the scene component constants in one place to ease maintenance.
  11962. * @hidden
  11963. */
  11964. export class SceneComponentConstants {
  11965. static readonly NAME_EFFECTLAYER: string;
  11966. static readonly NAME_LAYER: string;
  11967. static readonly NAME_LENSFLARESYSTEM: string;
  11968. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11969. static readonly NAME_PARTICLESYSTEM: string;
  11970. static readonly NAME_GAMEPAD: string;
  11971. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11972. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11973. static readonly NAME_DEPTHRENDERER: string;
  11974. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11975. static readonly NAME_SPRITE: string;
  11976. static readonly NAME_OUTLINERENDERER: string;
  11977. static readonly NAME_PROCEDURALTEXTURE: string;
  11978. static readonly NAME_SHADOWGENERATOR: string;
  11979. static readonly NAME_OCTREE: string;
  11980. static readonly NAME_PHYSICSENGINE: string;
  11981. static readonly NAME_AUDIO: string;
  11982. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11983. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11984. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11985. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11986. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11987. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11988. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11989. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11990. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11991. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11992. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11993. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11994. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11995. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11996. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11997. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11998. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11999. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12000. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12001. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12002. static readonly STEP_AFTERRENDER_AUDIO: number;
  12003. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12004. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12005. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12006. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12007. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12008. static readonly STEP_POINTERMOVE_SPRITE: number;
  12009. static readonly STEP_POINTERDOWN_SPRITE: number;
  12010. static readonly STEP_POINTERUP_SPRITE: number;
  12011. }
  12012. /**
  12013. * This represents a scene component.
  12014. *
  12015. * This is used to decouple the dependency the scene is having on the different workloads like
  12016. * layers, post processes...
  12017. */
  12018. export interface ISceneComponent {
  12019. /**
  12020. * The name of the component. Each component must have a unique name.
  12021. */
  12022. name: string;
  12023. /**
  12024. * The scene the component belongs to.
  12025. */
  12026. scene: Scene;
  12027. /**
  12028. * Register the component to one instance of a scene.
  12029. */
  12030. register(): void;
  12031. /**
  12032. * Rebuilds the elements related to this component in case of
  12033. * context lost for instance.
  12034. */
  12035. rebuild(): void;
  12036. /**
  12037. * Disposes the component and the associated ressources.
  12038. */
  12039. dispose(): void;
  12040. }
  12041. /**
  12042. * This represents a SERIALIZABLE scene component.
  12043. *
  12044. * This extends Scene Component to add Serialization methods on top.
  12045. */
  12046. export interface ISceneSerializableComponent extends ISceneComponent {
  12047. /**
  12048. * Adds all the elements from the container to the scene
  12049. * @param container the container holding the elements
  12050. */
  12051. addFromContainer(container: AbstractScene): void;
  12052. /**
  12053. * Removes all the elements in the container from the scene
  12054. * @param container contains the elements to remove
  12055. * @param dispose if the removed element should be disposed (default: false)
  12056. */
  12057. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  12058. /**
  12059. * Serializes the component data to the specified json object
  12060. * @param serializationObject The object to serialize to
  12061. */
  12062. serialize(serializationObject: any): void;
  12063. }
  12064. /**
  12065. * Strong typing of a Mesh related stage step action
  12066. */
  12067. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12068. /**
  12069. * Strong typing of a Evaluate Sub Mesh related stage step action
  12070. */
  12071. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12072. /**
  12073. * Strong typing of a Active Mesh related stage step action
  12074. */
  12075. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12076. /**
  12077. * Strong typing of a Camera related stage step action
  12078. */
  12079. export type CameraStageAction = (camera: Camera) => void;
  12080. /**
  12081. * Strong typing of a Camera Frame buffer related stage step action
  12082. */
  12083. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  12084. /**
  12085. * Strong typing of a Render Target related stage step action
  12086. */
  12087. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12088. /**
  12089. * Strong typing of a RenderingGroup related stage step action
  12090. */
  12091. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12092. /**
  12093. * Strong typing of a Mesh Render related stage step action
  12094. */
  12095. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12096. /**
  12097. * Strong typing of a simple stage step action
  12098. */
  12099. export type SimpleStageAction = () => void;
  12100. /**
  12101. * Strong typing of a render target action.
  12102. */
  12103. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12104. /**
  12105. * Strong typing of a pointer move action.
  12106. */
  12107. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12108. /**
  12109. * Strong typing of a pointer up/down action.
  12110. */
  12111. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12112. /**
  12113. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12114. * @hidden
  12115. */
  12116. export class Stage<T extends Function> extends Array<{
  12117. index: number;
  12118. component: ISceneComponent;
  12119. action: T;
  12120. }> {
  12121. /**
  12122. * Hide ctor from the rest of the world.
  12123. * @param items The items to add.
  12124. */
  12125. private constructor();
  12126. /**
  12127. * Creates a new Stage.
  12128. * @returns A new instance of a Stage
  12129. */
  12130. static Create<T extends Function>(): Stage<T>;
  12131. /**
  12132. * Registers a step in an ordered way in the targeted stage.
  12133. * @param index Defines the position to register the step in
  12134. * @param component Defines the component attached to the step
  12135. * @param action Defines the action to launch during the step
  12136. */
  12137. registerStep(index: number, component: ISceneComponent, action: T): void;
  12138. /**
  12139. * Clears all the steps from the stage.
  12140. */
  12141. clear(): void;
  12142. }
  12143. }
  12144. declare module "babylonjs/Sprites/spriteSceneComponent" {
  12145. import { Nullable } from "babylonjs/types";
  12146. import { Observable } from "babylonjs/Misc/observable";
  12147. import { Scene } from "babylonjs/scene";
  12148. import { Sprite } from "babylonjs/Sprites/sprite";
  12149. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12150. import { Ray } from "babylonjs/Culling/ray";
  12151. import { Camera } from "babylonjs/Cameras/camera";
  12152. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12153. import { ISceneComponent } from "babylonjs/sceneComponent";
  12154. module "babylonjs/scene" {
  12155. interface Scene {
  12156. /** @hidden */
  12157. _pointerOverSprite: Nullable<Sprite>;
  12158. /** @hidden */
  12159. _pickedDownSprite: Nullable<Sprite>;
  12160. /** @hidden */
  12161. _tempSpritePickingRay: Nullable<Ray>;
  12162. /**
  12163. * All of the sprite managers added to this scene
  12164. * @see http://doc.babylonjs.com/babylon101/sprites
  12165. */
  12166. spriteManagers: Array<ISpriteManager>;
  12167. /**
  12168. * An event triggered when sprites rendering is about to start
  12169. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12170. */
  12171. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12172. /**
  12173. * An event triggered when sprites rendering is done
  12174. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12175. */
  12176. onAfterSpritesRenderingObservable: Observable<Scene>;
  12177. /** @hidden */
  12178. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12179. /** Launch a ray to try to pick a sprite in the scene
  12180. * @param x position on screen
  12181. * @param y position on screen
  12182. * @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
  12183. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12184. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12185. * @returns a PickingInfo
  12186. */
  12187. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12188. /** Use the given ray to pick a sprite in the scene
  12189. * @param ray The ray (in world space) to use to pick meshes
  12190. * @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
  12191. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12192. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12193. * @returns a PickingInfo
  12194. */
  12195. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12196. /**
  12197. * Force the sprite under the pointer
  12198. * @param sprite defines the sprite to use
  12199. */
  12200. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12201. /**
  12202. * Gets the sprite under the pointer
  12203. * @returns a Sprite or null if no sprite is under the pointer
  12204. */
  12205. getPointerOverSprite(): Nullable<Sprite>;
  12206. }
  12207. }
  12208. /**
  12209. * Defines the sprite scene component responsible to manage sprites
  12210. * in a given scene.
  12211. */
  12212. export class SpriteSceneComponent implements ISceneComponent {
  12213. /**
  12214. * The component name helpfull to identify the component in the list of scene components.
  12215. */
  12216. readonly name: string;
  12217. /**
  12218. * The scene the component belongs to.
  12219. */
  12220. scene: Scene;
  12221. /** @hidden */
  12222. private _spritePredicate;
  12223. /**
  12224. * Creates a new instance of the component for the given scene
  12225. * @param scene Defines the scene to register the component in
  12226. */
  12227. constructor(scene: Scene);
  12228. /**
  12229. * Registers the component in a given scene
  12230. */
  12231. register(): void;
  12232. /**
  12233. * Rebuilds the elements related to this component in case of
  12234. * context lost for instance.
  12235. */
  12236. rebuild(): void;
  12237. /**
  12238. * Disposes the component and the associated ressources.
  12239. */
  12240. dispose(): void;
  12241. private _pickSpriteButKeepRay;
  12242. private _pointerMove;
  12243. private _pointerDown;
  12244. private _pointerUp;
  12245. }
  12246. }
  12247. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12248. /** @hidden */
  12249. export var fogFragmentDeclaration: {
  12250. name: string;
  12251. shader: string;
  12252. };
  12253. }
  12254. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12255. /** @hidden */
  12256. export var fogFragment: {
  12257. name: string;
  12258. shader: string;
  12259. };
  12260. }
  12261. declare module "babylonjs/Shaders/sprites.fragment" {
  12262. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12263. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12264. /** @hidden */
  12265. export var spritesPixelShader: {
  12266. name: string;
  12267. shader: string;
  12268. };
  12269. }
  12270. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12271. /** @hidden */
  12272. export var fogVertexDeclaration: {
  12273. name: string;
  12274. shader: string;
  12275. };
  12276. }
  12277. declare module "babylonjs/Shaders/sprites.vertex" {
  12278. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12279. /** @hidden */
  12280. export var spritesVertexShader: {
  12281. name: string;
  12282. shader: string;
  12283. };
  12284. }
  12285. declare module "babylonjs/Sprites/spriteManager" {
  12286. import { IDisposable, Scene } from "babylonjs/scene";
  12287. import { Nullable } from "babylonjs/types";
  12288. import { Observable } from "babylonjs/Misc/observable";
  12289. import { Sprite } from "babylonjs/Sprites/sprite";
  12290. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12291. import { Camera } from "babylonjs/Cameras/camera";
  12292. import { Texture } from "babylonjs/Materials/Textures/texture";
  12293. import "babylonjs/Shaders/sprites.fragment";
  12294. import "babylonjs/Shaders/sprites.vertex";
  12295. import { Ray } from "babylonjs/Culling/ray";
  12296. /**
  12297. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12298. */
  12299. export interface ISpriteManager extends IDisposable {
  12300. /**
  12301. * Restricts the camera to viewing objects with the same layerMask.
  12302. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12303. */
  12304. layerMask: number;
  12305. /**
  12306. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12307. */
  12308. isPickable: boolean;
  12309. /**
  12310. * Specifies the rendering group id for this mesh (0 by default)
  12311. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12312. */
  12313. renderingGroupId: number;
  12314. /**
  12315. * Defines the list of sprites managed by the manager.
  12316. */
  12317. sprites: Array<Sprite>;
  12318. /**
  12319. * Tests the intersection of a sprite with a specific ray.
  12320. * @param ray The ray we are sending to test the collision
  12321. * @param camera The camera space we are sending rays in
  12322. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12323. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12324. * @returns picking info or null.
  12325. */
  12326. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12327. /**
  12328. * Renders the list of sprites on screen.
  12329. */
  12330. render(): void;
  12331. }
  12332. /**
  12333. * Class used to manage multiple sprites on the same spritesheet
  12334. * @see http://doc.babylonjs.com/babylon101/sprites
  12335. */
  12336. export class SpriteManager implements ISpriteManager {
  12337. /** defines the manager's name */
  12338. name: string;
  12339. /** Gets the list of sprites */
  12340. sprites: Sprite[];
  12341. /** Gets or sets the rendering group id (0 by default) */
  12342. renderingGroupId: number;
  12343. /** Gets or sets camera layer mask */
  12344. layerMask: number;
  12345. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12346. fogEnabled: boolean;
  12347. /** Gets or sets a boolean indicating if the sprites are pickable */
  12348. isPickable: boolean;
  12349. /** Defines the default width of a cell in the spritesheet */
  12350. cellWidth: number;
  12351. /** Defines the default height of a cell in the spritesheet */
  12352. cellHeight: number;
  12353. /**
  12354. * An event triggered when the manager is disposed.
  12355. */
  12356. onDisposeObservable: Observable<SpriteManager>;
  12357. private _onDisposeObserver;
  12358. /**
  12359. * Callback called when the manager is disposed
  12360. */
  12361. onDispose: () => void;
  12362. private _capacity;
  12363. private _spriteTexture;
  12364. private _epsilon;
  12365. private _scene;
  12366. private _vertexData;
  12367. private _buffer;
  12368. private _vertexBuffers;
  12369. private _indexBuffer;
  12370. private _effectBase;
  12371. private _effectFog;
  12372. /**
  12373. * Gets or sets the spritesheet texture
  12374. */
  12375. texture: Texture;
  12376. /**
  12377. * Creates a new sprite manager
  12378. * @param name defines the manager's name
  12379. * @param imgUrl defines the sprite sheet url
  12380. * @param capacity defines the maximum allowed number of sprites
  12381. * @param cellSize defines the size of a sprite cell
  12382. * @param scene defines the hosting scene
  12383. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12384. * @param samplingMode defines the smapling mode to use with spritesheet
  12385. */
  12386. constructor(
  12387. /** defines the manager's name */
  12388. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12389. private _appendSpriteVertex;
  12390. /**
  12391. * Intersects the sprites with a ray
  12392. * @param ray defines the ray to intersect with
  12393. * @param camera defines the current active camera
  12394. * @param predicate defines a predicate used to select candidate sprites
  12395. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12396. * @returns null if no hit or a PickingInfo
  12397. */
  12398. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12399. /**
  12400. * Render all child sprites
  12401. */
  12402. render(): void;
  12403. /**
  12404. * Release associated resources
  12405. */
  12406. dispose(): void;
  12407. }
  12408. }
  12409. declare module "babylonjs/Sprites/sprite" {
  12410. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12411. import { Nullable } from "babylonjs/types";
  12412. import { ActionManager } from "babylonjs/Actions/actionManager";
  12413. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12414. /**
  12415. * Class used to represent a sprite
  12416. * @see http://doc.babylonjs.com/babylon101/sprites
  12417. */
  12418. export class Sprite {
  12419. /** defines the name */
  12420. name: string;
  12421. /** Gets or sets the current world position */
  12422. position: Vector3;
  12423. /** Gets or sets the main color */
  12424. color: Color4;
  12425. /** Gets or sets the width */
  12426. width: number;
  12427. /** Gets or sets the height */
  12428. height: number;
  12429. /** Gets or sets rotation angle */
  12430. angle: number;
  12431. /** Gets or sets the cell index in the sprite sheet */
  12432. cellIndex: number;
  12433. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12434. invertU: number;
  12435. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12436. invertV: number;
  12437. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12438. disposeWhenFinishedAnimating: boolean;
  12439. /** Gets the list of attached animations */
  12440. animations: Animation[];
  12441. /** Gets or sets a boolean indicating if the sprite can be picked */
  12442. isPickable: boolean;
  12443. /**
  12444. * Gets or sets the associated action manager
  12445. */
  12446. actionManager: Nullable<ActionManager>;
  12447. private _animationStarted;
  12448. private _loopAnimation;
  12449. private _fromIndex;
  12450. private _toIndex;
  12451. private _delay;
  12452. private _direction;
  12453. private _manager;
  12454. private _time;
  12455. private _onAnimationEnd;
  12456. /**
  12457. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12458. */
  12459. isVisible: boolean;
  12460. /**
  12461. * Gets or sets the sprite size
  12462. */
  12463. size: number;
  12464. /**
  12465. * Creates a new Sprite
  12466. * @param name defines the name
  12467. * @param manager defines the manager
  12468. */
  12469. constructor(
  12470. /** defines the name */
  12471. name: string, manager: ISpriteManager);
  12472. /**
  12473. * Starts an animation
  12474. * @param from defines the initial key
  12475. * @param to defines the end key
  12476. * @param loop defines if the animation must loop
  12477. * @param delay defines the start delay (in ms)
  12478. * @param onAnimationEnd defines a callback to call when animation ends
  12479. */
  12480. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12481. /** Stops current animation (if any) */
  12482. stopAnimation(): void;
  12483. /** @hidden */
  12484. _animate(deltaTime: number): void;
  12485. /** Release associated resources */
  12486. dispose(): void;
  12487. }
  12488. }
  12489. declare module "babylonjs/Collisions/pickingInfo" {
  12490. import { Nullable } from "babylonjs/types";
  12491. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12493. import { Sprite } from "babylonjs/Sprites/sprite";
  12494. import { Ray } from "babylonjs/Culling/ray";
  12495. /**
  12496. * Information about the result of picking within a scene
  12497. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12498. */
  12499. export class PickingInfo {
  12500. /** @hidden */
  12501. _pickingUnavailable: boolean;
  12502. /**
  12503. * If the pick collided with an object
  12504. */
  12505. hit: boolean;
  12506. /**
  12507. * Distance away where the pick collided
  12508. */
  12509. distance: number;
  12510. /**
  12511. * The location of pick collision
  12512. */
  12513. pickedPoint: Nullable<Vector3>;
  12514. /**
  12515. * The mesh corresponding the the pick collision
  12516. */
  12517. pickedMesh: Nullable<AbstractMesh>;
  12518. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12519. bu: number;
  12520. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12521. bv: number;
  12522. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12523. faceId: number;
  12524. /** Id of the the submesh that was picked */
  12525. subMeshId: number;
  12526. /** If a sprite was picked, this will be the sprite the pick collided with */
  12527. pickedSprite: Nullable<Sprite>;
  12528. /**
  12529. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12530. */
  12531. originMesh: Nullable<AbstractMesh>;
  12532. /**
  12533. * The ray that was used to perform the picking.
  12534. */
  12535. ray: Nullable<Ray>;
  12536. /**
  12537. * Gets the normal correspodning to the face the pick collided with
  12538. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12539. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12540. * @returns The normal correspodning to the face the pick collided with
  12541. */
  12542. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12543. /**
  12544. * Gets the texture coordinates of where the pick occured
  12545. * @returns the vector containing the coordnates of the texture
  12546. */
  12547. getTextureCoordinates(): Nullable<Vector2>;
  12548. }
  12549. }
  12550. declare module "babylonjs/Events/pointerEvents" {
  12551. import { Nullable } from "babylonjs/types";
  12552. import { Vector2 } from "babylonjs/Maths/math";
  12553. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12554. import { Ray } from "babylonjs/Culling/ray";
  12555. /**
  12556. * Gather the list of pointer event types as constants.
  12557. */
  12558. export class PointerEventTypes {
  12559. /**
  12560. * 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.
  12561. */
  12562. static readonly POINTERDOWN: number;
  12563. /**
  12564. * The pointerup event is fired when a pointer is no longer active.
  12565. */
  12566. static readonly POINTERUP: number;
  12567. /**
  12568. * The pointermove event is fired when a pointer changes coordinates.
  12569. */
  12570. static readonly POINTERMOVE: number;
  12571. /**
  12572. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12573. */
  12574. static readonly POINTERWHEEL: number;
  12575. /**
  12576. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12577. */
  12578. static readonly POINTERPICK: number;
  12579. /**
  12580. * The pointertap event is fired when a the object has been touched and released without drag.
  12581. */
  12582. static readonly POINTERTAP: number;
  12583. /**
  12584. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12585. */
  12586. static readonly POINTERDOUBLETAP: number;
  12587. }
  12588. /**
  12589. * Base class of pointer info types.
  12590. */
  12591. export class PointerInfoBase {
  12592. /**
  12593. * Defines the type of event (PointerEventTypes)
  12594. */
  12595. type: number;
  12596. /**
  12597. * Defines the related dom event
  12598. */
  12599. event: PointerEvent | MouseWheelEvent;
  12600. /**
  12601. * Instantiates the base class of pointers info.
  12602. * @param type Defines the type of event (PointerEventTypes)
  12603. * @param event Defines the related dom event
  12604. */
  12605. constructor(
  12606. /**
  12607. * Defines the type of event (PointerEventTypes)
  12608. */
  12609. type: number,
  12610. /**
  12611. * Defines the related dom event
  12612. */
  12613. event: PointerEvent | MouseWheelEvent);
  12614. }
  12615. /**
  12616. * This class is used to store pointer related info for the onPrePointerObservable event.
  12617. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12618. */
  12619. export class PointerInfoPre extends PointerInfoBase {
  12620. /**
  12621. * Ray from a pointer if availible (eg. 6dof controller)
  12622. */
  12623. ray: Nullable<Ray>;
  12624. /**
  12625. * Defines the local position of the pointer on the canvas.
  12626. */
  12627. localPosition: Vector2;
  12628. /**
  12629. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12630. */
  12631. skipOnPointerObservable: boolean;
  12632. /**
  12633. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12634. * @param type Defines the type of event (PointerEventTypes)
  12635. * @param event Defines the related dom event
  12636. * @param localX Defines the local x coordinates of the pointer when the event occured
  12637. * @param localY Defines the local y coordinates of the pointer when the event occured
  12638. */
  12639. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12640. }
  12641. /**
  12642. * This type contains all the data related to a pointer event in Babylon.js.
  12643. * 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.
  12644. */
  12645. export class PointerInfo extends PointerInfoBase {
  12646. /**
  12647. * Defines the picking info associated to the info (if any)\
  12648. */
  12649. pickInfo: Nullable<PickingInfo>;
  12650. /**
  12651. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12652. * @param type Defines the type of event (PointerEventTypes)
  12653. * @param event Defines the related dom event
  12654. * @param pickInfo Defines the picking info associated to the info (if any)\
  12655. */
  12656. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12657. /**
  12658. * Defines the picking info associated to the info (if any)\
  12659. */
  12660. pickInfo: Nullable<PickingInfo>);
  12661. }
  12662. /**
  12663. * Data relating to a touch event on the screen.
  12664. */
  12665. export interface PointerTouch {
  12666. /**
  12667. * X coordinate of touch.
  12668. */
  12669. x: number;
  12670. /**
  12671. * Y coordinate of touch.
  12672. */
  12673. y: number;
  12674. /**
  12675. * Id of touch. Unique for each finger.
  12676. */
  12677. pointerId: number;
  12678. /**
  12679. * Event type passed from DOM.
  12680. */
  12681. type: any;
  12682. }
  12683. }
  12684. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12685. import { Observable } from "babylonjs/Misc/observable";
  12686. import { Nullable } from "babylonjs/types";
  12687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12688. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12689. /**
  12690. * Manage the mouse inputs to control the movement of a free camera.
  12691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12692. */
  12693. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12694. /**
  12695. * Define if touch is enabled in the mouse input
  12696. */
  12697. touchEnabled: boolean;
  12698. /**
  12699. * Defines the camera the input is attached to.
  12700. */
  12701. camera: FreeCamera;
  12702. /**
  12703. * Defines the buttons associated with the input to handle camera move.
  12704. */
  12705. buttons: number[];
  12706. /**
  12707. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12708. */
  12709. angularSensibility: number;
  12710. private _pointerInput;
  12711. private _onMouseMove;
  12712. private _observer;
  12713. private previousPosition;
  12714. /**
  12715. * Observable for when a pointer move event occurs containing the move offset
  12716. */
  12717. onPointerMovedObservable: Observable<{
  12718. offsetX: number;
  12719. offsetY: number;
  12720. }>;
  12721. /**
  12722. * @hidden
  12723. * If the camera should be rotated automatically based on pointer movement
  12724. */
  12725. _allowCameraRotation: boolean;
  12726. /**
  12727. * Manage the mouse inputs to control the movement of a free camera.
  12728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12729. * @param touchEnabled Defines if touch is enabled or not
  12730. */
  12731. constructor(
  12732. /**
  12733. * Define if touch is enabled in the mouse input
  12734. */
  12735. touchEnabled?: boolean);
  12736. /**
  12737. * Attach the input controls to a specific dom element to get the input from.
  12738. * @param element Defines the element the controls should be listened from
  12739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12740. */
  12741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12742. /**
  12743. * Called on JS contextmenu event.
  12744. * Override this method to provide functionality.
  12745. */
  12746. protected onContextMenu(evt: PointerEvent): void;
  12747. /**
  12748. * Detach the current controls from the specified dom element.
  12749. * @param element Defines the element to stop listening the inputs from
  12750. */
  12751. detachControl(element: Nullable<HTMLElement>): void;
  12752. /**
  12753. * Gets the class name of the current intput.
  12754. * @returns the class name
  12755. */
  12756. getClassName(): string;
  12757. /**
  12758. * Get the friendly name associated with the input class.
  12759. * @returns the input friendly name
  12760. */
  12761. getSimpleName(): string;
  12762. }
  12763. }
  12764. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12765. import { Nullable } from "babylonjs/types";
  12766. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12767. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12768. /**
  12769. * Manage the touch inputs to control the movement of a free camera.
  12770. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12771. */
  12772. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12773. /**
  12774. * Defines the camera the input is attached to.
  12775. */
  12776. camera: FreeCamera;
  12777. /**
  12778. * Defines the touch sensibility for rotation.
  12779. * The higher the faster.
  12780. */
  12781. touchAngularSensibility: number;
  12782. /**
  12783. * Defines the touch sensibility for move.
  12784. * The higher the faster.
  12785. */
  12786. touchMoveSensibility: number;
  12787. private _offsetX;
  12788. private _offsetY;
  12789. private _pointerPressed;
  12790. private _pointerInput;
  12791. private _observer;
  12792. private _onLostFocus;
  12793. /**
  12794. * Attach the input controls to a specific dom element to get the input from.
  12795. * @param element Defines the element the controls should be listened from
  12796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12797. */
  12798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12799. /**
  12800. * Detach the current controls from the specified dom element.
  12801. * @param element Defines the element to stop listening the inputs from
  12802. */
  12803. detachControl(element: Nullable<HTMLElement>): void;
  12804. /**
  12805. * Update the current camera state depending on the inputs that have been used this frame.
  12806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12807. */
  12808. checkInputs(): void;
  12809. /**
  12810. * Gets the class name of the current intput.
  12811. * @returns the class name
  12812. */
  12813. getClassName(): string;
  12814. /**
  12815. * Get the friendly name associated with the input class.
  12816. * @returns the input friendly name
  12817. */
  12818. getSimpleName(): string;
  12819. }
  12820. }
  12821. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12822. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12823. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12824. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12825. import { Nullable } from "babylonjs/types";
  12826. /**
  12827. * Default Inputs manager for the FreeCamera.
  12828. * It groups all the default supported inputs for ease of use.
  12829. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12830. */
  12831. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12832. /**
  12833. * @hidden
  12834. */
  12835. _mouseInput: Nullable<FreeCameraMouseInput>;
  12836. /**
  12837. * Instantiates a new FreeCameraInputsManager.
  12838. * @param camera Defines the camera the inputs belong to
  12839. */
  12840. constructor(camera: FreeCamera);
  12841. /**
  12842. * Add keyboard input support to the input manager.
  12843. * @returns the current input manager
  12844. */
  12845. addKeyboard(): FreeCameraInputsManager;
  12846. /**
  12847. * Add mouse input support to the input manager.
  12848. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12849. * @returns the current input manager
  12850. */
  12851. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12852. /**
  12853. * Removes the mouse input support from the manager
  12854. * @returns the current input manager
  12855. */
  12856. removeMouse(): FreeCameraInputsManager;
  12857. /**
  12858. * Add touch input support to the input manager.
  12859. * @returns the current input manager
  12860. */
  12861. addTouch(): FreeCameraInputsManager;
  12862. /**
  12863. * Remove all attached input methods from a camera
  12864. */
  12865. clear(): void;
  12866. }
  12867. }
  12868. declare module "babylonjs/Cameras/freeCamera" {
  12869. import { Vector3 } from "babylonjs/Maths/math";
  12870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12871. import { Scene } from "babylonjs/scene";
  12872. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12873. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12874. /**
  12875. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12876. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12877. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12878. */
  12879. export class FreeCamera extends TargetCamera {
  12880. /**
  12881. * Define the collision ellipsoid of the camera.
  12882. * This is helpful to simulate a camera body like the player body around the camera
  12883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12884. */
  12885. ellipsoid: Vector3;
  12886. /**
  12887. * Define an offset for the position of the ellipsoid around the camera.
  12888. * This can be helpful to determine the center of the body near the gravity center of the body
  12889. * instead of its head.
  12890. */
  12891. ellipsoidOffset: Vector3;
  12892. /**
  12893. * Enable or disable collisions of the camera with the rest of the scene objects.
  12894. */
  12895. checkCollisions: boolean;
  12896. /**
  12897. * Enable or disable gravity on the camera.
  12898. */
  12899. applyGravity: boolean;
  12900. /**
  12901. * Define the input manager associated to the camera.
  12902. */
  12903. inputs: FreeCameraInputsManager;
  12904. /**
  12905. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12906. * Higher values reduce sensitivity.
  12907. */
  12908. /**
  12909. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12910. * Higher values reduce sensitivity.
  12911. */
  12912. angularSensibility: number;
  12913. /**
  12914. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12915. */
  12916. keysUp: number[];
  12917. /**
  12918. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12919. */
  12920. keysDown: number[];
  12921. /**
  12922. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12923. */
  12924. keysLeft: number[];
  12925. /**
  12926. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12927. */
  12928. keysRight: number[];
  12929. /**
  12930. * Event raised when the camera collide with a mesh in the scene.
  12931. */
  12932. onCollide: (collidedMesh: AbstractMesh) => void;
  12933. private _collider;
  12934. private _needMoveForGravity;
  12935. private _oldPosition;
  12936. private _diffPosition;
  12937. private _newPosition;
  12938. /** @hidden */
  12939. _localDirection: Vector3;
  12940. /** @hidden */
  12941. _transformedDirection: Vector3;
  12942. /**
  12943. * Instantiates a Free Camera.
  12944. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12945. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12946. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12947. * @param name Define the name of the camera in the scene
  12948. * @param position Define the start position of the camera in the scene
  12949. * @param scene Define the scene the camera belongs to
  12950. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12951. */
  12952. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12953. /**
  12954. * Attached controls to the current camera.
  12955. * @param element Defines the element the controls should be listened from
  12956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12957. */
  12958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12959. /**
  12960. * Detach the current controls from the camera.
  12961. * The camera will stop reacting to inputs.
  12962. * @param element Defines the element to stop listening the inputs from
  12963. */
  12964. detachControl(element: HTMLElement): void;
  12965. private _collisionMask;
  12966. /**
  12967. * Define a collision mask to limit the list of object the camera can collide with
  12968. */
  12969. collisionMask: number;
  12970. /** @hidden */
  12971. _collideWithWorld(displacement: Vector3): void;
  12972. private _onCollisionPositionChange;
  12973. /** @hidden */
  12974. _checkInputs(): void;
  12975. /** @hidden */
  12976. _decideIfNeedsToMove(): boolean;
  12977. /** @hidden */
  12978. _updatePosition(): void;
  12979. /**
  12980. * Destroy the camera and release the current resources hold by it.
  12981. */
  12982. dispose(): void;
  12983. /**
  12984. * Gets the current object class name.
  12985. * @return the class name
  12986. */
  12987. getClassName(): string;
  12988. }
  12989. }
  12990. declare module "babylonjs/Gamepads/gamepad" {
  12991. import { Observable } from "babylonjs/Misc/observable";
  12992. /**
  12993. * Represents a gamepad control stick position
  12994. */
  12995. export class StickValues {
  12996. /**
  12997. * The x component of the control stick
  12998. */
  12999. x: number;
  13000. /**
  13001. * The y component of the control stick
  13002. */
  13003. y: number;
  13004. /**
  13005. * Initializes the gamepad x and y control stick values
  13006. * @param x The x component of the gamepad control stick value
  13007. * @param y The y component of the gamepad control stick value
  13008. */
  13009. constructor(
  13010. /**
  13011. * The x component of the control stick
  13012. */
  13013. x: number,
  13014. /**
  13015. * The y component of the control stick
  13016. */
  13017. y: number);
  13018. }
  13019. /**
  13020. * An interface which manages callbacks for gamepad button changes
  13021. */
  13022. export interface GamepadButtonChanges {
  13023. /**
  13024. * Called when a gamepad has been changed
  13025. */
  13026. changed: boolean;
  13027. /**
  13028. * Called when a gamepad press event has been triggered
  13029. */
  13030. pressChanged: boolean;
  13031. /**
  13032. * Called when a touch event has been triggered
  13033. */
  13034. touchChanged: boolean;
  13035. /**
  13036. * Called when a value has changed
  13037. */
  13038. valueChanged: boolean;
  13039. }
  13040. /**
  13041. * Represents a gamepad
  13042. */
  13043. export class Gamepad {
  13044. /**
  13045. * The id of the gamepad
  13046. */
  13047. id: string;
  13048. /**
  13049. * The index of the gamepad
  13050. */
  13051. index: number;
  13052. /**
  13053. * The browser gamepad
  13054. */
  13055. browserGamepad: any;
  13056. /**
  13057. * Specifies what type of gamepad this represents
  13058. */
  13059. type: number;
  13060. private _leftStick;
  13061. private _rightStick;
  13062. /** @hidden */
  13063. _isConnected: boolean;
  13064. private _leftStickAxisX;
  13065. private _leftStickAxisY;
  13066. private _rightStickAxisX;
  13067. private _rightStickAxisY;
  13068. /**
  13069. * Triggered when the left control stick has been changed
  13070. */
  13071. private _onleftstickchanged;
  13072. /**
  13073. * Triggered when the right control stick has been changed
  13074. */
  13075. private _onrightstickchanged;
  13076. /**
  13077. * Represents a gamepad controller
  13078. */
  13079. static GAMEPAD: number;
  13080. /**
  13081. * Represents a generic controller
  13082. */
  13083. static GENERIC: number;
  13084. /**
  13085. * Represents an XBox controller
  13086. */
  13087. static XBOX: number;
  13088. /**
  13089. * Represents a pose-enabled controller
  13090. */
  13091. static POSE_ENABLED: number;
  13092. /**
  13093. * Specifies whether the left control stick should be Y-inverted
  13094. */
  13095. protected _invertLeftStickY: boolean;
  13096. /**
  13097. * Specifies if the gamepad has been connected
  13098. */
  13099. readonly isConnected: boolean;
  13100. /**
  13101. * Initializes the gamepad
  13102. * @param id The id of the gamepad
  13103. * @param index The index of the gamepad
  13104. * @param browserGamepad The browser gamepad
  13105. * @param leftStickX The x component of the left joystick
  13106. * @param leftStickY The y component of the left joystick
  13107. * @param rightStickX The x component of the right joystick
  13108. * @param rightStickY The y component of the right joystick
  13109. */
  13110. constructor(
  13111. /**
  13112. * The id of the gamepad
  13113. */
  13114. id: string,
  13115. /**
  13116. * The index of the gamepad
  13117. */
  13118. index: number,
  13119. /**
  13120. * The browser gamepad
  13121. */
  13122. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  13123. /**
  13124. * Callback triggered when the left joystick has changed
  13125. * @param callback
  13126. */
  13127. onleftstickchanged(callback: (values: StickValues) => void): void;
  13128. /**
  13129. * Callback triggered when the right joystick has changed
  13130. * @param callback
  13131. */
  13132. onrightstickchanged(callback: (values: StickValues) => void): void;
  13133. /**
  13134. * Gets the left joystick
  13135. */
  13136. /**
  13137. * Sets the left joystick values
  13138. */
  13139. leftStick: StickValues;
  13140. /**
  13141. * Gets the right joystick
  13142. */
  13143. /**
  13144. * Sets the right joystick value
  13145. */
  13146. rightStick: StickValues;
  13147. /**
  13148. * Updates the gamepad joystick positions
  13149. */
  13150. update(): void;
  13151. /**
  13152. * Disposes the gamepad
  13153. */
  13154. dispose(): void;
  13155. }
  13156. /**
  13157. * Represents a generic gamepad
  13158. */
  13159. export class GenericPad extends Gamepad {
  13160. private _buttons;
  13161. private _onbuttondown;
  13162. private _onbuttonup;
  13163. /**
  13164. * Observable triggered when a button has been pressed
  13165. */
  13166. onButtonDownObservable: Observable<number>;
  13167. /**
  13168. * Observable triggered when a button has been released
  13169. */
  13170. onButtonUpObservable: Observable<number>;
  13171. /**
  13172. * Callback triggered when a button has been pressed
  13173. * @param callback Called when a button has been pressed
  13174. */
  13175. onbuttondown(callback: (buttonPressed: number) => void): void;
  13176. /**
  13177. * Callback triggered when a button has been released
  13178. * @param callback Called when a button has been released
  13179. */
  13180. onbuttonup(callback: (buttonReleased: number) => void): void;
  13181. /**
  13182. * Initializes the generic gamepad
  13183. * @param id The id of the generic gamepad
  13184. * @param index The index of the generic gamepad
  13185. * @param browserGamepad The browser gamepad
  13186. */
  13187. constructor(id: string, index: number, browserGamepad: any);
  13188. private _setButtonValue;
  13189. /**
  13190. * Updates the generic gamepad
  13191. */
  13192. update(): void;
  13193. /**
  13194. * Disposes the generic gamepad
  13195. */
  13196. dispose(): void;
  13197. }
  13198. }
  13199. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  13200. import { Observable } from "babylonjs/Misc/observable";
  13201. import { Nullable } from "babylonjs/types";
  13202. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13205. import { Ray } from "babylonjs/Culling/ray";
  13206. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  13207. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  13208. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  13209. /**
  13210. * Defines the types of pose enabled controllers that are supported
  13211. */
  13212. export enum PoseEnabledControllerType {
  13213. /**
  13214. * HTC Vive
  13215. */
  13216. VIVE = 0,
  13217. /**
  13218. * Oculus Rift
  13219. */
  13220. OCULUS = 1,
  13221. /**
  13222. * Windows mixed reality
  13223. */
  13224. WINDOWS = 2,
  13225. /**
  13226. * Samsung gear VR
  13227. */
  13228. GEAR_VR = 3,
  13229. /**
  13230. * Google Daydream
  13231. */
  13232. DAYDREAM = 4,
  13233. /**
  13234. * Generic
  13235. */
  13236. GENERIC = 5
  13237. }
  13238. /**
  13239. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13240. */
  13241. export interface MutableGamepadButton {
  13242. /**
  13243. * Value of the button/trigger
  13244. */
  13245. value: number;
  13246. /**
  13247. * If the button/trigger is currently touched
  13248. */
  13249. touched: boolean;
  13250. /**
  13251. * If the button/trigger is currently pressed
  13252. */
  13253. pressed: boolean;
  13254. }
  13255. /**
  13256. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13257. * @hidden
  13258. */
  13259. export interface ExtendedGamepadButton extends GamepadButton {
  13260. /**
  13261. * If the button/trigger is currently pressed
  13262. */
  13263. readonly pressed: boolean;
  13264. /**
  13265. * If the button/trigger is currently touched
  13266. */
  13267. readonly touched: boolean;
  13268. /**
  13269. * Value of the button/trigger
  13270. */
  13271. readonly value: number;
  13272. }
  13273. /** @hidden */
  13274. export interface _GamePadFactory {
  13275. /**
  13276. * Returns wether or not the current gamepad can be created for this type of controller.
  13277. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13278. * @returns true if it can be created, otherwise false
  13279. */
  13280. canCreate(gamepadInfo: any): boolean;
  13281. /**
  13282. * Creates a new instance of the Gamepad.
  13283. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13284. * @returns the new gamepad instance
  13285. */
  13286. create(gamepadInfo: any): Gamepad;
  13287. }
  13288. /**
  13289. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13290. */
  13291. export class PoseEnabledControllerHelper {
  13292. /** @hidden */
  13293. static _ControllerFactories: _GamePadFactory[];
  13294. /** @hidden */
  13295. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13296. /**
  13297. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13298. * @param vrGamepad the gamepad to initialized
  13299. * @returns a vr controller of the type the gamepad identified as
  13300. */
  13301. static InitiateController(vrGamepad: any): Gamepad;
  13302. }
  13303. /**
  13304. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13305. */
  13306. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13307. private _deviceRoomPosition;
  13308. private _deviceRoomRotationQuaternion;
  13309. /**
  13310. * The device position in babylon space
  13311. */
  13312. devicePosition: Vector3;
  13313. /**
  13314. * The device rotation in babylon space
  13315. */
  13316. deviceRotationQuaternion: Quaternion;
  13317. /**
  13318. * The scale factor of the device in babylon space
  13319. */
  13320. deviceScaleFactor: number;
  13321. /**
  13322. * (Likely devicePosition should be used instead) The device position in its room space
  13323. */
  13324. position: Vector3;
  13325. /**
  13326. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13327. */
  13328. rotationQuaternion: Quaternion;
  13329. /**
  13330. * The type of controller (Eg. Windows mixed reality)
  13331. */
  13332. controllerType: PoseEnabledControllerType;
  13333. protected _calculatedPosition: Vector3;
  13334. private _calculatedRotation;
  13335. /**
  13336. * The raw pose from the device
  13337. */
  13338. rawPose: DevicePose;
  13339. private _trackPosition;
  13340. private _maxRotationDistFromHeadset;
  13341. private _draggedRoomRotation;
  13342. /**
  13343. * @hidden
  13344. */
  13345. _disableTrackPosition(fixedPosition: Vector3): void;
  13346. /**
  13347. * Internal, the mesh attached to the controller
  13348. * @hidden
  13349. */
  13350. _mesh: Nullable<AbstractMesh>;
  13351. private _poseControlledCamera;
  13352. private _leftHandSystemQuaternion;
  13353. /**
  13354. * Internal, matrix used to convert room space to babylon space
  13355. * @hidden
  13356. */
  13357. _deviceToWorld: Matrix;
  13358. /**
  13359. * Node to be used when casting a ray from the controller
  13360. * @hidden
  13361. */
  13362. _pointingPoseNode: Nullable<TransformNode>;
  13363. /**
  13364. * Name of the child mesh that can be used to cast a ray from the controller
  13365. */
  13366. static readonly POINTING_POSE: string;
  13367. /**
  13368. * Creates a new PoseEnabledController from a gamepad
  13369. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13370. */
  13371. constructor(browserGamepad: any);
  13372. private _workingMatrix;
  13373. /**
  13374. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13375. */
  13376. update(): void;
  13377. /**
  13378. * Updates only the pose device and mesh without doing any button event checking
  13379. */
  13380. protected _updatePoseAndMesh(): void;
  13381. /**
  13382. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13383. * @param poseData raw pose fromthe device
  13384. */
  13385. updateFromDevice(poseData: DevicePose): void;
  13386. /**
  13387. * @hidden
  13388. */
  13389. _meshAttachedObservable: Observable<AbstractMesh>;
  13390. /**
  13391. * Attaches a mesh to the controller
  13392. * @param mesh the mesh to be attached
  13393. */
  13394. attachToMesh(mesh: AbstractMesh): void;
  13395. /**
  13396. * Attaches the controllers mesh to a camera
  13397. * @param camera the camera the mesh should be attached to
  13398. */
  13399. attachToPoseControlledCamera(camera: TargetCamera): void;
  13400. /**
  13401. * Disposes of the controller
  13402. */
  13403. dispose(): void;
  13404. /**
  13405. * The mesh that is attached to the controller
  13406. */
  13407. readonly mesh: Nullable<AbstractMesh>;
  13408. /**
  13409. * Gets the ray of the controller in the direction the controller is pointing
  13410. * @param length the length the resulting ray should be
  13411. * @returns a ray in the direction the controller is pointing
  13412. */
  13413. getForwardRay(length?: number): Ray;
  13414. }
  13415. }
  13416. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13417. import { Observable } from "babylonjs/Misc/observable";
  13418. import { Scene } from "babylonjs/scene";
  13419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13420. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13421. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13422. /**
  13423. * Defines the WebVRController object that represents controllers tracked in 3D space
  13424. */
  13425. export abstract class WebVRController extends PoseEnabledController {
  13426. /**
  13427. * Internal, the default controller model for the controller
  13428. */
  13429. protected _defaultModel: AbstractMesh;
  13430. /**
  13431. * Fired when the trigger state has changed
  13432. */
  13433. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13434. /**
  13435. * Fired when the main button state has changed
  13436. */
  13437. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13438. /**
  13439. * Fired when the secondary button state has changed
  13440. */
  13441. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13442. /**
  13443. * Fired when the pad state has changed
  13444. */
  13445. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13446. /**
  13447. * Fired when controllers stick values have changed
  13448. */
  13449. onPadValuesChangedObservable: Observable<StickValues>;
  13450. /**
  13451. * Array of button availible on the controller
  13452. */
  13453. protected _buttons: Array<MutableGamepadButton>;
  13454. private _onButtonStateChange;
  13455. /**
  13456. * Fired when a controller button's state has changed
  13457. * @param callback the callback containing the button that was modified
  13458. */
  13459. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13460. /**
  13461. * X and Y axis corrisponding to the controllers joystick
  13462. */
  13463. pad: StickValues;
  13464. /**
  13465. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13466. */
  13467. hand: string;
  13468. /**
  13469. * The default controller model for the controller
  13470. */
  13471. readonly defaultModel: AbstractMesh;
  13472. /**
  13473. * Creates a new WebVRController from a gamepad
  13474. * @param vrGamepad the gamepad that the WebVRController should be created from
  13475. */
  13476. constructor(vrGamepad: any);
  13477. /**
  13478. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13479. */
  13480. update(): void;
  13481. /**
  13482. * Function to be called when a button is modified
  13483. */
  13484. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13485. /**
  13486. * Loads a mesh and attaches it to the controller
  13487. * @param scene the scene the mesh should be added to
  13488. * @param meshLoaded callback for when the mesh has been loaded
  13489. */
  13490. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13491. private _setButtonValue;
  13492. private _changes;
  13493. private _checkChanges;
  13494. /**
  13495. * Disposes of th webVRCOntroller
  13496. */
  13497. dispose(): void;
  13498. }
  13499. }
  13500. declare module "babylonjs/Lights/hemisphericLight" {
  13501. import { Nullable } from "babylonjs/types";
  13502. import { Scene } from "babylonjs/scene";
  13503. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13504. import { Effect } from "babylonjs/Materials/effect";
  13505. import { Light } from "babylonjs/Lights/light";
  13506. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13507. /**
  13508. * The HemisphericLight simulates the ambient environment light,
  13509. * so the passed direction is the light reflection direction, not the incoming direction.
  13510. */
  13511. export class HemisphericLight extends Light {
  13512. /**
  13513. * The groundColor is the light in the opposite direction to the one specified during creation.
  13514. * 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.
  13515. */
  13516. groundColor: Color3;
  13517. /**
  13518. * The light reflection direction, not the incoming direction.
  13519. */
  13520. direction: Vector3;
  13521. /**
  13522. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13523. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13524. * The HemisphericLight can't cast shadows.
  13525. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13526. * @param name The friendly name of the light
  13527. * @param direction The direction of the light reflection
  13528. * @param scene The scene the light belongs to
  13529. */
  13530. constructor(name: string, direction: Vector3, scene: Scene);
  13531. protected _buildUniformLayout(): void;
  13532. /**
  13533. * Returns the string "HemisphericLight".
  13534. * @return The class name
  13535. */
  13536. getClassName(): string;
  13537. /**
  13538. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13539. * Returns the updated direction.
  13540. * @param target The target the direction should point to
  13541. * @return The computed direction
  13542. */
  13543. setDirectionToTarget(target: Vector3): Vector3;
  13544. /**
  13545. * Returns the shadow generator associated to the light.
  13546. * @returns Always null for hemispheric lights because it does not support shadows.
  13547. */
  13548. getShadowGenerator(): Nullable<IShadowGenerator>;
  13549. /**
  13550. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13551. * @param effect The effect to update
  13552. * @param lightIndex The index of the light in the effect to update
  13553. * @returns The hemispheric light
  13554. */
  13555. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13556. /**
  13557. * Computes the world matrix of the node
  13558. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13559. * @param useWasUpdatedFlag defines a reserved property
  13560. * @returns the world matrix
  13561. */
  13562. computeWorldMatrix(): Matrix;
  13563. /**
  13564. * Returns the integer 3.
  13565. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13566. */
  13567. getTypeID(): number;
  13568. /**
  13569. * Prepares the list of defines specific to the light type.
  13570. * @param defines the list of defines
  13571. * @param lightIndex defines the index of the light for the effect
  13572. */
  13573. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13574. }
  13575. }
  13576. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13577. /** @hidden */
  13578. export var vrMultiviewToSingleviewPixelShader: {
  13579. name: string;
  13580. shader: string;
  13581. };
  13582. }
  13583. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13585. import { Scene } from "babylonjs/scene";
  13586. /**
  13587. * Renders to multiple views with a single draw call
  13588. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13589. */
  13590. export class MultiviewRenderTarget extends RenderTargetTexture {
  13591. /**
  13592. * Creates a multiview render target
  13593. * @param scene scene used with the render target
  13594. * @param size the size of the render target (used for each view)
  13595. */
  13596. constructor(scene: Scene, size?: number | {
  13597. width: number;
  13598. height: number;
  13599. } | {
  13600. ratio: number;
  13601. });
  13602. /**
  13603. * @hidden
  13604. * @param faceIndex the face index, if its a cube texture
  13605. */
  13606. _bindFrameBuffer(faceIndex?: number): void;
  13607. /**
  13608. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13609. * @returns the view count
  13610. */
  13611. getViewCount(): number;
  13612. }
  13613. }
  13614. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13615. import { Camera } from "babylonjs/Cameras/camera";
  13616. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13617. import { Nullable } from "babylonjs/types";
  13618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13619. import { Matrix } from "babylonjs/Maths/math";
  13620. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13621. module "babylonjs/Engines/engine" {
  13622. interface Engine {
  13623. /**
  13624. * Creates a new multiview render target
  13625. * @param width defines the width of the texture
  13626. * @param height defines the height of the texture
  13627. * @returns the created multiview texture
  13628. */
  13629. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13630. /**
  13631. * Binds a multiview framebuffer to be drawn to
  13632. * @param multiviewTexture texture to bind
  13633. */
  13634. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13635. }
  13636. }
  13637. module "babylonjs/Cameras/camera" {
  13638. interface Camera {
  13639. /**
  13640. * @hidden
  13641. * 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)
  13642. */
  13643. _useMultiviewToSingleView: boolean;
  13644. /**
  13645. * @hidden
  13646. * 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)
  13647. */
  13648. _multiviewTexture: Nullable<RenderTargetTexture>;
  13649. /**
  13650. * @hidden
  13651. * ensures the multiview texture of the camera exists and has the specified width/height
  13652. * @param width height to set on the multiview texture
  13653. * @param height width to set on the multiview texture
  13654. */
  13655. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13656. }
  13657. }
  13658. module "babylonjs/scene" {
  13659. interface Scene {
  13660. /** @hidden */
  13661. _transformMatrixR: Matrix;
  13662. /** @hidden */
  13663. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13664. /** @hidden */
  13665. _createMultiviewUbo(): void;
  13666. /** @hidden */
  13667. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13668. /** @hidden */
  13669. _renderMultiviewToSingleView(camera: Camera): void;
  13670. }
  13671. }
  13672. }
  13673. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13674. import { Camera } from "babylonjs/Cameras/camera";
  13675. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13676. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13677. import "babylonjs/Engines/Extensions/engine.multiview";
  13678. /**
  13679. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13680. * This will not be used for webXR as it supports displaying texture arrays directly
  13681. */
  13682. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13683. /**
  13684. * Initializes a VRMultiviewToSingleview
  13685. * @param name name of the post process
  13686. * @param camera camera to be applied to
  13687. * @param scaleFactor scaling factor to the size of the output texture
  13688. */
  13689. constructor(name: string, camera: Camera, scaleFactor: number);
  13690. }
  13691. }
  13692. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13693. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13694. import { Nullable } from "babylonjs/types";
  13695. import { Size } from "babylonjs/Maths/math";
  13696. import { Observable } from "babylonjs/Misc/observable";
  13697. module "babylonjs/Engines/engine" {
  13698. interface Engine {
  13699. /** @hidden */
  13700. _vrDisplay: any;
  13701. /** @hidden */
  13702. _vrSupported: boolean;
  13703. /** @hidden */
  13704. _oldSize: Size;
  13705. /** @hidden */
  13706. _oldHardwareScaleFactor: number;
  13707. /** @hidden */
  13708. _vrExclusivePointerMode: boolean;
  13709. /** @hidden */
  13710. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13711. /** @hidden */
  13712. _onVRDisplayPointerRestricted: () => void;
  13713. /** @hidden */
  13714. _onVRDisplayPointerUnrestricted: () => void;
  13715. /** @hidden */
  13716. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13717. /** @hidden */
  13718. _onVrDisplayDisconnect: Nullable<() => void>;
  13719. /** @hidden */
  13720. _onVrDisplayPresentChange: Nullable<() => void>;
  13721. /**
  13722. * Observable signaled when VR display mode changes
  13723. */
  13724. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13725. /**
  13726. * Observable signaled when VR request present is complete
  13727. */
  13728. onVRRequestPresentComplete: Observable<boolean>;
  13729. /**
  13730. * Observable signaled when VR request present starts
  13731. */
  13732. onVRRequestPresentStart: Observable<Engine>;
  13733. /**
  13734. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13735. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13736. */
  13737. isInVRExclusivePointerMode: boolean;
  13738. /**
  13739. * Gets a boolean indicating if a webVR device was detected
  13740. * @returns true if a webVR device was detected
  13741. */
  13742. isVRDevicePresent(): boolean;
  13743. /**
  13744. * Gets the current webVR device
  13745. * @returns the current webVR device (or null)
  13746. */
  13747. getVRDevice(): any;
  13748. /**
  13749. * Initializes a webVR display and starts listening to display change events
  13750. * The onVRDisplayChangedObservable will be notified upon these changes
  13751. * @returns A promise containing a VRDisplay and if vr is supported
  13752. */
  13753. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13754. /** @hidden */
  13755. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13756. /**
  13757. * Call this function to switch to webVR mode
  13758. * Will do nothing if webVR is not supported or if there is no webVR device
  13759. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13760. */
  13761. enableVR(): void;
  13762. /** @hidden */
  13763. _onVRFullScreenTriggered(): void;
  13764. }
  13765. }
  13766. }
  13767. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13768. import { Nullable } from "babylonjs/types";
  13769. import { Observable } from "babylonjs/Misc/observable";
  13770. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13771. import { Scene } from "babylonjs/scene";
  13772. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13773. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13774. import { Node } from "babylonjs/node";
  13775. import { Ray } from "babylonjs/Culling/ray";
  13776. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13777. import "babylonjs/Engines/Extensions/engine.webVR";
  13778. /**
  13779. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13780. * IMPORTANT!! The data is right-hand data.
  13781. * @export
  13782. * @interface DevicePose
  13783. */
  13784. export interface DevicePose {
  13785. /**
  13786. * The position of the device, values in array are [x,y,z].
  13787. */
  13788. readonly position: Nullable<Float32Array>;
  13789. /**
  13790. * The linearVelocity of the device, values in array are [x,y,z].
  13791. */
  13792. readonly linearVelocity: Nullable<Float32Array>;
  13793. /**
  13794. * The linearAcceleration of the device, values in array are [x,y,z].
  13795. */
  13796. readonly linearAcceleration: Nullable<Float32Array>;
  13797. /**
  13798. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13799. */
  13800. readonly orientation: Nullable<Float32Array>;
  13801. /**
  13802. * The angularVelocity of the device, values in array are [x,y,z].
  13803. */
  13804. readonly angularVelocity: Nullable<Float32Array>;
  13805. /**
  13806. * The angularAcceleration of the device, values in array are [x,y,z].
  13807. */
  13808. readonly angularAcceleration: Nullable<Float32Array>;
  13809. }
  13810. /**
  13811. * Interface representing a pose controlled object in Babylon.
  13812. * A pose controlled object has both regular pose values as well as pose values
  13813. * from an external device such as a VR head mounted display
  13814. */
  13815. export interface PoseControlled {
  13816. /**
  13817. * The position of the object in babylon space.
  13818. */
  13819. position: Vector3;
  13820. /**
  13821. * The rotation quaternion of the object in babylon space.
  13822. */
  13823. rotationQuaternion: Quaternion;
  13824. /**
  13825. * The position of the device in babylon space.
  13826. */
  13827. devicePosition?: Vector3;
  13828. /**
  13829. * The rotation quaternion of the device in babylon space.
  13830. */
  13831. deviceRotationQuaternion: Quaternion;
  13832. /**
  13833. * The raw pose coming from the device.
  13834. */
  13835. rawPose: Nullable<DevicePose>;
  13836. /**
  13837. * The scale of the device to be used when translating from device space to babylon space.
  13838. */
  13839. deviceScaleFactor: number;
  13840. /**
  13841. * Updates the poseControlled values based on the input device pose.
  13842. * @param poseData the pose data to update the object with
  13843. */
  13844. updateFromDevice(poseData: DevicePose): void;
  13845. }
  13846. /**
  13847. * Set of options to customize the webVRCamera
  13848. */
  13849. export interface WebVROptions {
  13850. /**
  13851. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13852. */
  13853. trackPosition?: boolean;
  13854. /**
  13855. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13856. */
  13857. positionScale?: number;
  13858. /**
  13859. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13860. */
  13861. displayName?: string;
  13862. /**
  13863. * Should the native controller meshes be initialized. (default: true)
  13864. */
  13865. controllerMeshes?: boolean;
  13866. /**
  13867. * Creating a default HemiLight only on controllers. (default: true)
  13868. */
  13869. defaultLightingOnControllers?: boolean;
  13870. /**
  13871. * If you don't want to use the default VR button of the helper. (default: false)
  13872. */
  13873. useCustomVRButton?: boolean;
  13874. /**
  13875. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13876. */
  13877. customVRButton?: HTMLButtonElement;
  13878. /**
  13879. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13880. */
  13881. rayLength?: number;
  13882. /**
  13883. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13884. */
  13885. defaultHeight?: number;
  13886. /**
  13887. * If multiview should be used if availible (default: false)
  13888. */
  13889. useMultiview?: boolean;
  13890. }
  13891. /**
  13892. * This represents a WebVR camera.
  13893. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13894. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13895. */
  13896. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13897. private webVROptions;
  13898. /**
  13899. * @hidden
  13900. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13901. */
  13902. _vrDevice: any;
  13903. /**
  13904. * The rawPose of the vrDevice.
  13905. */
  13906. rawPose: Nullable<DevicePose>;
  13907. private _onVREnabled;
  13908. private _specsVersion;
  13909. private _attached;
  13910. private _frameData;
  13911. protected _descendants: Array<Node>;
  13912. private _deviceRoomPosition;
  13913. /** @hidden */
  13914. _deviceRoomRotationQuaternion: Quaternion;
  13915. private _standingMatrix;
  13916. /**
  13917. * Represents device position in babylon space.
  13918. */
  13919. devicePosition: Vector3;
  13920. /**
  13921. * Represents device rotation in babylon space.
  13922. */
  13923. deviceRotationQuaternion: Quaternion;
  13924. /**
  13925. * The scale of the device to be used when translating from device space to babylon space.
  13926. */
  13927. deviceScaleFactor: number;
  13928. private _deviceToWorld;
  13929. private _worldToDevice;
  13930. /**
  13931. * References to the webVR controllers for the vrDevice.
  13932. */
  13933. controllers: Array<WebVRController>;
  13934. /**
  13935. * Emits an event when a controller is attached.
  13936. */
  13937. onControllersAttachedObservable: Observable<WebVRController[]>;
  13938. /**
  13939. * Emits an event when a controller's mesh has been loaded;
  13940. */
  13941. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13942. /**
  13943. * Emits an event when the HMD's pose has been updated.
  13944. */
  13945. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13946. private _poseSet;
  13947. /**
  13948. * If the rig cameras be used as parent instead of this camera.
  13949. */
  13950. rigParenting: boolean;
  13951. private _lightOnControllers;
  13952. private _defaultHeight?;
  13953. /**
  13954. * Instantiates a WebVRFreeCamera.
  13955. * @param name The name of the WebVRFreeCamera
  13956. * @param position The starting anchor position for the camera
  13957. * @param scene The scene the camera belongs to
  13958. * @param webVROptions a set of customizable options for the webVRCamera
  13959. */
  13960. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13961. /**
  13962. * Gets the device distance from the ground in meters.
  13963. * @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.
  13964. */
  13965. deviceDistanceToRoomGround(): number;
  13966. /**
  13967. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13968. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13969. */
  13970. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13971. /**
  13972. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13973. * @returns A promise with a boolean set to if the standing matrix is supported.
  13974. */
  13975. useStandingMatrixAsync(): Promise<boolean>;
  13976. /**
  13977. * Disposes the camera
  13978. */
  13979. dispose(): void;
  13980. /**
  13981. * Gets a vrController by name.
  13982. * @param name The name of the controller to retreive
  13983. * @returns the controller matching the name specified or null if not found
  13984. */
  13985. getControllerByName(name: string): Nullable<WebVRController>;
  13986. private _leftController;
  13987. /**
  13988. * The controller corrisponding to the users left hand.
  13989. */
  13990. readonly leftController: Nullable<WebVRController>;
  13991. private _rightController;
  13992. /**
  13993. * The controller corrisponding to the users right hand.
  13994. */
  13995. readonly rightController: Nullable<WebVRController>;
  13996. /**
  13997. * Casts a ray forward from the vrCamera's gaze.
  13998. * @param length Length of the ray (default: 100)
  13999. * @returns the ray corrisponding to the gaze
  14000. */
  14001. getForwardRay(length?: number): Ray;
  14002. /**
  14003. * @hidden
  14004. * Updates the camera based on device's frame data
  14005. */
  14006. _checkInputs(): void;
  14007. /**
  14008. * Updates the poseControlled values based on the input device pose.
  14009. * @param poseData Pose coming from the device
  14010. */
  14011. updateFromDevice(poseData: DevicePose): void;
  14012. private _htmlElementAttached;
  14013. private _detachIfAttached;
  14014. /**
  14015. * WebVR's attach control will start broadcasting frames to the device.
  14016. * Note that in certain browsers (chrome for example) this function must be called
  14017. * within a user-interaction callback. Example:
  14018. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14019. *
  14020. * @param element html element to attach the vrDevice to
  14021. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14022. */
  14023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14024. /**
  14025. * Detaches the camera from the html element and disables VR
  14026. *
  14027. * @param element html element to detach from
  14028. */
  14029. detachControl(element: HTMLElement): void;
  14030. /**
  14031. * @returns the name of this class
  14032. */
  14033. getClassName(): string;
  14034. /**
  14035. * Calls resetPose on the vrDisplay
  14036. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14037. */
  14038. resetToCurrentRotation(): void;
  14039. /**
  14040. * @hidden
  14041. * Updates the rig cameras (left and right eye)
  14042. */
  14043. _updateRigCameras(): void;
  14044. private _workingVector;
  14045. private _oneVector;
  14046. private _workingMatrix;
  14047. private updateCacheCalled;
  14048. private _correctPositionIfNotTrackPosition;
  14049. /**
  14050. * @hidden
  14051. * Updates the cached values of the camera
  14052. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14053. */
  14054. _updateCache(ignoreParentClass?: boolean): void;
  14055. /**
  14056. * @hidden
  14057. * Get current device position in babylon world
  14058. */
  14059. _computeDevicePosition(): void;
  14060. /**
  14061. * Updates the current device position and rotation in the babylon world
  14062. */
  14063. update(): void;
  14064. /**
  14065. * @hidden
  14066. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14067. * @returns an identity matrix
  14068. */
  14069. _getViewMatrix(): Matrix;
  14070. private _tmpMatrix;
  14071. /**
  14072. * This function is called by the two RIG cameras.
  14073. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14074. * @hidden
  14075. */
  14076. _getWebVRViewMatrix(): Matrix;
  14077. /** @hidden */
  14078. _getWebVRProjectionMatrix(): Matrix;
  14079. private _onGamepadConnectedObserver;
  14080. private _onGamepadDisconnectedObserver;
  14081. private _updateCacheWhenTrackingDisabledObserver;
  14082. /**
  14083. * Initializes the controllers and their meshes
  14084. */
  14085. initControllers(): void;
  14086. }
  14087. }
  14088. declare module "babylonjs/PostProcesses/postProcess" {
  14089. import { Nullable } from "babylonjs/types";
  14090. import { SmartArray } from "babylonjs/Misc/smartArray";
  14091. import { Observable } from "babylonjs/Misc/observable";
  14092. import { Color4, Vector2 } from "babylonjs/Maths/math";
  14093. import { Camera } from "babylonjs/Cameras/camera";
  14094. import { Effect } from "babylonjs/Materials/effect";
  14095. import "babylonjs/Shaders/postprocess.vertex";
  14096. import { IInspectable } from "babylonjs/Misc/iInspectable";
  14097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14098. import { Engine } from "babylonjs/Engines/engine";
  14099. /**
  14100. * Size options for a post process
  14101. */
  14102. export type PostProcessOptions = {
  14103. width: number;
  14104. height: number;
  14105. };
  14106. /**
  14107. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14109. */
  14110. export class PostProcess {
  14111. /** Name of the PostProcess. */
  14112. name: string;
  14113. /**
  14114. * Gets or sets the unique id of the post process
  14115. */
  14116. uniqueId: number;
  14117. /**
  14118. * Width of the texture to apply the post process on
  14119. */
  14120. width: number;
  14121. /**
  14122. * Height of the texture to apply the post process on
  14123. */
  14124. height: number;
  14125. /**
  14126. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14127. * @hidden
  14128. */
  14129. _outputTexture: Nullable<InternalTexture>;
  14130. /**
  14131. * Sampling mode used by the shader
  14132. * See https://doc.babylonjs.com/classes/3.1/texture
  14133. */
  14134. renderTargetSamplingMode: number;
  14135. /**
  14136. * Clear color to use when screen clearing
  14137. */
  14138. clearColor: Color4;
  14139. /**
  14140. * If the buffer needs to be cleared before applying the post process. (default: true)
  14141. * Should be set to false if shader will overwrite all previous pixels.
  14142. */
  14143. autoClear: boolean;
  14144. /**
  14145. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14146. */
  14147. alphaMode: number;
  14148. /**
  14149. * Sets the setAlphaBlendConstants of the babylon engine
  14150. */
  14151. alphaConstants: Color4;
  14152. /**
  14153. * Animations to be used for the post processing
  14154. */
  14155. animations: import("babylonjs/Animations/animation").Animation[];
  14156. /**
  14157. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14158. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14159. */
  14160. enablePixelPerfectMode: boolean;
  14161. /**
  14162. * Force the postprocess to be applied without taking in account viewport
  14163. */
  14164. forceFullscreenViewport: boolean;
  14165. /**
  14166. * List of inspectable custom properties (used by the Inspector)
  14167. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14168. */
  14169. inspectableCustomProperties: IInspectable[];
  14170. /**
  14171. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14172. *
  14173. * | Value | Type | Description |
  14174. * | ----- | ----------------------------------- | ----------- |
  14175. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14176. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14177. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14178. *
  14179. */
  14180. scaleMode: number;
  14181. /**
  14182. * Force textures to be a power of two (default: false)
  14183. */
  14184. alwaysForcePOT: boolean;
  14185. private _samples;
  14186. /**
  14187. * Number of sample textures (default: 1)
  14188. */
  14189. samples: number;
  14190. /**
  14191. * Modify the scale of the post process to be the same as the viewport (default: false)
  14192. */
  14193. adaptScaleToCurrentViewport: boolean;
  14194. private _camera;
  14195. private _scene;
  14196. private _engine;
  14197. private _options;
  14198. private _reusable;
  14199. private _textureType;
  14200. /**
  14201. * Smart array of input and output textures for the post process.
  14202. * @hidden
  14203. */
  14204. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  14205. /**
  14206. * The index in _textures that corresponds to the output texture.
  14207. * @hidden
  14208. */
  14209. _currentRenderTextureInd: number;
  14210. private _effect;
  14211. private _samplers;
  14212. private _fragmentUrl;
  14213. private _vertexUrl;
  14214. private _parameters;
  14215. private _scaleRatio;
  14216. protected _indexParameters: any;
  14217. private _shareOutputWithPostProcess;
  14218. private _texelSize;
  14219. private _forcedOutputTexture;
  14220. /**
  14221. * Returns the fragment url or shader name used in the post process.
  14222. * @returns the fragment url or name in the shader store.
  14223. */
  14224. getEffectName(): string;
  14225. /**
  14226. * An event triggered when the postprocess is activated.
  14227. */
  14228. onActivateObservable: Observable<Camera>;
  14229. private _onActivateObserver;
  14230. /**
  14231. * A function that is added to the onActivateObservable
  14232. */
  14233. onActivate: Nullable<(camera: Camera) => void>;
  14234. /**
  14235. * An event triggered when the postprocess changes its size.
  14236. */
  14237. onSizeChangedObservable: Observable<PostProcess>;
  14238. private _onSizeChangedObserver;
  14239. /**
  14240. * A function that is added to the onSizeChangedObservable
  14241. */
  14242. onSizeChanged: (postProcess: PostProcess) => void;
  14243. /**
  14244. * An event triggered when the postprocess applies its effect.
  14245. */
  14246. onApplyObservable: Observable<Effect>;
  14247. private _onApplyObserver;
  14248. /**
  14249. * A function that is added to the onApplyObservable
  14250. */
  14251. onApply: (effect: Effect) => void;
  14252. /**
  14253. * An event triggered before rendering the postprocess
  14254. */
  14255. onBeforeRenderObservable: Observable<Effect>;
  14256. private _onBeforeRenderObserver;
  14257. /**
  14258. * A function that is added to the onBeforeRenderObservable
  14259. */
  14260. onBeforeRender: (effect: Effect) => void;
  14261. /**
  14262. * An event triggered after rendering the postprocess
  14263. */
  14264. onAfterRenderObservable: Observable<Effect>;
  14265. private _onAfterRenderObserver;
  14266. /**
  14267. * A function that is added to the onAfterRenderObservable
  14268. */
  14269. onAfterRender: (efect: Effect) => void;
  14270. /**
  14271. * 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
  14272. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14273. */
  14274. inputTexture: InternalTexture;
  14275. /**
  14276. * Gets the camera which post process is applied to.
  14277. * @returns The camera the post process is applied to.
  14278. */
  14279. getCamera(): Camera;
  14280. /**
  14281. * Gets the texel size of the postprocess.
  14282. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14283. */
  14284. readonly texelSize: Vector2;
  14285. /**
  14286. * Creates a new instance PostProcess
  14287. * @param name The name of the PostProcess.
  14288. * @param fragmentUrl The url of the fragment shader to be used.
  14289. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14290. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14291. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14292. * @param camera The camera to apply the render pass to.
  14293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14294. * @param engine The engine which the post process will be applied. (default: current engine)
  14295. * @param reusable If the post process can be reused on the same frame. (default: false)
  14296. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14297. * @param textureType Type of textures used when performing the post process. (default: 0)
  14298. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14299. * @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
  14300. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14301. */
  14302. constructor(
  14303. /** Name of the PostProcess. */
  14304. 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);
  14305. /**
  14306. * Gets a string idenfifying the name of the class
  14307. * @returns "PostProcess" string
  14308. */
  14309. getClassName(): string;
  14310. /**
  14311. * Gets the engine which this post process belongs to.
  14312. * @returns The engine the post process was enabled with.
  14313. */
  14314. getEngine(): Engine;
  14315. /**
  14316. * The effect that is created when initializing the post process.
  14317. * @returns The created effect corrisponding the the postprocess.
  14318. */
  14319. getEffect(): Effect;
  14320. /**
  14321. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14322. * @param postProcess The post process to share the output with.
  14323. * @returns This post process.
  14324. */
  14325. shareOutputWith(postProcess: PostProcess): PostProcess;
  14326. /**
  14327. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14328. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14329. */
  14330. useOwnOutput(): void;
  14331. /**
  14332. * Updates the effect with the current post process compile time values and recompiles the shader.
  14333. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14334. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14335. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14336. * @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
  14337. * @param onCompiled Called when the shader has been compiled.
  14338. * @param onError Called if there is an error when compiling a shader.
  14339. */
  14340. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14341. /**
  14342. * The post process is reusable if it can be used multiple times within one frame.
  14343. * @returns If the post process is reusable
  14344. */
  14345. isReusable(): boolean;
  14346. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14347. markTextureDirty(): void;
  14348. /**
  14349. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14350. * 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.
  14351. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14352. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14353. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14354. * @returns The target texture that was bound to be written to.
  14355. */
  14356. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14357. /**
  14358. * If the post process is supported.
  14359. */
  14360. readonly isSupported: boolean;
  14361. /**
  14362. * The aspect ratio of the output texture.
  14363. */
  14364. readonly aspectRatio: number;
  14365. /**
  14366. * Get a value indicating if the post-process is ready to be used
  14367. * @returns true if the post-process is ready (shader is compiled)
  14368. */
  14369. isReady(): boolean;
  14370. /**
  14371. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14372. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14373. */
  14374. apply(): Nullable<Effect>;
  14375. private _disposeTextures;
  14376. /**
  14377. * Disposes the post process.
  14378. * @param camera The camera to dispose the post process on.
  14379. */
  14380. dispose(camera?: Camera): void;
  14381. }
  14382. }
  14383. declare module "babylonjs/PostProcesses/postProcessManager" {
  14384. import { Nullable } from "babylonjs/types";
  14385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14387. import { Scene } from "babylonjs/scene";
  14388. /**
  14389. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14391. */
  14392. export class PostProcessManager {
  14393. private _scene;
  14394. private _indexBuffer;
  14395. private _vertexBuffers;
  14396. /**
  14397. * Creates a new instance PostProcess
  14398. * @param scene The scene that the post process is associated with.
  14399. */
  14400. constructor(scene: Scene);
  14401. private _prepareBuffers;
  14402. private _buildIndexBuffer;
  14403. /**
  14404. * Rebuilds the vertex buffers of the manager.
  14405. * @hidden
  14406. */
  14407. _rebuild(): void;
  14408. /**
  14409. * Prepares a frame to be run through a post process.
  14410. * @param sourceTexture The input texture to the post procesess. (default: null)
  14411. * @param postProcesses An array of post processes to be run. (default: null)
  14412. * @returns True if the post processes were able to be run.
  14413. * @hidden
  14414. */
  14415. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14416. /**
  14417. * Manually render a set of post processes to a texture.
  14418. * @param postProcesses An array of post processes to be run.
  14419. * @param targetTexture The target texture to render to.
  14420. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14421. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14422. * @param lodLevel defines which lod of the texture to render to
  14423. */
  14424. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14425. /**
  14426. * Finalize the result of the output of the postprocesses.
  14427. * @param doNotPresent If true the result will not be displayed to the screen.
  14428. * @param targetTexture The target texture to render to.
  14429. * @param faceIndex The index of the face to bind the target texture to.
  14430. * @param postProcesses The array of post processes to render.
  14431. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14432. * @hidden
  14433. */
  14434. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14435. /**
  14436. * Disposes of the post process manager.
  14437. */
  14438. dispose(): void;
  14439. }
  14440. }
  14441. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14442. import { Scene } from "babylonjs/scene";
  14443. import { ISceneComponent } from "babylonjs/sceneComponent";
  14444. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14445. module "babylonjs/abstractScene" {
  14446. interface AbstractScene {
  14447. /**
  14448. * The list of procedural textures added to the scene
  14449. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14450. */
  14451. proceduralTextures: Array<ProceduralTexture>;
  14452. }
  14453. }
  14454. /**
  14455. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14456. * in a given scene.
  14457. */
  14458. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14459. /**
  14460. * The component name helpfull to identify the component in the list of scene components.
  14461. */
  14462. readonly name: string;
  14463. /**
  14464. * The scene the component belongs to.
  14465. */
  14466. scene: Scene;
  14467. /**
  14468. * Creates a new instance of the component for the given scene
  14469. * @param scene Defines the scene to register the component in
  14470. */
  14471. constructor(scene: Scene);
  14472. /**
  14473. * Registers the component in a given scene
  14474. */
  14475. register(): void;
  14476. /**
  14477. * Rebuilds the elements related to this component in case of
  14478. * context lost for instance.
  14479. */
  14480. rebuild(): void;
  14481. /**
  14482. * Disposes the component and the associated ressources.
  14483. */
  14484. dispose(): void;
  14485. private _beforeClear;
  14486. }
  14487. }
  14488. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14489. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14490. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14491. module "babylonjs/Engines/engine" {
  14492. interface Engine {
  14493. /**
  14494. * Creates a new render target cube texture
  14495. * @param size defines the size of the texture
  14496. * @param options defines the options used to create the texture
  14497. * @returns a new render target cube texture stored in an InternalTexture
  14498. */
  14499. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14500. }
  14501. }
  14502. }
  14503. declare module "babylonjs/Shaders/procedural.vertex" {
  14504. /** @hidden */
  14505. export var proceduralVertexShader: {
  14506. name: string;
  14507. shader: string;
  14508. };
  14509. }
  14510. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14511. import { Observable } from "babylonjs/Misc/observable";
  14512. import { Nullable } from "babylonjs/types";
  14513. import { Scene } from "babylonjs/scene";
  14514. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14515. import { Effect } from "babylonjs/Materials/effect";
  14516. import { Texture } from "babylonjs/Materials/Textures/texture";
  14517. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14518. import "babylonjs/Shaders/procedural.vertex";
  14519. /**
  14520. * 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.
  14521. * This is the base class of any Procedural texture and contains most of the shareable code.
  14522. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14523. */
  14524. export class ProceduralTexture extends Texture {
  14525. isCube: boolean;
  14526. /**
  14527. * Define if the texture is enabled or not (disabled texture will not render)
  14528. */
  14529. isEnabled: boolean;
  14530. /**
  14531. * Define if the texture must be cleared before rendering (default is true)
  14532. */
  14533. autoClear: boolean;
  14534. /**
  14535. * Callback called when the texture is generated
  14536. */
  14537. onGenerated: () => void;
  14538. /**
  14539. * Event raised when the texture is generated
  14540. */
  14541. onGeneratedObservable: Observable<ProceduralTexture>;
  14542. /** @hidden */
  14543. _generateMipMaps: boolean;
  14544. /** @hidden **/
  14545. _effect: Effect;
  14546. /** @hidden */
  14547. _textures: {
  14548. [key: string]: Texture;
  14549. };
  14550. private _size;
  14551. private _currentRefreshId;
  14552. private _refreshRate;
  14553. private _vertexBuffers;
  14554. private _indexBuffer;
  14555. private _uniforms;
  14556. private _samplers;
  14557. private _fragment;
  14558. private _floats;
  14559. private _ints;
  14560. private _floatsArrays;
  14561. private _colors3;
  14562. private _colors4;
  14563. private _vectors2;
  14564. private _vectors3;
  14565. private _matrices;
  14566. private _fallbackTexture;
  14567. private _fallbackTextureUsed;
  14568. private _engine;
  14569. private _cachedDefines;
  14570. private _contentUpdateId;
  14571. private _contentData;
  14572. /**
  14573. * Instantiates a new procedural texture.
  14574. * 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.
  14575. * This is the base class of any Procedural texture and contains most of the shareable code.
  14576. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14577. * @param name Define the name of the texture
  14578. * @param size Define the size of the texture to create
  14579. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14580. * @param scene Define the scene the texture belongs to
  14581. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14582. * @param generateMipMaps Define if the texture should creates mip maps or not
  14583. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14584. */
  14585. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14586. /**
  14587. * The effect that is created when initializing the post process.
  14588. * @returns The created effect corrisponding the the postprocess.
  14589. */
  14590. getEffect(): Effect;
  14591. /**
  14592. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14593. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14594. */
  14595. getContent(): Nullable<ArrayBufferView>;
  14596. private _createIndexBuffer;
  14597. /** @hidden */
  14598. _rebuild(): void;
  14599. /**
  14600. * Resets the texture in order to recreate its associated resources.
  14601. * This can be called in case of context loss
  14602. */
  14603. reset(): void;
  14604. protected _getDefines(): string;
  14605. /**
  14606. * Is the texture ready to be used ? (rendered at least once)
  14607. * @returns true if ready, otherwise, false.
  14608. */
  14609. isReady(): boolean;
  14610. /**
  14611. * Resets the refresh counter of the texture and start bak from scratch.
  14612. * Could be useful to regenerate the texture if it is setup to render only once.
  14613. */
  14614. resetRefreshCounter(): void;
  14615. /**
  14616. * Set the fragment shader to use in order to render the texture.
  14617. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14618. */
  14619. setFragment(fragment: any): void;
  14620. /**
  14621. * Define the refresh rate of the texture or the rendering frequency.
  14622. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14623. */
  14624. refreshRate: number;
  14625. /** @hidden */
  14626. _shouldRender(): boolean;
  14627. /**
  14628. * Get the size the texture is rendering at.
  14629. * @returns the size (texture is always squared)
  14630. */
  14631. getRenderSize(): number;
  14632. /**
  14633. * Resize the texture to new value.
  14634. * @param size Define the new size the texture should have
  14635. * @param generateMipMaps Define whether the new texture should create mip maps
  14636. */
  14637. resize(size: number, generateMipMaps: boolean): void;
  14638. private _checkUniform;
  14639. /**
  14640. * Set a texture in the shader program used to render.
  14641. * @param name Define the name of the uniform samplers as defined in the shader
  14642. * @param texture Define the texture to bind to this sampler
  14643. * @return the texture itself allowing "fluent" like uniform updates
  14644. */
  14645. setTexture(name: string, texture: Texture): ProceduralTexture;
  14646. /**
  14647. * Set a float in the shader.
  14648. * @param name Define the name of the uniform as defined in the shader
  14649. * @param value Define the value to give to the uniform
  14650. * @return the texture itself allowing "fluent" like uniform updates
  14651. */
  14652. setFloat(name: string, value: number): ProceduralTexture;
  14653. /**
  14654. * Set a int in the shader.
  14655. * @param name Define the name of the uniform as defined in the shader
  14656. * @param value Define the value to give to the uniform
  14657. * @return the texture itself allowing "fluent" like uniform updates
  14658. */
  14659. setInt(name: string, value: number): ProceduralTexture;
  14660. /**
  14661. * Set an array of floats in the shader.
  14662. * @param name Define the name of the uniform as defined in the shader
  14663. * @param value Define the value to give to the uniform
  14664. * @return the texture itself allowing "fluent" like uniform updates
  14665. */
  14666. setFloats(name: string, value: number[]): ProceduralTexture;
  14667. /**
  14668. * Set a vec3 in the shader from a Color3.
  14669. * @param name Define the name of the uniform as defined in the shader
  14670. * @param value Define the value to give to the uniform
  14671. * @return the texture itself allowing "fluent" like uniform updates
  14672. */
  14673. setColor3(name: string, value: Color3): ProceduralTexture;
  14674. /**
  14675. * Set a vec4 in the shader from a Color4.
  14676. * @param name Define the name of the uniform as defined in the shader
  14677. * @param value Define the value to give to the uniform
  14678. * @return the texture itself allowing "fluent" like uniform updates
  14679. */
  14680. setColor4(name: string, value: Color4): ProceduralTexture;
  14681. /**
  14682. * Set a vec2 in the shader from a Vector2.
  14683. * @param name Define the name of the uniform as defined in the shader
  14684. * @param value Define the value to give to the uniform
  14685. * @return the texture itself allowing "fluent" like uniform updates
  14686. */
  14687. setVector2(name: string, value: Vector2): ProceduralTexture;
  14688. /**
  14689. * Set a vec3 in the shader from a Vector3.
  14690. * @param name Define the name of the uniform as defined in the shader
  14691. * @param value Define the value to give to the uniform
  14692. * @return the texture itself allowing "fluent" like uniform updates
  14693. */
  14694. setVector3(name: string, value: Vector3): ProceduralTexture;
  14695. /**
  14696. * Set a mat4 in the shader from a MAtrix.
  14697. * @param name Define the name of the uniform as defined in the shader
  14698. * @param value Define the value to give to the uniform
  14699. * @return the texture itself allowing "fluent" like uniform updates
  14700. */
  14701. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14702. /**
  14703. * Render the texture to its associated render target.
  14704. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14705. */
  14706. render(useCameraPostProcess?: boolean): void;
  14707. /**
  14708. * Clone the texture.
  14709. * @returns the cloned texture
  14710. */
  14711. clone(): ProceduralTexture;
  14712. /**
  14713. * Dispose the texture and release its asoociated resources.
  14714. */
  14715. dispose(): void;
  14716. }
  14717. }
  14718. declare module "babylonjs/Particles/baseParticleSystem" {
  14719. import { Nullable } from "babylonjs/types";
  14720. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14722. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14723. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14724. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14725. import { Scene } from "babylonjs/scene";
  14726. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14727. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14728. import { Texture } from "babylonjs/Materials/Textures/texture";
  14729. import { Animation } from "babylonjs/Animations/animation";
  14730. /**
  14731. * This represents the base class for particle system in Babylon.
  14732. * 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.
  14733. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14734. * @example https://doc.babylonjs.com/babylon101/particles
  14735. */
  14736. export class BaseParticleSystem {
  14737. /**
  14738. * Source color is added to the destination color without alpha affecting the result
  14739. */
  14740. static BLENDMODE_ONEONE: number;
  14741. /**
  14742. * Blend current color and particle color using particle’s alpha
  14743. */
  14744. static BLENDMODE_STANDARD: number;
  14745. /**
  14746. * Add current color and particle color multiplied by particle’s alpha
  14747. */
  14748. static BLENDMODE_ADD: number;
  14749. /**
  14750. * Multiply current color with particle color
  14751. */
  14752. static BLENDMODE_MULTIPLY: number;
  14753. /**
  14754. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14755. */
  14756. static BLENDMODE_MULTIPLYADD: number;
  14757. /**
  14758. * List of animations used by the particle system.
  14759. */
  14760. animations: Animation[];
  14761. /**
  14762. * The id of the Particle system.
  14763. */
  14764. id: string;
  14765. /**
  14766. * The friendly name of the Particle system.
  14767. */
  14768. name: string;
  14769. /**
  14770. * The rendering group used by the Particle system to chose when to render.
  14771. */
  14772. renderingGroupId: number;
  14773. /**
  14774. * The emitter represents the Mesh or position we are attaching the particle system to.
  14775. */
  14776. emitter: Nullable<AbstractMesh | Vector3>;
  14777. /**
  14778. * The maximum number of particles to emit per frame
  14779. */
  14780. emitRate: number;
  14781. /**
  14782. * If you want to launch only a few particles at once, that can be done, as well.
  14783. */
  14784. manualEmitCount: number;
  14785. /**
  14786. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14787. */
  14788. updateSpeed: number;
  14789. /**
  14790. * The amount of time the particle system is running (depends of the overall update speed).
  14791. */
  14792. targetStopDuration: number;
  14793. /**
  14794. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14795. */
  14796. disposeOnStop: boolean;
  14797. /**
  14798. * Minimum power of emitting particles.
  14799. */
  14800. minEmitPower: number;
  14801. /**
  14802. * Maximum power of emitting particles.
  14803. */
  14804. maxEmitPower: number;
  14805. /**
  14806. * Minimum life time of emitting particles.
  14807. */
  14808. minLifeTime: number;
  14809. /**
  14810. * Maximum life time of emitting particles.
  14811. */
  14812. maxLifeTime: number;
  14813. /**
  14814. * Minimum Size of emitting particles.
  14815. */
  14816. minSize: number;
  14817. /**
  14818. * Maximum Size of emitting particles.
  14819. */
  14820. maxSize: number;
  14821. /**
  14822. * Minimum scale of emitting particles on X axis.
  14823. */
  14824. minScaleX: number;
  14825. /**
  14826. * Maximum scale of emitting particles on X axis.
  14827. */
  14828. maxScaleX: number;
  14829. /**
  14830. * Minimum scale of emitting particles on Y axis.
  14831. */
  14832. minScaleY: number;
  14833. /**
  14834. * Maximum scale of emitting particles on Y axis.
  14835. */
  14836. maxScaleY: number;
  14837. /**
  14838. * Gets or sets the minimal initial rotation in radians.
  14839. */
  14840. minInitialRotation: number;
  14841. /**
  14842. * Gets or sets the maximal initial rotation in radians.
  14843. */
  14844. maxInitialRotation: number;
  14845. /**
  14846. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14847. */
  14848. minAngularSpeed: number;
  14849. /**
  14850. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14851. */
  14852. maxAngularSpeed: number;
  14853. /**
  14854. * The texture used to render each particle. (this can be a spritesheet)
  14855. */
  14856. particleTexture: Nullable<Texture>;
  14857. /**
  14858. * The layer mask we are rendering the particles through.
  14859. */
  14860. layerMask: number;
  14861. /**
  14862. * This can help using your own shader to render the particle system.
  14863. * The according effect will be created
  14864. */
  14865. customShader: any;
  14866. /**
  14867. * By default particle system starts as soon as they are created. This prevents the
  14868. * automatic start to happen and let you decide when to start emitting particles.
  14869. */
  14870. preventAutoStart: boolean;
  14871. private _noiseTexture;
  14872. /**
  14873. * Gets or sets a texture used to add random noise to particle positions
  14874. */
  14875. noiseTexture: Nullable<ProceduralTexture>;
  14876. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14877. noiseStrength: Vector3;
  14878. /**
  14879. * Callback triggered when the particle animation is ending.
  14880. */
  14881. onAnimationEnd: Nullable<() => void>;
  14882. /**
  14883. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14884. */
  14885. blendMode: number;
  14886. /**
  14887. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14888. * to override the particles.
  14889. */
  14890. forceDepthWrite: boolean;
  14891. /** 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 */
  14892. preWarmCycles: number;
  14893. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14894. preWarmStepOffset: number;
  14895. /**
  14896. * 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)
  14897. */
  14898. spriteCellChangeSpeed: number;
  14899. /**
  14900. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14901. */
  14902. startSpriteCellID: number;
  14903. /**
  14904. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14905. */
  14906. endSpriteCellID: number;
  14907. /**
  14908. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14909. */
  14910. spriteCellWidth: number;
  14911. /**
  14912. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14913. */
  14914. spriteCellHeight: number;
  14915. /**
  14916. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14917. */
  14918. spriteRandomStartCell: boolean;
  14919. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14920. translationPivot: Vector2;
  14921. /** @hidden */
  14922. protected _isAnimationSheetEnabled: boolean;
  14923. /**
  14924. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14925. */
  14926. beginAnimationOnStart: boolean;
  14927. /**
  14928. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14929. */
  14930. beginAnimationFrom: number;
  14931. /**
  14932. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14933. */
  14934. beginAnimationTo: number;
  14935. /**
  14936. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14937. */
  14938. beginAnimationLoop: boolean;
  14939. /**
  14940. * Gets or sets a world offset applied to all particles
  14941. */
  14942. worldOffset: Vector3;
  14943. /**
  14944. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14945. */
  14946. isAnimationSheetEnabled: boolean;
  14947. /**
  14948. * Get hosting scene
  14949. * @returns the scene
  14950. */
  14951. getScene(): Scene;
  14952. /**
  14953. * You can use gravity if you want to give an orientation to your particles.
  14954. */
  14955. gravity: Vector3;
  14956. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14957. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14958. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14959. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14960. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14961. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14962. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14963. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14964. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14965. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14966. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14967. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14968. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14969. /**
  14970. * Defines the delay in milliseconds before starting the system (0 by default)
  14971. */
  14972. startDelay: number;
  14973. /**
  14974. * Gets the current list of drag gradients.
  14975. * You must use addDragGradient and removeDragGradient to udpate this list
  14976. * @returns the list of drag gradients
  14977. */
  14978. getDragGradients(): Nullable<Array<FactorGradient>>;
  14979. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14980. limitVelocityDamping: number;
  14981. /**
  14982. * Gets the current list of limit velocity gradients.
  14983. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14984. * @returns the list of limit velocity gradients
  14985. */
  14986. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14987. /**
  14988. * Gets the current list of color gradients.
  14989. * You must use addColorGradient and removeColorGradient to udpate this list
  14990. * @returns the list of color gradients
  14991. */
  14992. getColorGradients(): Nullable<Array<ColorGradient>>;
  14993. /**
  14994. * Gets the current list of size gradients.
  14995. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14996. * @returns the list of size gradients
  14997. */
  14998. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14999. /**
  15000. * Gets the current list of color remap gradients.
  15001. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15002. * @returns the list of color remap gradients
  15003. */
  15004. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15005. /**
  15006. * Gets the current list of alpha remap gradients.
  15007. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15008. * @returns the list of alpha remap gradients
  15009. */
  15010. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15011. /**
  15012. * Gets the current list of life time gradients.
  15013. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15014. * @returns the list of life time gradients
  15015. */
  15016. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15017. /**
  15018. * Gets the current list of angular speed gradients.
  15019. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15020. * @returns the list of angular speed gradients
  15021. */
  15022. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15023. /**
  15024. * Gets the current list of velocity gradients.
  15025. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15026. * @returns the list of velocity gradients
  15027. */
  15028. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15029. /**
  15030. * Gets the current list of start size gradients.
  15031. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15032. * @returns the list of start size gradients
  15033. */
  15034. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15035. /**
  15036. * Gets the current list of emit rate gradients.
  15037. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15038. * @returns the list of emit rate gradients
  15039. */
  15040. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15041. /**
  15042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15043. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15044. */
  15045. direction1: Vector3;
  15046. /**
  15047. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15048. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15049. */
  15050. direction2: Vector3;
  15051. /**
  15052. * 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.
  15053. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15054. */
  15055. minEmitBox: Vector3;
  15056. /**
  15057. * 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.
  15058. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15059. */
  15060. maxEmitBox: Vector3;
  15061. /**
  15062. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15063. */
  15064. color1: Color4;
  15065. /**
  15066. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15067. */
  15068. color2: Color4;
  15069. /**
  15070. * Color the particle will have at the end of its lifetime
  15071. */
  15072. colorDead: Color4;
  15073. /**
  15074. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15075. */
  15076. textureMask: Color4;
  15077. /**
  15078. * The particle emitter type defines the emitter used by the particle system.
  15079. * It can be for example box, sphere, or cone...
  15080. */
  15081. particleEmitterType: IParticleEmitterType;
  15082. /** @hidden */
  15083. _isSubEmitter: boolean;
  15084. /**
  15085. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15086. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15087. */
  15088. billboardMode: number;
  15089. protected _isBillboardBased: boolean;
  15090. /**
  15091. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15092. */
  15093. isBillboardBased: boolean;
  15094. /**
  15095. * The scene the particle system belongs to.
  15096. */
  15097. protected _scene: Scene;
  15098. /**
  15099. * Local cache of defines for image processing.
  15100. */
  15101. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15102. /**
  15103. * Default configuration related to image processing available in the standard Material.
  15104. */
  15105. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15106. /**
  15107. * Gets the image processing configuration used either in this material.
  15108. */
  15109. /**
  15110. * Sets the Default image processing configuration used either in the this material.
  15111. *
  15112. * If sets to null, the scene one is in use.
  15113. */
  15114. imageProcessingConfiguration: ImageProcessingConfiguration;
  15115. /**
  15116. * Attaches a new image processing configuration to the Standard Material.
  15117. * @param configuration
  15118. */
  15119. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15120. /** @hidden */
  15121. protected _reset(): void;
  15122. /** @hidden */
  15123. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15124. /**
  15125. * Instantiates a particle system.
  15126. * 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.
  15127. * @param name The name of the particle system
  15128. */
  15129. constructor(name: string);
  15130. /**
  15131. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15134. * @returns the emitter
  15135. */
  15136. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15137. /**
  15138. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15139. * @param radius The radius of the hemisphere to emit from
  15140. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15141. * @returns the emitter
  15142. */
  15143. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15144. /**
  15145. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15146. * @param radius The radius of the sphere to emit from
  15147. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15148. * @returns the emitter
  15149. */
  15150. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15151. /**
  15152. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15153. * @param radius The radius of the sphere to emit from
  15154. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15155. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15156. * @returns the emitter
  15157. */
  15158. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15159. /**
  15160. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15161. * @param radius The radius of the emission cylinder
  15162. * @param height The height of the emission cylinder
  15163. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15164. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15165. * @returns the emitter
  15166. */
  15167. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15168. /**
  15169. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15170. * @param radius The radius of the cylinder to emit from
  15171. * @param height The height of the emission cylinder
  15172. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15173. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15174. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15175. * @returns the emitter
  15176. */
  15177. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15178. /**
  15179. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15180. * @param radius The radius of the cone to emit from
  15181. * @param angle The base angle of the cone
  15182. * @returns the emitter
  15183. */
  15184. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15185. /**
  15186. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15187. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15188. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15189. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15190. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15191. * @returns the emitter
  15192. */
  15193. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15194. }
  15195. }
  15196. declare module "babylonjs/Particles/subEmitter" {
  15197. import { Scene } from "babylonjs/scene";
  15198. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15199. /**
  15200. * Type of sub emitter
  15201. */
  15202. export enum SubEmitterType {
  15203. /**
  15204. * Attached to the particle over it's lifetime
  15205. */
  15206. ATTACHED = 0,
  15207. /**
  15208. * Created when the particle dies
  15209. */
  15210. END = 1
  15211. }
  15212. /**
  15213. * Sub emitter class used to emit particles from an existing particle
  15214. */
  15215. export class SubEmitter {
  15216. /**
  15217. * the particle system to be used by the sub emitter
  15218. */
  15219. particleSystem: ParticleSystem;
  15220. /**
  15221. * Type of the submitter (Default: END)
  15222. */
  15223. type: SubEmitterType;
  15224. /**
  15225. * 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)
  15226. * Note: This only is supported when using an emitter of type Mesh
  15227. */
  15228. inheritDirection: boolean;
  15229. /**
  15230. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15231. */
  15232. inheritedVelocityAmount: number;
  15233. /**
  15234. * Creates a sub emitter
  15235. * @param particleSystem the particle system to be used by the sub emitter
  15236. */
  15237. constructor(
  15238. /**
  15239. * the particle system to be used by the sub emitter
  15240. */
  15241. particleSystem: ParticleSystem);
  15242. /**
  15243. * Clones the sub emitter
  15244. * @returns the cloned sub emitter
  15245. */
  15246. clone(): SubEmitter;
  15247. /**
  15248. * Serialize current object to a JSON object
  15249. * @returns the serialized object
  15250. */
  15251. serialize(): any;
  15252. /** @hidden */
  15253. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15254. /**
  15255. * Creates a new SubEmitter from a serialized JSON version
  15256. * @param serializationObject defines the JSON object to read from
  15257. * @param scene defines the hosting scene
  15258. * @param rootUrl defines the rootUrl for data loading
  15259. * @returns a new SubEmitter
  15260. */
  15261. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15262. /** Release associated resources */
  15263. dispose(): void;
  15264. }
  15265. }
  15266. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15267. /** @hidden */
  15268. export var clipPlaneFragmentDeclaration: {
  15269. name: string;
  15270. shader: string;
  15271. };
  15272. }
  15273. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15274. /** @hidden */
  15275. export var imageProcessingDeclaration: {
  15276. name: string;
  15277. shader: string;
  15278. };
  15279. }
  15280. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15281. /** @hidden */
  15282. export var imageProcessingFunctions: {
  15283. name: string;
  15284. shader: string;
  15285. };
  15286. }
  15287. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15288. /** @hidden */
  15289. export var clipPlaneFragment: {
  15290. name: string;
  15291. shader: string;
  15292. };
  15293. }
  15294. declare module "babylonjs/Shaders/particles.fragment" {
  15295. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15296. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15297. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15298. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15299. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15300. /** @hidden */
  15301. export var particlesPixelShader: {
  15302. name: string;
  15303. shader: string;
  15304. };
  15305. }
  15306. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15307. /** @hidden */
  15308. export var clipPlaneVertexDeclaration: {
  15309. name: string;
  15310. shader: string;
  15311. };
  15312. }
  15313. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15314. /** @hidden */
  15315. export var clipPlaneVertex: {
  15316. name: string;
  15317. shader: string;
  15318. };
  15319. }
  15320. declare module "babylonjs/Shaders/particles.vertex" {
  15321. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15323. /** @hidden */
  15324. export var particlesVertexShader: {
  15325. name: string;
  15326. shader: string;
  15327. };
  15328. }
  15329. declare module "babylonjs/Particles/particleSystem" {
  15330. import { Nullable } from "babylonjs/types";
  15331. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15332. import { Observable } from "babylonjs/Misc/observable";
  15333. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15334. import { Effect } from "babylonjs/Materials/effect";
  15335. import { Scene, IDisposable } from "babylonjs/scene";
  15336. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15337. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15338. import { Particle } from "babylonjs/Particles/particle";
  15339. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15340. import "babylonjs/Shaders/particles.fragment";
  15341. import "babylonjs/Shaders/particles.vertex";
  15342. /**
  15343. * This represents a particle system in Babylon.
  15344. * 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.
  15345. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15346. * @example https://doc.babylonjs.com/babylon101/particles
  15347. */
  15348. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15349. /**
  15350. * Billboard mode will only apply to Y axis
  15351. */
  15352. static readonly BILLBOARDMODE_Y: number;
  15353. /**
  15354. * Billboard mode will apply to all axes
  15355. */
  15356. static readonly BILLBOARDMODE_ALL: number;
  15357. /**
  15358. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15359. */
  15360. static readonly BILLBOARDMODE_STRETCHED: number;
  15361. /**
  15362. * This function can be defined to provide custom update for active particles.
  15363. * This function will be called instead of regular update (age, position, color, etc.).
  15364. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15365. */
  15366. updateFunction: (particles: Particle[]) => void;
  15367. private _emitterWorldMatrix;
  15368. /**
  15369. * This function can be defined to specify initial direction for every new particle.
  15370. * It by default use the emitterType defined function
  15371. */
  15372. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15373. /**
  15374. * This function can be defined to specify initial position for every new particle.
  15375. * It by default use the emitterType defined function
  15376. */
  15377. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15378. /**
  15379. * @hidden
  15380. */
  15381. _inheritedVelocityOffset: Vector3;
  15382. /**
  15383. * An event triggered when the system is disposed
  15384. */
  15385. onDisposeObservable: Observable<ParticleSystem>;
  15386. private _onDisposeObserver;
  15387. /**
  15388. * Sets a callback that will be triggered when the system is disposed
  15389. */
  15390. onDispose: () => void;
  15391. private _particles;
  15392. private _epsilon;
  15393. private _capacity;
  15394. private _stockParticles;
  15395. private _newPartsExcess;
  15396. private _vertexData;
  15397. private _vertexBuffer;
  15398. private _vertexBuffers;
  15399. private _spriteBuffer;
  15400. private _indexBuffer;
  15401. private _effect;
  15402. private _customEffect;
  15403. private _cachedDefines;
  15404. private _scaledColorStep;
  15405. private _colorDiff;
  15406. private _scaledDirection;
  15407. private _scaledGravity;
  15408. private _currentRenderId;
  15409. private _alive;
  15410. private _useInstancing;
  15411. private _started;
  15412. private _stopped;
  15413. private _actualFrame;
  15414. private _scaledUpdateSpeed;
  15415. private _vertexBufferSize;
  15416. /** @hidden */
  15417. _currentEmitRateGradient: Nullable<FactorGradient>;
  15418. /** @hidden */
  15419. _currentEmitRate1: number;
  15420. /** @hidden */
  15421. _currentEmitRate2: number;
  15422. /** @hidden */
  15423. _currentStartSizeGradient: Nullable<FactorGradient>;
  15424. /** @hidden */
  15425. _currentStartSize1: number;
  15426. /** @hidden */
  15427. _currentStartSize2: number;
  15428. private readonly _rawTextureWidth;
  15429. private _rampGradientsTexture;
  15430. private _useRampGradients;
  15431. /** Gets or sets a boolean indicating that ramp gradients must be used
  15432. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15433. */
  15434. useRampGradients: boolean;
  15435. /**
  15436. * 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.
  15437. * 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: [])
  15438. */
  15439. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15440. private _subEmitters;
  15441. /**
  15442. * @hidden
  15443. * If the particle systems emitter should be disposed when the particle system is disposed
  15444. */
  15445. _disposeEmitterOnDispose: boolean;
  15446. /**
  15447. * The current active Sub-systems, this property is used by the root particle system only.
  15448. */
  15449. activeSubSystems: Array<ParticleSystem>;
  15450. private _rootParticleSystem;
  15451. /**
  15452. * Gets the current list of active particles
  15453. */
  15454. readonly particles: Particle[];
  15455. /**
  15456. * Returns the string "ParticleSystem"
  15457. * @returns a string containing the class name
  15458. */
  15459. getClassName(): string;
  15460. /**
  15461. * Instantiates a particle system.
  15462. * 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.
  15463. * @param name The name of the particle system
  15464. * @param capacity The max number of particles alive at the same time
  15465. * @param scene The scene the particle system belongs to
  15466. * @param customEffect a custom effect used to change the way particles are rendered by default
  15467. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15468. * @param epsilon Offset used to render the particles
  15469. */
  15470. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15471. private _addFactorGradient;
  15472. private _removeFactorGradient;
  15473. /**
  15474. * Adds a new life time gradient
  15475. * @param gradient defines the gradient to use (between 0 and 1)
  15476. * @param factor defines the life time factor to affect to the specified gradient
  15477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15478. * @returns the current particle system
  15479. */
  15480. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15481. /**
  15482. * Remove a specific life time gradient
  15483. * @param gradient defines the gradient to remove
  15484. * @returns the current particle system
  15485. */
  15486. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15487. /**
  15488. * Adds a new size gradient
  15489. * @param gradient defines the gradient to use (between 0 and 1)
  15490. * @param factor defines the size factor to affect to the specified gradient
  15491. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15492. * @returns the current particle system
  15493. */
  15494. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15495. /**
  15496. * Remove a specific size gradient
  15497. * @param gradient defines the gradient to remove
  15498. * @returns the current particle system
  15499. */
  15500. removeSizeGradient(gradient: number): IParticleSystem;
  15501. /**
  15502. * Adds a new color remap gradient
  15503. * @param gradient defines the gradient to use (between 0 and 1)
  15504. * @param min defines the color remap minimal range
  15505. * @param max defines the color remap maximal range
  15506. * @returns the current particle system
  15507. */
  15508. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15509. /**
  15510. * Remove a specific color remap gradient
  15511. * @param gradient defines the gradient to remove
  15512. * @returns the current particle system
  15513. */
  15514. removeColorRemapGradient(gradient: number): IParticleSystem;
  15515. /**
  15516. * Adds a new alpha remap gradient
  15517. * @param gradient defines the gradient to use (between 0 and 1)
  15518. * @param min defines the alpha remap minimal range
  15519. * @param max defines the alpha remap maximal range
  15520. * @returns the current particle system
  15521. */
  15522. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15523. /**
  15524. * Remove a specific alpha remap gradient
  15525. * @param gradient defines the gradient to remove
  15526. * @returns the current particle system
  15527. */
  15528. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15529. /**
  15530. * Adds a new angular speed gradient
  15531. * @param gradient defines the gradient to use (between 0 and 1)
  15532. * @param factor defines the angular speed to affect to the specified gradient
  15533. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15534. * @returns the current particle system
  15535. */
  15536. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15537. /**
  15538. * Remove a specific angular speed gradient
  15539. * @param gradient defines the gradient to remove
  15540. * @returns the current particle system
  15541. */
  15542. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15543. /**
  15544. * Adds a new velocity gradient
  15545. * @param gradient defines the gradient to use (between 0 and 1)
  15546. * @param factor defines the velocity to affect to the specified gradient
  15547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15548. * @returns the current particle system
  15549. */
  15550. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15551. /**
  15552. * Remove a specific velocity gradient
  15553. * @param gradient defines the gradient to remove
  15554. * @returns the current particle system
  15555. */
  15556. removeVelocityGradient(gradient: number): IParticleSystem;
  15557. /**
  15558. * Adds a new limit velocity gradient
  15559. * @param gradient defines the gradient to use (between 0 and 1)
  15560. * @param factor defines the limit velocity value to affect to the specified gradient
  15561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15562. * @returns the current particle system
  15563. */
  15564. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15565. /**
  15566. * Remove a specific limit velocity gradient
  15567. * @param gradient defines the gradient to remove
  15568. * @returns the current particle system
  15569. */
  15570. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15571. /**
  15572. * Adds a new drag gradient
  15573. * @param gradient defines the gradient to use (between 0 and 1)
  15574. * @param factor defines the drag value to affect to the specified gradient
  15575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15576. * @returns the current particle system
  15577. */
  15578. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15579. /**
  15580. * Remove a specific drag gradient
  15581. * @param gradient defines the gradient to remove
  15582. * @returns the current particle system
  15583. */
  15584. removeDragGradient(gradient: number): IParticleSystem;
  15585. /**
  15586. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15587. * @param gradient defines the gradient to use (between 0 and 1)
  15588. * @param factor defines the emit rate value to affect to the specified gradient
  15589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15590. * @returns the current particle system
  15591. */
  15592. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15593. /**
  15594. * Remove a specific emit rate gradient
  15595. * @param gradient defines the gradient to remove
  15596. * @returns the current particle system
  15597. */
  15598. removeEmitRateGradient(gradient: number): IParticleSystem;
  15599. /**
  15600. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15601. * @param gradient defines the gradient to use (between 0 and 1)
  15602. * @param factor defines the start size value to affect to the specified gradient
  15603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15604. * @returns the current particle system
  15605. */
  15606. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15607. /**
  15608. * Remove a specific start size gradient
  15609. * @param gradient defines the gradient to remove
  15610. * @returns the current particle system
  15611. */
  15612. removeStartSizeGradient(gradient: number): IParticleSystem;
  15613. private _createRampGradientTexture;
  15614. /**
  15615. * Gets the current list of ramp gradients.
  15616. * You must use addRampGradient and removeRampGradient to udpate this list
  15617. * @returns the list of ramp gradients
  15618. */
  15619. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15620. /**
  15621. * Adds a new ramp gradient used to remap particle colors
  15622. * @param gradient defines the gradient to use (between 0 and 1)
  15623. * @param color defines the color to affect to the specified gradient
  15624. * @returns the current particle system
  15625. */
  15626. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15627. /**
  15628. * Remove a specific ramp gradient
  15629. * @param gradient defines the gradient to remove
  15630. * @returns the current particle system
  15631. */
  15632. removeRampGradient(gradient: number): ParticleSystem;
  15633. /**
  15634. * Adds a new color gradient
  15635. * @param gradient defines the gradient to use (between 0 and 1)
  15636. * @param color1 defines the color to affect to the specified gradient
  15637. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15638. * @returns this particle system
  15639. */
  15640. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15641. /**
  15642. * Remove a specific color gradient
  15643. * @param gradient defines the gradient to remove
  15644. * @returns this particle system
  15645. */
  15646. removeColorGradient(gradient: number): IParticleSystem;
  15647. private _fetchR;
  15648. protected _reset(): void;
  15649. private _resetEffect;
  15650. private _createVertexBuffers;
  15651. private _createIndexBuffer;
  15652. /**
  15653. * Gets the maximum number of particles active at the same time.
  15654. * @returns The max number of active particles.
  15655. */
  15656. getCapacity(): number;
  15657. /**
  15658. * Gets whether there are still active particles in the system.
  15659. * @returns True if it is alive, otherwise false.
  15660. */
  15661. isAlive(): boolean;
  15662. /**
  15663. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15664. * @returns True if it has been started, otherwise false.
  15665. */
  15666. isStarted(): boolean;
  15667. private _prepareSubEmitterInternalArray;
  15668. /**
  15669. * Starts the particle system and begins to emit
  15670. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15671. */
  15672. start(delay?: number): void;
  15673. /**
  15674. * Stops the particle system.
  15675. * @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.
  15676. */
  15677. stop(stopSubEmitters?: boolean): void;
  15678. /**
  15679. * Remove all active particles
  15680. */
  15681. reset(): void;
  15682. /**
  15683. * @hidden (for internal use only)
  15684. */
  15685. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15686. /**
  15687. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15688. * Its lifetime will start back at 0.
  15689. */
  15690. recycleParticle: (particle: Particle) => void;
  15691. private _stopSubEmitters;
  15692. private _createParticle;
  15693. private _removeFromRoot;
  15694. private _emitFromParticle;
  15695. private _update;
  15696. /** @hidden */
  15697. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15698. /** @hidden */
  15699. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15700. /** @hidden */
  15701. private _getEffect;
  15702. /**
  15703. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15704. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15705. */
  15706. animate(preWarmOnly?: boolean): void;
  15707. private _appendParticleVertices;
  15708. /**
  15709. * Rebuilds the particle system.
  15710. */
  15711. rebuild(): void;
  15712. /**
  15713. * Is this system ready to be used/rendered
  15714. * @return true if the system is ready
  15715. */
  15716. isReady(): boolean;
  15717. private _render;
  15718. /**
  15719. * Renders the particle system in its current state.
  15720. * @returns the current number of particles
  15721. */
  15722. render(): number;
  15723. /**
  15724. * Disposes the particle system and free the associated resources
  15725. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15726. */
  15727. dispose(disposeTexture?: boolean): void;
  15728. /**
  15729. * Clones the particle system.
  15730. * @param name The name of the cloned object
  15731. * @param newEmitter The new emitter to use
  15732. * @returns the cloned particle system
  15733. */
  15734. clone(name: string, newEmitter: any): ParticleSystem;
  15735. /**
  15736. * Serializes the particle system to a JSON object.
  15737. * @returns the JSON object
  15738. */
  15739. serialize(): any;
  15740. /** @hidden */
  15741. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15742. /** @hidden */
  15743. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15744. /**
  15745. * Parses a JSON object to create a particle system.
  15746. * @param parsedParticleSystem The JSON object to parse
  15747. * @param scene The scene to create the particle system in
  15748. * @param rootUrl The root url to use to load external dependencies like texture
  15749. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15750. * @returns the Parsed particle system
  15751. */
  15752. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15753. }
  15754. }
  15755. declare module "babylonjs/Particles/particle" {
  15756. import { Nullable } from "babylonjs/types";
  15757. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15758. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15759. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15760. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15761. /**
  15762. * A particle represents one of the element emitted by a particle system.
  15763. * This is mainly define by its coordinates, direction, velocity and age.
  15764. */
  15765. export class Particle {
  15766. /**
  15767. * The particle system the particle belongs to.
  15768. */
  15769. particleSystem: ParticleSystem;
  15770. private static _Count;
  15771. /**
  15772. * Unique ID of the particle
  15773. */
  15774. id: number;
  15775. /**
  15776. * The world position of the particle in the scene.
  15777. */
  15778. position: Vector3;
  15779. /**
  15780. * The world direction of the particle in the scene.
  15781. */
  15782. direction: Vector3;
  15783. /**
  15784. * The color of the particle.
  15785. */
  15786. color: Color4;
  15787. /**
  15788. * The color change of the particle per step.
  15789. */
  15790. colorStep: Color4;
  15791. /**
  15792. * Defines how long will the life of the particle be.
  15793. */
  15794. lifeTime: number;
  15795. /**
  15796. * The current age of the particle.
  15797. */
  15798. age: number;
  15799. /**
  15800. * The current size of the particle.
  15801. */
  15802. size: number;
  15803. /**
  15804. * The current scale of the particle.
  15805. */
  15806. scale: Vector2;
  15807. /**
  15808. * The current angle of the particle.
  15809. */
  15810. angle: number;
  15811. /**
  15812. * Defines how fast is the angle changing.
  15813. */
  15814. angularSpeed: number;
  15815. /**
  15816. * Defines the cell index used by the particle to be rendered from a sprite.
  15817. */
  15818. cellIndex: number;
  15819. /**
  15820. * The information required to support color remapping
  15821. */
  15822. remapData: Vector4;
  15823. /** @hidden */
  15824. _randomCellOffset?: number;
  15825. /** @hidden */
  15826. _initialDirection: Nullable<Vector3>;
  15827. /** @hidden */
  15828. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15829. /** @hidden */
  15830. _initialStartSpriteCellID: number;
  15831. /** @hidden */
  15832. _initialEndSpriteCellID: number;
  15833. /** @hidden */
  15834. _currentColorGradient: Nullable<ColorGradient>;
  15835. /** @hidden */
  15836. _currentColor1: Color4;
  15837. /** @hidden */
  15838. _currentColor2: Color4;
  15839. /** @hidden */
  15840. _currentSizeGradient: Nullable<FactorGradient>;
  15841. /** @hidden */
  15842. _currentSize1: number;
  15843. /** @hidden */
  15844. _currentSize2: number;
  15845. /** @hidden */
  15846. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15847. /** @hidden */
  15848. _currentAngularSpeed1: number;
  15849. /** @hidden */
  15850. _currentAngularSpeed2: number;
  15851. /** @hidden */
  15852. _currentVelocityGradient: Nullable<FactorGradient>;
  15853. /** @hidden */
  15854. _currentVelocity1: number;
  15855. /** @hidden */
  15856. _currentVelocity2: number;
  15857. /** @hidden */
  15858. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15859. /** @hidden */
  15860. _currentLimitVelocity1: number;
  15861. /** @hidden */
  15862. _currentLimitVelocity2: number;
  15863. /** @hidden */
  15864. _currentDragGradient: Nullable<FactorGradient>;
  15865. /** @hidden */
  15866. _currentDrag1: number;
  15867. /** @hidden */
  15868. _currentDrag2: number;
  15869. /** @hidden */
  15870. _randomNoiseCoordinates1: Vector3;
  15871. /** @hidden */
  15872. _randomNoiseCoordinates2: Vector3;
  15873. /**
  15874. * Creates a new instance Particle
  15875. * @param particleSystem the particle system the particle belongs to
  15876. */
  15877. constructor(
  15878. /**
  15879. * The particle system the particle belongs to.
  15880. */
  15881. particleSystem: ParticleSystem);
  15882. private updateCellInfoFromSystem;
  15883. /**
  15884. * Defines how the sprite cell index is updated for the particle
  15885. */
  15886. updateCellIndex(): void;
  15887. /** @hidden */
  15888. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15889. /** @hidden */
  15890. _inheritParticleInfoToSubEmitters(): void;
  15891. /** @hidden */
  15892. _reset(): void;
  15893. /**
  15894. * Copy the properties of particle to another one.
  15895. * @param other the particle to copy the information to.
  15896. */
  15897. copyTo(other: Particle): void;
  15898. }
  15899. }
  15900. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15901. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15902. import { Effect } from "babylonjs/Materials/effect";
  15903. import { Particle } from "babylonjs/Particles/particle";
  15904. /**
  15905. * Particle emitter represents a volume emitting particles.
  15906. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15907. */
  15908. export interface IParticleEmitterType {
  15909. /**
  15910. * Called by the particle System when the direction is computed for the created particle.
  15911. * @param worldMatrix is the world matrix of the particle system
  15912. * @param directionToUpdate is the direction vector to update with the result
  15913. * @param particle is the particle we are computed the direction for
  15914. */
  15915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15916. /**
  15917. * Called by the particle System when the position is computed for the created particle.
  15918. * @param worldMatrix is the world matrix of the particle system
  15919. * @param positionToUpdate is the position vector to update with the result
  15920. * @param particle is the particle we are computed the position for
  15921. */
  15922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15923. /**
  15924. * Clones the current emitter and returns a copy of it
  15925. * @returns the new emitter
  15926. */
  15927. clone(): IParticleEmitterType;
  15928. /**
  15929. * Called by the GPUParticleSystem to setup the update shader
  15930. * @param effect defines the update shader
  15931. */
  15932. applyToShader(effect: Effect): void;
  15933. /**
  15934. * Returns a string to use to update the GPU particles update shader
  15935. * @returns the effect defines string
  15936. */
  15937. getEffectDefines(): string;
  15938. /**
  15939. * Returns a string representing the class name
  15940. * @returns a string containing the class name
  15941. */
  15942. getClassName(): string;
  15943. /**
  15944. * Serializes the particle system to a JSON object.
  15945. * @returns the JSON object
  15946. */
  15947. serialize(): any;
  15948. /**
  15949. * Parse properties from a JSON object
  15950. * @param serializationObject defines the JSON object
  15951. */
  15952. parse(serializationObject: any): void;
  15953. }
  15954. }
  15955. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15956. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15957. import { Effect } from "babylonjs/Materials/effect";
  15958. import { Particle } from "babylonjs/Particles/particle";
  15959. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15960. /**
  15961. * Particle emitter emitting particles from the inside of a box.
  15962. * It emits the particles randomly between 2 given directions.
  15963. */
  15964. export class BoxParticleEmitter implements IParticleEmitterType {
  15965. /**
  15966. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15967. */
  15968. direction1: Vector3;
  15969. /**
  15970. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15971. */
  15972. direction2: Vector3;
  15973. /**
  15974. * 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.
  15975. */
  15976. minEmitBox: Vector3;
  15977. /**
  15978. * 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.
  15979. */
  15980. maxEmitBox: Vector3;
  15981. /**
  15982. * Creates a new instance BoxParticleEmitter
  15983. */
  15984. constructor();
  15985. /**
  15986. * Called by the particle System when the direction is computed for the created particle.
  15987. * @param worldMatrix is the world matrix of the particle system
  15988. * @param directionToUpdate is the direction vector to update with the result
  15989. * @param particle is the particle we are computed the direction for
  15990. */
  15991. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15992. /**
  15993. * Called by the particle System when the position is computed for the created particle.
  15994. * @param worldMatrix is the world matrix of the particle system
  15995. * @param positionToUpdate is the position vector to update with the result
  15996. * @param particle is the particle we are computed the position for
  15997. */
  15998. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15999. /**
  16000. * Clones the current emitter and returns a copy of it
  16001. * @returns the new emitter
  16002. */
  16003. clone(): BoxParticleEmitter;
  16004. /**
  16005. * Called by the GPUParticleSystem to setup the update shader
  16006. * @param effect defines the update shader
  16007. */
  16008. applyToShader(effect: Effect): void;
  16009. /**
  16010. * Returns a string to use to update the GPU particles update shader
  16011. * @returns a string containng the defines string
  16012. */
  16013. getEffectDefines(): string;
  16014. /**
  16015. * Returns the string "BoxParticleEmitter"
  16016. * @returns a string containing the class name
  16017. */
  16018. getClassName(): string;
  16019. /**
  16020. * Serializes the particle system to a JSON object.
  16021. * @returns the JSON object
  16022. */
  16023. serialize(): any;
  16024. /**
  16025. * Parse properties from a JSON object
  16026. * @param serializationObject defines the JSON object
  16027. */
  16028. parse(serializationObject: any): void;
  16029. }
  16030. }
  16031. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16032. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16033. import { Effect } from "babylonjs/Materials/effect";
  16034. import { Particle } from "babylonjs/Particles/particle";
  16035. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16036. /**
  16037. * Particle emitter emitting particles from the inside of a cone.
  16038. * It emits the particles alongside the cone volume from the base to the particle.
  16039. * The emission direction might be randomized.
  16040. */
  16041. export class ConeParticleEmitter implements IParticleEmitterType {
  16042. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16043. directionRandomizer: number;
  16044. private _radius;
  16045. private _angle;
  16046. private _height;
  16047. /**
  16048. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16049. */
  16050. radiusRange: number;
  16051. /**
  16052. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16053. */
  16054. heightRange: number;
  16055. /**
  16056. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16057. */
  16058. emitFromSpawnPointOnly: boolean;
  16059. /**
  16060. * Gets or sets the radius of the emission cone
  16061. */
  16062. radius: number;
  16063. /**
  16064. * Gets or sets the angle of the emission cone
  16065. */
  16066. angle: number;
  16067. private _buildHeight;
  16068. /**
  16069. * Creates a new instance ConeParticleEmitter
  16070. * @param radius the radius of the emission cone (1 by default)
  16071. * @param angle the cone base angle (PI by default)
  16072. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16073. */
  16074. constructor(radius?: number, angle?: number,
  16075. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16076. directionRandomizer?: number);
  16077. /**
  16078. * Called by the particle System when the direction is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param directionToUpdate is the direction vector to update with the result
  16081. * @param particle is the particle we are computed the direction for
  16082. */
  16083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16084. /**
  16085. * Called by the particle System when the position is computed for the created particle.
  16086. * @param worldMatrix is the world matrix of the particle system
  16087. * @param positionToUpdate is the position vector to update with the result
  16088. * @param particle is the particle we are computed the position for
  16089. */
  16090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16091. /**
  16092. * Clones the current emitter and returns a copy of it
  16093. * @returns the new emitter
  16094. */
  16095. clone(): ConeParticleEmitter;
  16096. /**
  16097. * Called by the GPUParticleSystem to setup the update shader
  16098. * @param effect defines the update shader
  16099. */
  16100. applyToShader(effect: Effect): void;
  16101. /**
  16102. * Returns a string to use to update the GPU particles update shader
  16103. * @returns a string containng the defines string
  16104. */
  16105. getEffectDefines(): string;
  16106. /**
  16107. * Returns the string "ConeParticleEmitter"
  16108. * @returns a string containing the class name
  16109. */
  16110. getClassName(): string;
  16111. /**
  16112. * Serializes the particle system to a JSON object.
  16113. * @returns the JSON object
  16114. */
  16115. serialize(): any;
  16116. /**
  16117. * Parse properties from a JSON object
  16118. * @param serializationObject defines the JSON object
  16119. */
  16120. parse(serializationObject: any): void;
  16121. }
  16122. }
  16123. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16124. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16125. import { Effect } from "babylonjs/Materials/effect";
  16126. import { Particle } from "babylonjs/Particles/particle";
  16127. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16128. /**
  16129. * Particle emitter emitting particles from the inside of a cylinder.
  16130. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16131. */
  16132. export class CylinderParticleEmitter implements IParticleEmitterType {
  16133. /**
  16134. * The radius of the emission cylinder.
  16135. */
  16136. radius: number;
  16137. /**
  16138. * The height of the emission cylinder.
  16139. */
  16140. height: 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 CylinderParticleEmitter
  16151. * @param radius the radius of the emission cylinder (1 by default)
  16152. * @param height the height of the emission cylinder (1 by default)
  16153. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16154. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16155. */
  16156. constructor(
  16157. /**
  16158. * The radius of the emission cylinder.
  16159. */
  16160. radius?: number,
  16161. /**
  16162. * The height of the emission cylinder.
  16163. */
  16164. height?: number,
  16165. /**
  16166. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16167. */
  16168. radiusRange?: number,
  16169. /**
  16170. * How much to randomize the particle direction [0-1].
  16171. */
  16172. directionRandomizer?: number);
  16173. /**
  16174. * Called by the particle System when the direction is computed for the created particle.
  16175. * @param worldMatrix is the world matrix of the particle system
  16176. * @param directionToUpdate is the direction vector to update with the result
  16177. * @param particle is the particle we are computed the direction for
  16178. */
  16179. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16180. /**
  16181. * Called by the particle System when the position is computed for the created particle.
  16182. * @param worldMatrix is the world matrix of the particle system
  16183. * @param positionToUpdate is the position vector to update with the result
  16184. * @param particle is the particle we are computed the position for
  16185. */
  16186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16187. /**
  16188. * Clones the current emitter and returns a copy of it
  16189. * @returns the new emitter
  16190. */
  16191. clone(): CylinderParticleEmitter;
  16192. /**
  16193. * Called by the GPUParticleSystem to setup the update shader
  16194. * @param effect defines the update shader
  16195. */
  16196. applyToShader(effect: Effect): void;
  16197. /**
  16198. * Returns a string to use to update the GPU particles update shader
  16199. * @returns a string containng the defines string
  16200. */
  16201. getEffectDefines(): string;
  16202. /**
  16203. * Returns the string "CylinderParticleEmitter"
  16204. * @returns a string containing the class name
  16205. */
  16206. getClassName(): string;
  16207. /**
  16208. * Serializes the particle system to a JSON object.
  16209. * @returns the JSON object
  16210. */
  16211. serialize(): any;
  16212. /**
  16213. * Parse properties from a JSON object
  16214. * @param serializationObject defines the JSON object
  16215. */
  16216. parse(serializationObject: any): void;
  16217. }
  16218. /**
  16219. * Particle emitter emitting particles from the inside of a cylinder.
  16220. * It emits the particles randomly between two vectors.
  16221. */
  16222. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16223. /**
  16224. * The min limit of the emission direction.
  16225. */
  16226. direction1: Vector3;
  16227. /**
  16228. * The max limit of the emission direction.
  16229. */
  16230. direction2: Vector3;
  16231. /**
  16232. * Creates a new instance CylinderDirectedParticleEmitter
  16233. * @param radius the radius of the emission cylinder (1 by default)
  16234. * @param height the height of the emission cylinder (1 by default)
  16235. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16236. * @param direction1 the min limit of the emission direction (up vector by default)
  16237. * @param direction2 the max limit of the emission direction (up vector by default)
  16238. */
  16239. constructor(radius?: number, height?: number, radiusRange?: number,
  16240. /**
  16241. * The min limit of the emission direction.
  16242. */
  16243. direction1?: Vector3,
  16244. /**
  16245. * The max limit of the emission direction.
  16246. */
  16247. direction2?: Vector3);
  16248. /**
  16249. * Called by the particle System when the direction is computed for the created particle.
  16250. * @param worldMatrix is the world matrix of the particle system
  16251. * @param directionToUpdate is the direction vector to update with the result
  16252. * @param particle is the particle we are computed the direction for
  16253. */
  16254. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16255. /**
  16256. * Clones the current emitter and returns a copy of it
  16257. * @returns the new emitter
  16258. */
  16259. clone(): CylinderDirectedParticleEmitter;
  16260. /**
  16261. * Called by the GPUParticleSystem to setup the update shader
  16262. * @param effect defines the update shader
  16263. */
  16264. applyToShader(effect: Effect): void;
  16265. /**
  16266. * Returns a string to use to update the GPU particles update shader
  16267. * @returns a string containng the defines string
  16268. */
  16269. getEffectDefines(): string;
  16270. /**
  16271. * Returns the string "CylinderDirectedParticleEmitter"
  16272. * @returns a string containing the class name
  16273. */
  16274. getClassName(): string;
  16275. /**
  16276. * Serializes the particle system to a JSON object.
  16277. * @returns the JSON object
  16278. */
  16279. serialize(): any;
  16280. /**
  16281. * Parse properties from a JSON object
  16282. * @param serializationObject defines the JSON object
  16283. */
  16284. parse(serializationObject: any): void;
  16285. }
  16286. }
  16287. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16288. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16289. import { Effect } from "babylonjs/Materials/effect";
  16290. import { Particle } from "babylonjs/Particles/particle";
  16291. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16292. /**
  16293. * Particle emitter emitting particles from the inside of a hemisphere.
  16294. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16295. */
  16296. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16297. /**
  16298. * The radius of the emission hemisphere.
  16299. */
  16300. radius: number;
  16301. /**
  16302. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16303. */
  16304. radiusRange: number;
  16305. /**
  16306. * How much to randomize the particle direction [0-1].
  16307. */
  16308. directionRandomizer: number;
  16309. /**
  16310. * Creates a new instance HemisphericParticleEmitter
  16311. * @param radius the radius of the emission hemisphere (1 by default)
  16312. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16313. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16314. */
  16315. constructor(
  16316. /**
  16317. * The radius of the emission hemisphere.
  16318. */
  16319. radius?: number,
  16320. /**
  16321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16322. */
  16323. radiusRange?: number,
  16324. /**
  16325. * How much to randomize the particle direction [0-1].
  16326. */
  16327. directionRandomizer?: number);
  16328. /**
  16329. * Called by the particle System when the direction is computed for the created particle.
  16330. * @param worldMatrix is the world matrix of the particle system
  16331. * @param directionToUpdate is the direction vector to update with the result
  16332. * @param particle is the particle we are computed the direction for
  16333. */
  16334. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16335. /**
  16336. * Called by the particle System when the position is computed for the created particle.
  16337. * @param worldMatrix is the world matrix of the particle system
  16338. * @param positionToUpdate is the position vector to update with the result
  16339. * @param particle is the particle we are computed the position for
  16340. */
  16341. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16342. /**
  16343. * Clones the current emitter and returns a copy of it
  16344. * @returns the new emitter
  16345. */
  16346. clone(): HemisphericParticleEmitter;
  16347. /**
  16348. * Called by the GPUParticleSystem to setup the update shader
  16349. * @param effect defines the update shader
  16350. */
  16351. applyToShader(effect: Effect): void;
  16352. /**
  16353. * Returns a string to use to update the GPU particles update shader
  16354. * @returns a string containng the defines string
  16355. */
  16356. getEffectDefines(): string;
  16357. /**
  16358. * Returns the string "HemisphericParticleEmitter"
  16359. * @returns a string containing the class name
  16360. */
  16361. getClassName(): string;
  16362. /**
  16363. * Serializes the particle system to a JSON object.
  16364. * @returns the JSON object
  16365. */
  16366. serialize(): any;
  16367. /**
  16368. * Parse properties from a JSON object
  16369. * @param serializationObject defines the JSON object
  16370. */
  16371. parse(serializationObject: any): void;
  16372. }
  16373. }
  16374. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16375. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16376. import { Effect } from "babylonjs/Materials/effect";
  16377. import { Particle } from "babylonjs/Particles/particle";
  16378. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16379. /**
  16380. * Particle emitter emitting particles from a point.
  16381. * It emits the particles randomly between 2 given directions.
  16382. */
  16383. export class PointParticleEmitter implements IParticleEmitterType {
  16384. /**
  16385. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16386. */
  16387. direction1: Vector3;
  16388. /**
  16389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16390. */
  16391. direction2: Vector3;
  16392. /**
  16393. * Creates a new instance PointParticleEmitter
  16394. */
  16395. constructor();
  16396. /**
  16397. * Called by the particle System when the direction is computed for the created particle.
  16398. * @param worldMatrix is the world matrix of the particle system
  16399. * @param directionToUpdate is the direction vector to update with the result
  16400. * @param particle is the particle we are computed the direction for
  16401. */
  16402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16403. /**
  16404. * Called by the particle System when the position is computed for the created particle.
  16405. * @param worldMatrix is the world matrix of the particle system
  16406. * @param positionToUpdate is the position vector to update with the result
  16407. * @param particle is the particle we are computed the position for
  16408. */
  16409. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16410. /**
  16411. * Clones the current emitter and returns a copy of it
  16412. * @returns the new emitter
  16413. */
  16414. clone(): PointParticleEmitter;
  16415. /**
  16416. * Called by the GPUParticleSystem to setup the update shader
  16417. * @param effect defines the update shader
  16418. */
  16419. applyToShader(effect: Effect): void;
  16420. /**
  16421. * Returns a string to use to update the GPU particles update shader
  16422. * @returns a string containng the defines string
  16423. */
  16424. getEffectDefines(): string;
  16425. /**
  16426. * Returns the string "PointParticleEmitter"
  16427. * @returns a string containing the class name
  16428. */
  16429. getClassName(): string;
  16430. /**
  16431. * Serializes the particle system to a JSON object.
  16432. * @returns the JSON object
  16433. */
  16434. serialize(): any;
  16435. /**
  16436. * Parse properties from a JSON object
  16437. * @param serializationObject defines the JSON object
  16438. */
  16439. parse(serializationObject: any): void;
  16440. }
  16441. }
  16442. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16443. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16444. import { Effect } from "babylonjs/Materials/effect";
  16445. import { Particle } from "babylonjs/Particles/particle";
  16446. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16447. /**
  16448. * Particle emitter emitting particles from the inside of a sphere.
  16449. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16450. */
  16451. export class SphereParticleEmitter implements IParticleEmitterType {
  16452. /**
  16453. * The radius of the emission sphere.
  16454. */
  16455. radius: number;
  16456. /**
  16457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16458. */
  16459. radiusRange: number;
  16460. /**
  16461. * How much to randomize the particle direction [0-1].
  16462. */
  16463. directionRandomizer: number;
  16464. /**
  16465. * Creates a new instance SphereParticleEmitter
  16466. * @param radius the radius of the emission sphere (1 by default)
  16467. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16468. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16469. */
  16470. constructor(
  16471. /**
  16472. * The radius of the emission sphere.
  16473. */
  16474. radius?: number,
  16475. /**
  16476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16477. */
  16478. radiusRange?: number,
  16479. /**
  16480. * How much to randomize the particle direction [0-1].
  16481. */
  16482. directionRandomizer?: number);
  16483. /**
  16484. * Called by the particle System when the direction is computed for the created particle.
  16485. * @param worldMatrix is the world matrix of the particle system
  16486. * @param directionToUpdate is the direction vector to update with the result
  16487. * @param particle is the particle we are computed the direction for
  16488. */
  16489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16490. /**
  16491. * Called by the particle System when the position is computed for the created particle.
  16492. * @param worldMatrix is the world matrix of the particle system
  16493. * @param positionToUpdate is the position vector to update with the result
  16494. * @param particle is the particle we are computed the position for
  16495. */
  16496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16497. /**
  16498. * Clones the current emitter and returns a copy of it
  16499. * @returns the new emitter
  16500. */
  16501. clone(): SphereParticleEmitter;
  16502. /**
  16503. * Called by the GPUParticleSystem to setup the update shader
  16504. * @param effect defines the update shader
  16505. */
  16506. applyToShader(effect: Effect): void;
  16507. /**
  16508. * Returns a string to use to update the GPU particles update shader
  16509. * @returns a string containng the defines string
  16510. */
  16511. getEffectDefines(): string;
  16512. /**
  16513. * Returns the string "SphereParticleEmitter"
  16514. * @returns a string containing the class name
  16515. */
  16516. getClassName(): string;
  16517. /**
  16518. * Serializes the particle system to a JSON object.
  16519. * @returns the JSON object
  16520. */
  16521. serialize(): any;
  16522. /**
  16523. * Parse properties from a JSON object
  16524. * @param serializationObject defines the JSON object
  16525. */
  16526. parse(serializationObject: any): void;
  16527. }
  16528. /**
  16529. * Particle emitter emitting particles from the inside of a sphere.
  16530. * It emits the particles randomly between two vectors.
  16531. */
  16532. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16533. /**
  16534. * The min limit of the emission direction.
  16535. */
  16536. direction1: Vector3;
  16537. /**
  16538. * The max limit of the emission direction.
  16539. */
  16540. direction2: Vector3;
  16541. /**
  16542. * Creates a new instance SphereDirectedParticleEmitter
  16543. * @param radius the radius of the emission sphere (1 by default)
  16544. * @param direction1 the min limit of the emission direction (up vector by default)
  16545. * @param direction2 the max limit of the emission direction (up vector by default)
  16546. */
  16547. constructor(radius?: number,
  16548. /**
  16549. * The min limit of the emission direction.
  16550. */
  16551. direction1?: Vector3,
  16552. /**
  16553. * The max limit of the emission direction.
  16554. */
  16555. direction2?: Vector3);
  16556. /**
  16557. * Called by the particle System when the direction is computed for the created particle.
  16558. * @param worldMatrix is the world matrix of the particle system
  16559. * @param directionToUpdate is the direction vector to update with the result
  16560. * @param particle is the particle we are computed the direction for
  16561. */
  16562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16563. /**
  16564. * Clones the current emitter and returns a copy of it
  16565. * @returns the new emitter
  16566. */
  16567. clone(): SphereDirectedParticleEmitter;
  16568. /**
  16569. * Called by the GPUParticleSystem to setup the update shader
  16570. * @param effect defines the update shader
  16571. */
  16572. applyToShader(effect: Effect): void;
  16573. /**
  16574. * Returns a string to use to update the GPU particles update shader
  16575. * @returns a string containng the defines string
  16576. */
  16577. getEffectDefines(): string;
  16578. /**
  16579. * Returns the string "SphereDirectedParticleEmitter"
  16580. * @returns a string containing the class name
  16581. */
  16582. getClassName(): string;
  16583. /**
  16584. * Serializes the particle system to a JSON object.
  16585. * @returns the JSON object
  16586. */
  16587. serialize(): any;
  16588. /**
  16589. * Parse properties from a JSON object
  16590. * @param serializationObject defines the JSON object
  16591. */
  16592. parse(serializationObject: any): void;
  16593. }
  16594. }
  16595. declare module "babylonjs/Particles/EmitterTypes/index" {
  16596. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16597. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16598. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16599. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16600. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16601. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16602. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16603. }
  16604. declare module "babylonjs/Particles/IParticleSystem" {
  16605. import { Nullable } from "babylonjs/types";
  16606. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16609. import { Texture } from "babylonjs/Materials/Textures/texture";
  16610. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16611. import { Scene } from "babylonjs/scene";
  16612. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16613. import { Animation } from "babylonjs/Animations/animation";
  16614. /**
  16615. * Interface representing a particle system in Babylon.js.
  16616. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16617. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16618. */
  16619. export interface IParticleSystem {
  16620. /**
  16621. * List of animations used by the particle system.
  16622. */
  16623. animations: Animation[];
  16624. /**
  16625. * The id of the Particle system.
  16626. */
  16627. id: string;
  16628. /**
  16629. * The name of the Particle system.
  16630. */
  16631. name: string;
  16632. /**
  16633. * The emitter represents the Mesh or position we are attaching the particle system to.
  16634. */
  16635. emitter: Nullable<AbstractMesh | Vector3>;
  16636. /**
  16637. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16638. */
  16639. isBillboardBased: boolean;
  16640. /**
  16641. * The rendering group used by the Particle system to chose when to render.
  16642. */
  16643. renderingGroupId: number;
  16644. /**
  16645. * The layer mask we are rendering the particles through.
  16646. */
  16647. layerMask: number;
  16648. /**
  16649. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16650. */
  16651. updateSpeed: number;
  16652. /**
  16653. * The amount of time the particle system is running (depends of the overall update speed).
  16654. */
  16655. targetStopDuration: number;
  16656. /**
  16657. * The texture used to render each particle. (this can be a spritesheet)
  16658. */
  16659. particleTexture: Nullable<Texture>;
  16660. /**
  16661. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16662. */
  16663. blendMode: number;
  16664. /**
  16665. * Minimum life time of emitting particles.
  16666. */
  16667. minLifeTime: number;
  16668. /**
  16669. * Maximum life time of emitting particles.
  16670. */
  16671. maxLifeTime: number;
  16672. /**
  16673. * Minimum Size of emitting particles.
  16674. */
  16675. minSize: number;
  16676. /**
  16677. * Maximum Size of emitting particles.
  16678. */
  16679. maxSize: number;
  16680. /**
  16681. * Minimum scale of emitting particles on X axis.
  16682. */
  16683. minScaleX: number;
  16684. /**
  16685. * Maximum scale of emitting particles on X axis.
  16686. */
  16687. maxScaleX: number;
  16688. /**
  16689. * Minimum scale of emitting particles on Y axis.
  16690. */
  16691. minScaleY: number;
  16692. /**
  16693. * Maximum scale of emitting particles on Y axis.
  16694. */
  16695. maxScaleY: number;
  16696. /**
  16697. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16698. */
  16699. color1: Color4;
  16700. /**
  16701. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16702. */
  16703. color2: Color4;
  16704. /**
  16705. * Color the particle will have at the end of its lifetime.
  16706. */
  16707. colorDead: Color4;
  16708. /**
  16709. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16710. */
  16711. emitRate: number;
  16712. /**
  16713. * You can use gravity if you want to give an orientation to your particles.
  16714. */
  16715. gravity: Vector3;
  16716. /**
  16717. * Minimum power of emitting particles.
  16718. */
  16719. minEmitPower: number;
  16720. /**
  16721. * Maximum power of emitting particles.
  16722. */
  16723. maxEmitPower: number;
  16724. /**
  16725. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16726. */
  16727. minAngularSpeed: number;
  16728. /**
  16729. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16730. */
  16731. maxAngularSpeed: number;
  16732. /**
  16733. * Gets or sets the minimal initial rotation in radians.
  16734. */
  16735. minInitialRotation: number;
  16736. /**
  16737. * Gets or sets the maximal initial rotation in radians.
  16738. */
  16739. maxInitialRotation: number;
  16740. /**
  16741. * The particle emitter type defines the emitter used by the particle system.
  16742. * It can be for example box, sphere, or cone...
  16743. */
  16744. particleEmitterType: Nullable<IParticleEmitterType>;
  16745. /**
  16746. * Defines the delay in milliseconds before starting the system (0 by default)
  16747. */
  16748. startDelay: number;
  16749. /**
  16750. * 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
  16751. */
  16752. preWarmCycles: number;
  16753. /**
  16754. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16755. */
  16756. preWarmStepOffset: number;
  16757. /**
  16758. * 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)
  16759. */
  16760. spriteCellChangeSpeed: number;
  16761. /**
  16762. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16763. */
  16764. startSpriteCellID: number;
  16765. /**
  16766. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16767. */
  16768. endSpriteCellID: number;
  16769. /**
  16770. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16771. */
  16772. spriteCellWidth: number;
  16773. /**
  16774. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16775. */
  16776. spriteCellHeight: number;
  16777. /**
  16778. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16779. */
  16780. spriteRandomStartCell: boolean;
  16781. /**
  16782. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16783. */
  16784. isAnimationSheetEnabled: boolean;
  16785. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16786. translationPivot: Vector2;
  16787. /**
  16788. * Gets or sets a texture used to add random noise to particle positions
  16789. */
  16790. noiseTexture: Nullable<BaseTexture>;
  16791. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16792. noiseStrength: Vector3;
  16793. /**
  16794. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16795. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16796. */
  16797. billboardMode: number;
  16798. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16799. limitVelocityDamping: number;
  16800. /**
  16801. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16802. */
  16803. beginAnimationOnStart: boolean;
  16804. /**
  16805. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16806. */
  16807. beginAnimationFrom: number;
  16808. /**
  16809. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16810. */
  16811. beginAnimationTo: number;
  16812. /**
  16813. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16814. */
  16815. beginAnimationLoop: boolean;
  16816. /**
  16817. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16818. */
  16819. disposeOnStop: boolean;
  16820. /**
  16821. * Gets the maximum number of particles active at the same time.
  16822. * @returns The max number of active particles.
  16823. */
  16824. getCapacity(): number;
  16825. /**
  16826. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16827. * @returns True if it has been started, otherwise false.
  16828. */
  16829. isStarted(): boolean;
  16830. /**
  16831. * Animates the particle system for this frame.
  16832. */
  16833. animate(): void;
  16834. /**
  16835. * Renders the particle system in its current state.
  16836. * @returns the current number of particles
  16837. */
  16838. render(): number;
  16839. /**
  16840. * Dispose the particle system and frees its associated resources.
  16841. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16842. */
  16843. dispose(disposeTexture?: boolean): void;
  16844. /**
  16845. * Clones the particle system.
  16846. * @param name The name of the cloned object
  16847. * @param newEmitter The new emitter to use
  16848. * @returns the cloned particle system
  16849. */
  16850. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16851. /**
  16852. * Serializes the particle system to a JSON object.
  16853. * @returns the JSON object
  16854. */
  16855. serialize(): any;
  16856. /**
  16857. * Rebuild the particle system
  16858. */
  16859. rebuild(): void;
  16860. /**
  16861. * Starts the particle system and begins to emit
  16862. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16863. */
  16864. start(delay?: number): void;
  16865. /**
  16866. * Stops the particle system.
  16867. */
  16868. stop(): void;
  16869. /**
  16870. * Remove all active particles
  16871. */
  16872. reset(): void;
  16873. /**
  16874. * Is this system ready to be used/rendered
  16875. * @return true if the system is ready
  16876. */
  16877. isReady(): boolean;
  16878. /**
  16879. * Adds a new color gradient
  16880. * @param gradient defines the gradient to use (between 0 and 1)
  16881. * @param color1 defines the color to affect to the specified gradient
  16882. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16883. * @returns the current particle system
  16884. */
  16885. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16886. /**
  16887. * Remove a specific color gradient
  16888. * @param gradient defines the gradient to remove
  16889. * @returns the current particle system
  16890. */
  16891. removeColorGradient(gradient: number): IParticleSystem;
  16892. /**
  16893. * Adds a new size gradient
  16894. * @param gradient defines the gradient to use (between 0 and 1)
  16895. * @param factor defines the size factor to affect to the specified gradient
  16896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16897. * @returns the current particle system
  16898. */
  16899. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16900. /**
  16901. * Remove a specific size gradient
  16902. * @param gradient defines the gradient to remove
  16903. * @returns the current particle system
  16904. */
  16905. removeSizeGradient(gradient: number): IParticleSystem;
  16906. /**
  16907. * Gets the current list of color gradients.
  16908. * You must use addColorGradient and removeColorGradient to udpate this list
  16909. * @returns the list of color gradients
  16910. */
  16911. getColorGradients(): Nullable<Array<ColorGradient>>;
  16912. /**
  16913. * Gets the current list of size gradients.
  16914. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16915. * @returns the list of size gradients
  16916. */
  16917. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16918. /**
  16919. * Gets the current list of angular speed gradients.
  16920. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16921. * @returns the list of angular speed gradients
  16922. */
  16923. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16924. /**
  16925. * Adds a new angular speed gradient
  16926. * @param gradient defines the gradient to use (between 0 and 1)
  16927. * @param factor defines the angular speed to affect to the specified gradient
  16928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16929. * @returns the current particle system
  16930. */
  16931. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16932. /**
  16933. * Remove a specific angular speed gradient
  16934. * @param gradient defines the gradient to remove
  16935. * @returns the current particle system
  16936. */
  16937. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16938. /**
  16939. * Gets the current list of velocity gradients.
  16940. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16941. * @returns the list of velocity gradients
  16942. */
  16943. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16944. /**
  16945. * Adds a new velocity gradient
  16946. * @param gradient defines the gradient to use (between 0 and 1)
  16947. * @param factor defines the velocity to affect to the specified gradient
  16948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16949. * @returns the current particle system
  16950. */
  16951. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16952. /**
  16953. * Remove a specific velocity gradient
  16954. * @param gradient defines the gradient to remove
  16955. * @returns the current particle system
  16956. */
  16957. removeVelocityGradient(gradient: number): IParticleSystem;
  16958. /**
  16959. * Gets the current list of limit velocity gradients.
  16960. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16961. * @returns the list of limit velocity gradients
  16962. */
  16963. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16964. /**
  16965. * Adds a new limit velocity gradient
  16966. * @param gradient defines the gradient to use (between 0 and 1)
  16967. * @param factor defines the limit velocity to affect to the specified gradient
  16968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16969. * @returns the current particle system
  16970. */
  16971. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16972. /**
  16973. * Remove a specific limit velocity gradient
  16974. * @param gradient defines the gradient to remove
  16975. * @returns the current particle system
  16976. */
  16977. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16978. /**
  16979. * Adds a new drag gradient
  16980. * @param gradient defines the gradient to use (between 0 and 1)
  16981. * @param factor defines the drag to affect to the specified gradient
  16982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16983. * @returns the current particle system
  16984. */
  16985. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16986. /**
  16987. * Remove a specific drag gradient
  16988. * @param gradient defines the gradient to remove
  16989. * @returns the current particle system
  16990. */
  16991. removeDragGradient(gradient: number): IParticleSystem;
  16992. /**
  16993. * Gets the current list of drag gradients.
  16994. * You must use addDragGradient and removeDragGradient to udpate this list
  16995. * @returns the list of drag gradients
  16996. */
  16997. getDragGradients(): Nullable<Array<FactorGradient>>;
  16998. /**
  16999. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17000. * @param gradient defines the gradient to use (between 0 and 1)
  17001. * @param factor defines the emit rate to affect to the specified gradient
  17002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17003. * @returns the current particle system
  17004. */
  17005. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17006. /**
  17007. * Remove a specific emit rate gradient
  17008. * @param gradient defines the gradient to remove
  17009. * @returns the current particle system
  17010. */
  17011. removeEmitRateGradient(gradient: number): IParticleSystem;
  17012. /**
  17013. * Gets the current list of emit rate gradients.
  17014. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17015. * @returns the list of emit rate gradients
  17016. */
  17017. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17018. /**
  17019. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17020. * @param gradient defines the gradient to use (between 0 and 1)
  17021. * @param factor defines the start size to affect to the specified gradient
  17022. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17023. * @returns the current particle system
  17024. */
  17025. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17026. /**
  17027. * Remove a specific start size gradient
  17028. * @param gradient defines the gradient to remove
  17029. * @returns the current particle system
  17030. */
  17031. removeStartSizeGradient(gradient: number): IParticleSystem;
  17032. /**
  17033. * Gets the current list of start size gradients.
  17034. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17035. * @returns the list of start size gradients
  17036. */
  17037. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17038. /**
  17039. * Adds a new life time gradient
  17040. * @param gradient defines the gradient to use (between 0 and 1)
  17041. * @param factor defines the life time factor to affect to the specified gradient
  17042. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17043. * @returns the current particle system
  17044. */
  17045. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17046. /**
  17047. * Remove a specific life time gradient
  17048. * @param gradient defines the gradient to remove
  17049. * @returns the current particle system
  17050. */
  17051. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17052. /**
  17053. * Gets the current list of life time gradients.
  17054. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17055. * @returns the list of life time gradients
  17056. */
  17057. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Gets the current list of color gradients.
  17060. * You must use addColorGradient and removeColorGradient to udpate this list
  17061. * @returns the list of color gradients
  17062. */
  17063. getColorGradients(): Nullable<Array<ColorGradient>>;
  17064. /**
  17065. * Adds a new ramp gradient used to remap particle colors
  17066. * @param gradient defines the gradient to use (between 0 and 1)
  17067. * @param color defines the color to affect to the specified gradient
  17068. * @returns the current particle system
  17069. */
  17070. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17071. /**
  17072. * Gets the current list of ramp gradients.
  17073. * You must use addRampGradient and removeRampGradient to udpate this list
  17074. * @returns the list of ramp gradients
  17075. */
  17076. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17077. /** Gets or sets a boolean indicating that ramp gradients must be used
  17078. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17079. */
  17080. useRampGradients: boolean;
  17081. /**
  17082. * Adds a new color remap gradient
  17083. * @param gradient defines the gradient to use (between 0 and 1)
  17084. * @param min defines the color remap minimal range
  17085. * @param max defines the color remap maximal range
  17086. * @returns the current particle system
  17087. */
  17088. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17089. /**
  17090. * Gets the current list of color remap gradients.
  17091. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17092. * @returns the list of color remap gradients
  17093. */
  17094. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17095. /**
  17096. * Adds a new alpha remap gradient
  17097. * @param gradient defines the gradient to use (between 0 and 1)
  17098. * @param min defines the alpha remap minimal range
  17099. * @param max defines the alpha remap maximal range
  17100. * @returns the current particle system
  17101. */
  17102. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17103. /**
  17104. * Gets the current list of alpha remap gradients.
  17105. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17106. * @returns the list of alpha remap gradients
  17107. */
  17108. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17109. /**
  17110. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17111. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17112. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17113. * @returns the emitter
  17114. */
  17115. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17116. /**
  17117. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17118. * @param radius The radius of the hemisphere to emit from
  17119. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17120. * @returns the emitter
  17121. */
  17122. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17123. /**
  17124. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17125. * @param radius The radius of the sphere to emit from
  17126. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17127. * @returns the emitter
  17128. */
  17129. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17130. /**
  17131. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17132. * @param radius The radius of the sphere to emit from
  17133. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17134. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17135. * @returns the emitter
  17136. */
  17137. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17138. /**
  17139. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17140. * @param radius The radius of the emission cylinder
  17141. * @param height The height of the emission cylinder
  17142. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17143. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17144. * @returns the emitter
  17145. */
  17146. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17147. /**
  17148. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17149. * @param radius The radius of the cylinder to emit from
  17150. * @param height The height of the emission cylinder
  17151. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17152. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17153. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17154. * @returns the emitter
  17155. */
  17156. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17157. /**
  17158. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17159. * @param radius The radius of the cone to emit from
  17160. * @param angle The base angle of the cone
  17161. * @returns the emitter
  17162. */
  17163. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17164. /**
  17165. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17166. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17167. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17168. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17169. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17170. * @returns the emitter
  17171. */
  17172. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17173. /**
  17174. * Get hosting scene
  17175. * @returns the scene
  17176. */
  17177. getScene(): Scene;
  17178. }
  17179. }
  17180. declare module "babylonjs/Meshes/instancedMesh" {
  17181. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17182. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17183. import { Camera } from "babylonjs/Cameras/camera";
  17184. import { Node } from "babylonjs/node";
  17185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17186. import { Mesh } from "babylonjs/Meshes/mesh";
  17187. import { Material } from "babylonjs/Materials/material";
  17188. import { Skeleton } from "babylonjs/Bones/skeleton";
  17189. import { Light } from "babylonjs/Lights/light";
  17190. /**
  17191. * Creates an instance based on a source mesh.
  17192. */
  17193. export class InstancedMesh extends AbstractMesh {
  17194. private _sourceMesh;
  17195. private _currentLOD;
  17196. /** @hidden */
  17197. _indexInSourceMeshInstanceArray: number;
  17198. constructor(name: string, source: Mesh);
  17199. /**
  17200. * Returns the string "InstancedMesh".
  17201. */
  17202. getClassName(): string;
  17203. /** Gets the list of lights affecting that mesh */
  17204. readonly lightSources: Light[];
  17205. _resyncLightSources(): void;
  17206. _resyncLighSource(light: Light): void;
  17207. _removeLightSource(light: Light): void;
  17208. /**
  17209. * If the source mesh receives shadows
  17210. */
  17211. readonly receiveShadows: boolean;
  17212. /**
  17213. * The material of the source mesh
  17214. */
  17215. readonly material: Nullable<Material>;
  17216. /**
  17217. * Visibility of the source mesh
  17218. */
  17219. readonly visibility: number;
  17220. /**
  17221. * Skeleton of the source mesh
  17222. */
  17223. readonly skeleton: Nullable<Skeleton>;
  17224. /**
  17225. * Rendering ground id of the source mesh
  17226. */
  17227. renderingGroupId: number;
  17228. /**
  17229. * Returns the total number of vertices (integer).
  17230. */
  17231. getTotalVertices(): number;
  17232. /**
  17233. * Returns a positive integer : the total number of indices in this mesh geometry.
  17234. * @returns the numner of indices or zero if the mesh has no geometry.
  17235. */
  17236. getTotalIndices(): number;
  17237. /**
  17238. * The source mesh of the instance
  17239. */
  17240. readonly sourceMesh: Mesh;
  17241. /**
  17242. * Is this node ready to be used/rendered
  17243. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17244. * @return {boolean} is it ready
  17245. */
  17246. isReady(completeCheck?: boolean): boolean;
  17247. /**
  17248. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17249. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17250. * @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.
  17251. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17252. */
  17253. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17254. /**
  17255. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17256. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17257. * The `data` are either a numeric array either a Float32Array.
  17258. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17259. * 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).
  17260. * Note that a new underlying VertexBuffer object is created each call.
  17261. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17262. *
  17263. * Possible `kind` values :
  17264. * - VertexBuffer.PositionKind
  17265. * - VertexBuffer.UVKind
  17266. * - VertexBuffer.UV2Kind
  17267. * - VertexBuffer.UV3Kind
  17268. * - VertexBuffer.UV4Kind
  17269. * - VertexBuffer.UV5Kind
  17270. * - VertexBuffer.UV6Kind
  17271. * - VertexBuffer.ColorKind
  17272. * - VertexBuffer.MatricesIndicesKind
  17273. * - VertexBuffer.MatricesIndicesExtraKind
  17274. * - VertexBuffer.MatricesWeightsKind
  17275. * - VertexBuffer.MatricesWeightsExtraKind
  17276. *
  17277. * Returns the Mesh.
  17278. */
  17279. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17280. /**
  17281. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17282. * If the mesh has no geometry, it is simply returned as it is.
  17283. * The `data` are either a numeric array either a Float32Array.
  17284. * No new underlying VertexBuffer object is created.
  17285. * 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.
  17286. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17287. *
  17288. * Possible `kind` values :
  17289. * - VertexBuffer.PositionKind
  17290. * - VertexBuffer.UVKind
  17291. * - VertexBuffer.UV2Kind
  17292. * - VertexBuffer.UV3Kind
  17293. * - VertexBuffer.UV4Kind
  17294. * - VertexBuffer.UV5Kind
  17295. * - VertexBuffer.UV6Kind
  17296. * - VertexBuffer.ColorKind
  17297. * - VertexBuffer.MatricesIndicesKind
  17298. * - VertexBuffer.MatricesIndicesExtraKind
  17299. * - VertexBuffer.MatricesWeightsKind
  17300. * - VertexBuffer.MatricesWeightsExtraKind
  17301. *
  17302. * Returns the Mesh.
  17303. */
  17304. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17305. /**
  17306. * Sets the mesh indices.
  17307. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17308. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17309. * This method creates a new index buffer each call.
  17310. * Returns the Mesh.
  17311. */
  17312. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17313. /**
  17314. * Boolean : True if the mesh owns the requested kind of data.
  17315. */
  17316. isVerticesDataPresent(kind: string): boolean;
  17317. /**
  17318. * Returns an array of indices (IndicesArray).
  17319. */
  17320. getIndices(): Nullable<IndicesArray>;
  17321. readonly _positions: Nullable<Vector3[]>;
  17322. /**
  17323. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17324. * This means the mesh underlying bounding box and sphere are recomputed.
  17325. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17326. * @returns the current mesh
  17327. */
  17328. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17329. /** @hidden */
  17330. _preActivate(): InstancedMesh;
  17331. /** @hidden */
  17332. _activate(renderId: number, intermediateRendering: boolean): boolean;
  17333. /** @hidden */
  17334. _postActivate(): void;
  17335. getWorldMatrix(): Matrix;
  17336. readonly isAnInstance: boolean;
  17337. /**
  17338. * Returns the current associated LOD AbstractMesh.
  17339. */
  17340. getLOD(camera: Camera): AbstractMesh;
  17341. /** @hidden */
  17342. _syncSubMeshes(): InstancedMesh;
  17343. /** @hidden */
  17344. _generatePointsArray(): boolean;
  17345. /**
  17346. * Creates a new InstancedMesh from the current mesh.
  17347. * - name (string) : the cloned mesh name
  17348. * - newParent (optional Node) : the optional Node to parent the clone to.
  17349. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17350. *
  17351. * Returns the clone.
  17352. */
  17353. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17354. /**
  17355. * Disposes the InstancedMesh.
  17356. * Returns nothing.
  17357. */
  17358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17359. }
  17360. }
  17361. declare module "babylonjs/Materials/shaderMaterial" {
  17362. import { Scene } from "babylonjs/scene";
  17363. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17365. import { Mesh } from "babylonjs/Meshes/mesh";
  17366. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17367. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17368. import { Texture } from "babylonjs/Materials/Textures/texture";
  17369. import { Material } from "babylonjs/Materials/material";
  17370. /**
  17371. * Defines the options associated with the creation of a shader material.
  17372. */
  17373. export interface IShaderMaterialOptions {
  17374. /**
  17375. * Does the material work in alpha blend mode
  17376. */
  17377. needAlphaBlending: boolean;
  17378. /**
  17379. * Does the material work in alpha test mode
  17380. */
  17381. needAlphaTesting: boolean;
  17382. /**
  17383. * The list of attribute names used in the shader
  17384. */
  17385. attributes: string[];
  17386. /**
  17387. * The list of unifrom names used in the shader
  17388. */
  17389. uniforms: string[];
  17390. /**
  17391. * The list of UBO names used in the shader
  17392. */
  17393. uniformBuffers: string[];
  17394. /**
  17395. * The list of sampler names used in the shader
  17396. */
  17397. samplers: string[];
  17398. /**
  17399. * The list of defines used in the shader
  17400. */
  17401. defines: string[];
  17402. }
  17403. /**
  17404. * 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.
  17405. *
  17406. * This returned material effects how the mesh will look based on the code in the shaders.
  17407. *
  17408. * @see http://doc.babylonjs.com/how_to/shader_material
  17409. */
  17410. export class ShaderMaterial extends Material {
  17411. private _shaderPath;
  17412. private _options;
  17413. private _textures;
  17414. private _textureArrays;
  17415. private _floats;
  17416. private _ints;
  17417. private _floatsArrays;
  17418. private _colors3;
  17419. private _colors3Arrays;
  17420. private _colors4;
  17421. private _vectors2;
  17422. private _vectors3;
  17423. private _vectors4;
  17424. private _matrices;
  17425. private _matrices3x3;
  17426. private _matrices2x2;
  17427. private _vectors2Arrays;
  17428. private _vectors3Arrays;
  17429. private _cachedWorldViewMatrix;
  17430. private _cachedWorldViewProjectionMatrix;
  17431. private _renderId;
  17432. /**
  17433. * Instantiate a new shader material.
  17434. * 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.
  17435. * This returned material effects how the mesh will look based on the code in the shaders.
  17436. * @see http://doc.babylonjs.com/how_to/shader_material
  17437. * @param name Define the name of the material in the scene
  17438. * @param scene Define the scene the material belongs to
  17439. * @param shaderPath Defines the route to the shader code in one of three ways:
  17440. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17441. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17442. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17443. * @param options Define the options used to create the shader
  17444. */
  17445. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17446. /**
  17447. * Gets the options used to compile the shader.
  17448. * They can be modified to trigger a new compilation
  17449. */
  17450. readonly options: IShaderMaterialOptions;
  17451. /**
  17452. * Gets the current class name of the material e.g. "ShaderMaterial"
  17453. * Mainly use in serialization.
  17454. * @returns the class name
  17455. */
  17456. getClassName(): string;
  17457. /**
  17458. * Specifies if the material will require alpha blending
  17459. * @returns a boolean specifying if alpha blending is needed
  17460. */
  17461. needAlphaBlending(): boolean;
  17462. /**
  17463. * Specifies if this material should be rendered in alpha test mode
  17464. * @returns a boolean specifying if an alpha test is needed.
  17465. */
  17466. needAlphaTesting(): boolean;
  17467. private _checkUniform;
  17468. /**
  17469. * Set a texture in the shader.
  17470. * @param name Define the name of the uniform samplers as defined in the shader
  17471. * @param texture Define the texture to bind to this sampler
  17472. * @return the material itself allowing "fluent" like uniform updates
  17473. */
  17474. setTexture(name: string, texture: Texture): ShaderMaterial;
  17475. /**
  17476. * Set a texture array in the shader.
  17477. * @param name Define the name of the uniform sampler array as defined in the shader
  17478. * @param textures Define the list of textures to bind to this sampler
  17479. * @return the material itself allowing "fluent" like uniform updates
  17480. */
  17481. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17482. /**
  17483. * Set a float in the shader.
  17484. * @param name Define the name of the uniform as defined in the shader
  17485. * @param value Define the value to give to the uniform
  17486. * @return the material itself allowing "fluent" like uniform updates
  17487. */
  17488. setFloat(name: string, value: number): ShaderMaterial;
  17489. /**
  17490. * Set a int in the shader.
  17491. * @param name Define the name of the uniform as defined in the shader
  17492. * @param value Define the value to give to the uniform
  17493. * @return the material itself allowing "fluent" like uniform updates
  17494. */
  17495. setInt(name: string, value: number): ShaderMaterial;
  17496. /**
  17497. * Set an array of floats in the shader.
  17498. * @param name Define the name of the uniform as defined in the shader
  17499. * @param value Define the value to give to the uniform
  17500. * @return the material itself allowing "fluent" like uniform updates
  17501. */
  17502. setFloats(name: string, value: number[]): ShaderMaterial;
  17503. /**
  17504. * Set a vec3 in the shader from a Color3.
  17505. * @param name Define the name of the uniform as defined in the shader
  17506. * @param value Define the value to give to the uniform
  17507. * @return the material itself allowing "fluent" like uniform updates
  17508. */
  17509. setColor3(name: string, value: Color3): ShaderMaterial;
  17510. /**
  17511. * Set a vec3 array in the shader from a Color3 array.
  17512. * @param name Define the name of the uniform as defined in the shader
  17513. * @param value Define the value to give to the uniform
  17514. * @return the material itself allowing "fluent" like uniform updates
  17515. */
  17516. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17517. /**
  17518. * Set a vec4 in the shader from a Color4.
  17519. * @param name Define the name of the uniform as defined in the shader
  17520. * @param value Define the value to give to the uniform
  17521. * @return the material itself allowing "fluent" like uniform updates
  17522. */
  17523. setColor4(name: string, value: Color4): ShaderMaterial;
  17524. /**
  17525. * Set a vec2 in the shader from a Vector2.
  17526. * @param name Define the name of the uniform as defined in the shader
  17527. * @param value Define the value to give to the uniform
  17528. * @return the material itself allowing "fluent" like uniform updates
  17529. */
  17530. setVector2(name: string, value: Vector2): ShaderMaterial;
  17531. /**
  17532. * Set a vec3 in the shader from a Vector3.
  17533. * @param name Define the name of the uniform as defined in the shader
  17534. * @param value Define the value to give to the uniform
  17535. * @return the material itself allowing "fluent" like uniform updates
  17536. */
  17537. setVector3(name: string, value: Vector3): ShaderMaterial;
  17538. /**
  17539. * Set a vec4 in the shader from a Vector4.
  17540. * @param name Define the name of the uniform as defined in the shader
  17541. * @param value Define the value to give to the uniform
  17542. * @return the material itself allowing "fluent" like uniform updates
  17543. */
  17544. setVector4(name: string, value: Vector4): ShaderMaterial;
  17545. /**
  17546. * Set a mat4 in the shader from a Matrix.
  17547. * @param name Define the name of the uniform as defined in the shader
  17548. * @param value Define the value to give to the uniform
  17549. * @return the material itself allowing "fluent" like uniform updates
  17550. */
  17551. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17552. /**
  17553. * Set a mat3 in the shader from a Float32Array.
  17554. * @param name Define the name of the uniform as defined in the shader
  17555. * @param value Define the value to give to the uniform
  17556. * @return the material itself allowing "fluent" like uniform updates
  17557. */
  17558. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17559. /**
  17560. * Set a mat2 in the shader from a Float32Array.
  17561. * @param name Define the name of the uniform as defined in the shader
  17562. * @param value Define the value to give to the uniform
  17563. * @return the material itself allowing "fluent" like uniform updates
  17564. */
  17565. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17566. /**
  17567. * Set a vec2 array in the shader from a number array.
  17568. * @param name Define the name of the uniform as defined in the shader
  17569. * @param value Define the value to give to the uniform
  17570. * @return the material itself allowing "fluent" like uniform updates
  17571. */
  17572. setArray2(name: string, value: number[]): ShaderMaterial;
  17573. /**
  17574. * Set a vec3 array in the shader from a number array.
  17575. * @param name Define the name of the uniform as defined in the shader
  17576. * @param value Define the value to give to the uniform
  17577. * @return the material itself allowing "fluent" like uniform updates
  17578. */
  17579. setArray3(name: string, value: number[]): ShaderMaterial;
  17580. private _checkCache;
  17581. /**
  17582. * Specifies that the submesh is ready to be used
  17583. * @param mesh defines the mesh to check
  17584. * @param subMesh defines which submesh to check
  17585. * @param useInstances specifies that instances should be used
  17586. * @returns a boolean indicating that the submesh is ready or not
  17587. */
  17588. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17589. /**
  17590. * Checks if the material is ready to render the requested mesh
  17591. * @param mesh Define the mesh to render
  17592. * @param useInstances Define whether or not the material is used with instances
  17593. * @returns true if ready, otherwise false
  17594. */
  17595. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17596. /**
  17597. * Binds the world matrix to the material
  17598. * @param world defines the world transformation matrix
  17599. */
  17600. bindOnlyWorldMatrix(world: Matrix): void;
  17601. /**
  17602. * Binds the material to the mesh
  17603. * @param world defines the world transformation matrix
  17604. * @param mesh defines the mesh to bind the material to
  17605. */
  17606. bind(world: Matrix, mesh?: Mesh): void;
  17607. /**
  17608. * Gets the active textures from the material
  17609. * @returns an array of textures
  17610. */
  17611. getActiveTextures(): BaseTexture[];
  17612. /**
  17613. * Specifies if the material uses a texture
  17614. * @param texture defines the texture to check against the material
  17615. * @returns a boolean specifying if the material uses the texture
  17616. */
  17617. hasTexture(texture: BaseTexture): boolean;
  17618. /**
  17619. * Makes a duplicate of the material, and gives it a new name
  17620. * @param name defines the new name for the duplicated material
  17621. * @returns the cloned material
  17622. */
  17623. clone(name: string): ShaderMaterial;
  17624. /**
  17625. * Disposes the material
  17626. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17627. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17628. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17629. */
  17630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17631. /**
  17632. * Serializes this material in a JSON representation
  17633. * @returns the serialized material object
  17634. */
  17635. serialize(): any;
  17636. /**
  17637. * Creates a shader material from parsed shader material data
  17638. * @param source defines the JSON represnetation of the material
  17639. * @param scene defines the hosting scene
  17640. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17641. * @returns a new material
  17642. */
  17643. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17644. }
  17645. }
  17646. declare module "babylonjs/Shaders/color.fragment" {
  17647. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17648. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17649. /** @hidden */
  17650. export var colorPixelShader: {
  17651. name: string;
  17652. shader: string;
  17653. };
  17654. }
  17655. declare module "babylonjs/Shaders/color.vertex" {
  17656. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17657. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17658. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17659. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17660. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17661. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17662. /** @hidden */
  17663. export var colorVertexShader: {
  17664. name: string;
  17665. shader: string;
  17666. };
  17667. }
  17668. declare module "babylonjs/Meshes/linesMesh" {
  17669. import { Nullable } from "babylonjs/types";
  17670. import { Scene } from "babylonjs/scene";
  17671. import { Color3 } from "babylonjs/Maths/math";
  17672. import { Node } from "babylonjs/node";
  17673. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17674. import { Mesh } from "babylonjs/Meshes/mesh";
  17675. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17676. import { Effect } from "babylonjs/Materials/effect";
  17677. import { Material } from "babylonjs/Materials/material";
  17678. import "babylonjs/Shaders/color.fragment";
  17679. import "babylonjs/Shaders/color.vertex";
  17680. /**
  17681. * Line mesh
  17682. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17683. */
  17684. export class LinesMesh extends Mesh {
  17685. /**
  17686. * If vertex color should be applied to the mesh
  17687. */
  17688. readonly useVertexColor?: boolean | undefined;
  17689. /**
  17690. * If vertex alpha should be applied to the mesh
  17691. */
  17692. readonly useVertexAlpha?: boolean | undefined;
  17693. /**
  17694. * Color of the line (Default: White)
  17695. */
  17696. color: Color3;
  17697. /**
  17698. * Alpha of the line (Default: 1)
  17699. */
  17700. alpha: number;
  17701. /**
  17702. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17703. * This margin is expressed in world space coordinates, so its value may vary.
  17704. * Default value is 0.1
  17705. */
  17706. intersectionThreshold: number;
  17707. private _colorShader;
  17708. private color4;
  17709. /**
  17710. * Creates a new LinesMesh
  17711. * @param name defines the name
  17712. * @param scene defines the hosting scene
  17713. * @param parent defines the parent mesh if any
  17714. * @param source defines the optional source LinesMesh used to clone data from
  17715. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17716. * When false, achieved by calling a clone(), also passing False.
  17717. * This will make creation of children, recursive.
  17718. * @param useVertexColor defines if this LinesMesh supports vertex color
  17719. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17720. */
  17721. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17722. /**
  17723. * If vertex color should be applied to the mesh
  17724. */
  17725. useVertexColor?: boolean | undefined,
  17726. /**
  17727. * If vertex alpha should be applied to the mesh
  17728. */
  17729. useVertexAlpha?: boolean | undefined);
  17730. private _addClipPlaneDefine;
  17731. private _removeClipPlaneDefine;
  17732. isReady(): boolean;
  17733. /**
  17734. * Returns the string "LineMesh"
  17735. */
  17736. getClassName(): string;
  17737. /**
  17738. * @hidden
  17739. */
  17740. /**
  17741. * @hidden
  17742. */
  17743. material: Material;
  17744. /**
  17745. * @hidden
  17746. */
  17747. readonly checkCollisions: boolean;
  17748. /** @hidden */
  17749. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17750. /** @hidden */
  17751. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17752. /**
  17753. * Disposes of the line mesh
  17754. * @param doNotRecurse If children should be disposed
  17755. */
  17756. dispose(doNotRecurse?: boolean): void;
  17757. /**
  17758. * Returns a new LineMesh object cloned from the current one.
  17759. */
  17760. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17761. /**
  17762. * Creates a new InstancedLinesMesh object from the mesh model.
  17763. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17764. * @param name defines the name of the new instance
  17765. * @returns a new InstancedLinesMesh
  17766. */
  17767. createInstance(name: string): InstancedLinesMesh;
  17768. }
  17769. /**
  17770. * Creates an instance based on a source LinesMesh
  17771. */
  17772. export class InstancedLinesMesh extends InstancedMesh {
  17773. /**
  17774. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17775. * This margin is expressed in world space coordinates, so its value may vary.
  17776. * Initilized with the intersectionThreshold value of the source LinesMesh
  17777. */
  17778. intersectionThreshold: number;
  17779. constructor(name: string, source: LinesMesh);
  17780. /**
  17781. * Returns the string "InstancedLinesMesh".
  17782. */
  17783. getClassName(): string;
  17784. }
  17785. }
  17786. declare module "babylonjs/Shaders/line.fragment" {
  17787. /** @hidden */
  17788. export var linePixelShader: {
  17789. name: string;
  17790. shader: string;
  17791. };
  17792. }
  17793. declare module "babylonjs/Shaders/line.vertex" {
  17794. /** @hidden */
  17795. export var lineVertexShader: {
  17796. name: string;
  17797. shader: string;
  17798. };
  17799. }
  17800. declare module "babylonjs/Rendering/edgesRenderer" {
  17801. import { Nullable } from "babylonjs/types";
  17802. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17803. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17804. import { Vector3 } from "babylonjs/Maths/math";
  17805. import { IDisposable } from "babylonjs/scene";
  17806. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17807. import "babylonjs/Shaders/line.fragment";
  17808. import "babylonjs/Shaders/line.vertex";
  17809. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17810. module "babylonjs/Meshes/abstractMesh" {
  17811. interface AbstractMesh {
  17812. /**
  17813. * Gets the edgesRenderer associated with the mesh
  17814. */
  17815. edgesRenderer: Nullable<EdgesRenderer>;
  17816. }
  17817. }
  17818. module "babylonjs/Meshes/linesMesh" {
  17819. interface LinesMesh {
  17820. /**
  17821. * Enables the edge rendering mode on the mesh.
  17822. * This mode makes the mesh edges visible
  17823. * @param epsilon defines the maximal distance between two angles to detect a face
  17824. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17825. * @returns the currentAbstractMesh
  17826. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17827. */
  17828. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17829. }
  17830. }
  17831. module "babylonjs/Meshes/linesMesh" {
  17832. interface InstancedLinesMesh {
  17833. /**
  17834. * Enables the edge rendering mode on the mesh.
  17835. * This mode makes the mesh edges visible
  17836. * @param epsilon defines the maximal distance between two angles to detect a face
  17837. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17838. * @returns the current InstancedLinesMesh
  17839. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17840. */
  17841. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17842. }
  17843. }
  17844. /**
  17845. * Defines the minimum contract an Edges renderer should follow.
  17846. */
  17847. export interface IEdgesRenderer extends IDisposable {
  17848. /**
  17849. * Gets or sets a boolean indicating if the edgesRenderer is active
  17850. */
  17851. isEnabled: boolean;
  17852. /**
  17853. * Renders the edges of the attached mesh,
  17854. */
  17855. render(): void;
  17856. /**
  17857. * Checks wether or not the edges renderer is ready to render.
  17858. * @return true if ready, otherwise false.
  17859. */
  17860. isReady(): boolean;
  17861. }
  17862. /**
  17863. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17864. */
  17865. export class EdgesRenderer implements IEdgesRenderer {
  17866. /**
  17867. * Define the size of the edges with an orthographic camera
  17868. */
  17869. edgesWidthScalerForOrthographic: number;
  17870. /**
  17871. * Define the size of the edges with a perspective camera
  17872. */
  17873. edgesWidthScalerForPerspective: number;
  17874. protected _source: AbstractMesh;
  17875. protected _linesPositions: number[];
  17876. protected _linesNormals: number[];
  17877. protected _linesIndices: number[];
  17878. protected _epsilon: number;
  17879. protected _indicesCount: number;
  17880. protected _lineShader: ShaderMaterial;
  17881. protected _ib: DataBuffer;
  17882. protected _buffers: {
  17883. [key: string]: Nullable<VertexBuffer>;
  17884. };
  17885. protected _checkVerticesInsteadOfIndices: boolean;
  17886. private _meshRebuildObserver;
  17887. private _meshDisposeObserver;
  17888. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17889. isEnabled: boolean;
  17890. /**
  17891. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17892. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17893. * @param source Mesh used to create edges
  17894. * @param epsilon sum of angles in adjacency to check for edge
  17895. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17896. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17897. */
  17898. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17899. protected _prepareRessources(): void;
  17900. /** @hidden */
  17901. _rebuild(): void;
  17902. /**
  17903. * Releases the required resources for the edges renderer
  17904. */
  17905. dispose(): void;
  17906. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17907. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17908. /**
  17909. * Checks if the pair of p0 and p1 is en edge
  17910. * @param faceIndex
  17911. * @param edge
  17912. * @param faceNormals
  17913. * @param p0
  17914. * @param p1
  17915. * @private
  17916. */
  17917. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17918. /**
  17919. * push line into the position, normal and index buffer
  17920. * @protected
  17921. */
  17922. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17923. /**
  17924. * Generates lines edges from adjacencjes
  17925. * @private
  17926. */
  17927. _generateEdgesLines(): void;
  17928. /**
  17929. * Checks wether or not the edges renderer is ready to render.
  17930. * @return true if ready, otherwise false.
  17931. */
  17932. isReady(): boolean;
  17933. /**
  17934. * Renders the edges of the attached mesh,
  17935. */
  17936. render(): void;
  17937. }
  17938. /**
  17939. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17940. */
  17941. export class LineEdgesRenderer extends EdgesRenderer {
  17942. /**
  17943. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17944. * @param source LineMesh used to generate edges
  17945. * @param epsilon not important (specified angle for edge detection)
  17946. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17947. */
  17948. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17949. /**
  17950. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17951. */
  17952. _generateEdgesLines(): void;
  17953. }
  17954. }
  17955. declare module "babylonjs/Rendering/renderingGroup" {
  17956. import { SmartArray } from "babylonjs/Misc/smartArray";
  17957. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17959. import { Nullable } from "babylonjs/types";
  17960. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17961. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17962. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17963. import { Material } from "babylonjs/Materials/material";
  17964. import { Scene } from "babylonjs/scene";
  17965. /**
  17966. * This represents the object necessary to create a rendering group.
  17967. * This is exclusively used and created by the rendering manager.
  17968. * To modify the behavior, you use the available helpers in your scene or meshes.
  17969. * @hidden
  17970. */
  17971. export class RenderingGroup {
  17972. index: number;
  17973. private static _zeroVector;
  17974. private _scene;
  17975. private _opaqueSubMeshes;
  17976. private _transparentSubMeshes;
  17977. private _alphaTestSubMeshes;
  17978. private _depthOnlySubMeshes;
  17979. private _particleSystems;
  17980. private _spriteManagers;
  17981. private _opaqueSortCompareFn;
  17982. private _alphaTestSortCompareFn;
  17983. private _transparentSortCompareFn;
  17984. private _renderOpaque;
  17985. private _renderAlphaTest;
  17986. private _renderTransparent;
  17987. /** @hidden */
  17988. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17989. onBeforeTransparentRendering: () => void;
  17990. /**
  17991. * Set the opaque sort comparison function.
  17992. * If null the sub meshes will be render in the order they were created
  17993. */
  17994. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17995. /**
  17996. * Set the alpha test sort comparison function.
  17997. * If null the sub meshes will be render in the order they were created
  17998. */
  17999. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18000. /**
  18001. * Set the transparent sort comparison function.
  18002. * If null the sub meshes will be render in the order they were created
  18003. */
  18004. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  18005. /**
  18006. * Creates a new rendering group.
  18007. * @param index The rendering group index
  18008. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  18009. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  18010. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  18011. */
  18012. 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>);
  18013. /**
  18014. * Render all the sub meshes contained in the group.
  18015. * @param customRenderFunction Used to override the default render behaviour of the group.
  18016. * @returns true if rendered some submeshes.
  18017. */
  18018. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  18019. /**
  18020. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  18021. * @param subMeshes The submeshes to render
  18022. */
  18023. private renderOpaqueSorted;
  18024. /**
  18025. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  18026. * @param subMeshes The submeshes to render
  18027. */
  18028. private renderAlphaTestSorted;
  18029. /**
  18030. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  18031. * @param subMeshes The submeshes to render
  18032. */
  18033. private renderTransparentSorted;
  18034. /**
  18035. * Renders the submeshes in a specified order.
  18036. * @param subMeshes The submeshes to sort before render
  18037. * @param sortCompareFn The comparison function use to sort
  18038. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  18039. * @param transparent Specifies to activate blending if true
  18040. */
  18041. private static renderSorted;
  18042. /**
  18043. * Renders the submeshes in the order they were dispatched (no sort applied).
  18044. * @param subMeshes The submeshes to render
  18045. */
  18046. private static renderUnsorted;
  18047. /**
  18048. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18049. * are rendered back to front if in the same alpha index.
  18050. *
  18051. * @param a The first submesh
  18052. * @param b The second submesh
  18053. * @returns The result of the comparison
  18054. */
  18055. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  18056. /**
  18057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18058. * are rendered back to front.
  18059. *
  18060. * @param a The first submesh
  18061. * @param b The second submesh
  18062. * @returns The result of the comparison
  18063. */
  18064. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  18065. /**
  18066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  18067. * are rendered front to back (prevent overdraw).
  18068. *
  18069. * @param a The first submesh
  18070. * @param b The second submesh
  18071. * @returns The result of the comparison
  18072. */
  18073. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  18074. /**
  18075. * Resets the different lists of submeshes to prepare a new frame.
  18076. */
  18077. prepare(): void;
  18078. dispose(): void;
  18079. /**
  18080. * Inserts the submesh in its correct queue depending on its material.
  18081. * @param subMesh The submesh to dispatch
  18082. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18083. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18084. */
  18085. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18086. dispatchSprites(spriteManager: ISpriteManager): void;
  18087. dispatchParticles(particleSystem: IParticleSystem): void;
  18088. private _renderParticles;
  18089. private _renderSprites;
  18090. }
  18091. }
  18092. declare module "babylonjs/Rendering/renderingManager" {
  18093. import { Nullable } from "babylonjs/types";
  18094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18095. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18096. import { SmartArray } from "babylonjs/Misc/smartArray";
  18097. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18098. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  18099. import { Material } from "babylonjs/Materials/material";
  18100. import { Scene } from "babylonjs/scene";
  18101. import { Camera } from "babylonjs/Cameras/camera";
  18102. /**
  18103. * Interface describing the different options available in the rendering manager
  18104. * regarding Auto Clear between groups.
  18105. */
  18106. export interface IRenderingManagerAutoClearSetup {
  18107. /**
  18108. * Defines whether or not autoclear is enable.
  18109. */
  18110. autoClear: boolean;
  18111. /**
  18112. * Defines whether or not to autoclear the depth buffer.
  18113. */
  18114. depth: boolean;
  18115. /**
  18116. * Defines whether or not to autoclear the stencil buffer.
  18117. */
  18118. stencil: boolean;
  18119. }
  18120. /**
  18121. * This class is used by the onRenderingGroupObservable
  18122. */
  18123. export class RenderingGroupInfo {
  18124. /**
  18125. * The Scene that being rendered
  18126. */
  18127. scene: Scene;
  18128. /**
  18129. * The camera currently used for the rendering pass
  18130. */
  18131. camera: Nullable<Camera>;
  18132. /**
  18133. * The ID of the renderingGroup being processed
  18134. */
  18135. renderingGroupId: number;
  18136. }
  18137. /**
  18138. * This is the manager responsible of all the rendering for meshes sprites and particles.
  18139. * It is enable to manage the different groups as well as the different necessary sort functions.
  18140. * This should not be used directly aside of the few static configurations
  18141. */
  18142. export class RenderingManager {
  18143. /**
  18144. * The max id used for rendering groups (not included)
  18145. */
  18146. static MAX_RENDERINGGROUPS: number;
  18147. /**
  18148. * The min id used for rendering groups (included)
  18149. */
  18150. static MIN_RENDERINGGROUPS: number;
  18151. /**
  18152. * Used to globally prevent autoclearing scenes.
  18153. */
  18154. static AUTOCLEAR: boolean;
  18155. /**
  18156. * @hidden
  18157. */
  18158. _useSceneAutoClearSetup: boolean;
  18159. private _scene;
  18160. private _renderingGroups;
  18161. private _depthStencilBufferAlreadyCleaned;
  18162. private _autoClearDepthStencil;
  18163. private _customOpaqueSortCompareFn;
  18164. private _customAlphaTestSortCompareFn;
  18165. private _customTransparentSortCompareFn;
  18166. private _renderingGroupInfo;
  18167. /**
  18168. * Instantiates a new rendering group for a particular scene
  18169. * @param scene Defines the scene the groups belongs to
  18170. */
  18171. constructor(scene: Scene);
  18172. private _clearDepthStencilBuffer;
  18173. /**
  18174. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18175. * @hidden
  18176. */
  18177. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18178. /**
  18179. * Resets the different information of the group to prepare a new frame
  18180. * @hidden
  18181. */
  18182. reset(): void;
  18183. /**
  18184. * Dispose and release the group and its associated resources.
  18185. * @hidden
  18186. */
  18187. dispose(): void;
  18188. /**
  18189. * Clear the info related to rendering groups preventing retention points during dispose.
  18190. */
  18191. freeRenderingGroups(): void;
  18192. private _prepareRenderingGroup;
  18193. /**
  18194. * Add a sprite manager to the rendering manager in order to render it this frame.
  18195. * @param spriteManager Define the sprite manager to render
  18196. */
  18197. dispatchSprites(spriteManager: ISpriteManager): void;
  18198. /**
  18199. * Add a particle system to the rendering manager in order to render it this frame.
  18200. * @param particleSystem Define the particle system to render
  18201. */
  18202. dispatchParticles(particleSystem: IParticleSystem): void;
  18203. /**
  18204. * Add a submesh to the manager in order to render it this frame
  18205. * @param subMesh The submesh to dispatch
  18206. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18207. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18208. */
  18209. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18210. /**
  18211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18212. * This allowed control for front to back rendering or reversly depending of the special needs.
  18213. *
  18214. * @param renderingGroupId The rendering group id corresponding to its index
  18215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18218. */
  18219. 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;
  18220. /**
  18221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18222. *
  18223. * @param renderingGroupId The rendering group id corresponding to its index
  18224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18227. */
  18228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18229. /**
  18230. * Gets the current auto clear configuration for one rendering group of the rendering
  18231. * manager.
  18232. * @param index the rendering group index to get the information for
  18233. * @returns The auto clear setup for the requested rendering group
  18234. */
  18235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18236. }
  18237. }
  18238. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18239. import { Observable } from "babylonjs/Misc/observable";
  18240. import { SmartArray } from "babylonjs/Misc/smartArray";
  18241. import { Nullable } from "babylonjs/types";
  18242. import { Camera } from "babylonjs/Cameras/camera";
  18243. import { Scene } from "babylonjs/scene";
  18244. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18245. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18247. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18249. import { Texture } from "babylonjs/Materials/Textures/texture";
  18250. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18251. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18252. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18253. import { Engine } from "babylonjs/Engines/engine";
  18254. /**
  18255. * This Helps creating a texture that will be created from a camera in your scene.
  18256. * It is basically a dynamic texture that could be used to create special effects for instance.
  18257. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18258. */
  18259. export class RenderTargetTexture extends Texture {
  18260. isCube: boolean;
  18261. /**
  18262. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18263. */
  18264. static readonly REFRESHRATE_RENDER_ONCE: number;
  18265. /**
  18266. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18267. */
  18268. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18269. /**
  18270. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18271. * the central point of your effect and can save a lot of performances.
  18272. */
  18273. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18274. /**
  18275. * Use this predicate to dynamically define the list of mesh you want to render.
  18276. * If set, the renderList property will be overwritten.
  18277. */
  18278. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18279. private _renderList;
  18280. /**
  18281. * Use this list to define the list of mesh you want to render.
  18282. */
  18283. renderList: Nullable<Array<AbstractMesh>>;
  18284. private _hookArray;
  18285. /**
  18286. * Define if particles should be rendered in your texture.
  18287. */
  18288. renderParticles: boolean;
  18289. /**
  18290. * Define if sprites should be rendered in your texture.
  18291. */
  18292. renderSprites: boolean;
  18293. /**
  18294. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18295. */
  18296. coordinatesMode: number;
  18297. /**
  18298. * Define the camera used to render the texture.
  18299. */
  18300. activeCamera: Nullable<Camera>;
  18301. /**
  18302. * Override the render function of the texture with your own one.
  18303. */
  18304. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18305. /**
  18306. * Define if camera post processes should be use while rendering the texture.
  18307. */
  18308. useCameraPostProcesses: boolean;
  18309. /**
  18310. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18311. */
  18312. ignoreCameraViewport: boolean;
  18313. private _postProcessManager;
  18314. private _postProcesses;
  18315. private _resizeObserver;
  18316. /**
  18317. * An event triggered when the texture is unbind.
  18318. */
  18319. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18320. /**
  18321. * An event triggered when the texture is unbind.
  18322. */
  18323. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18324. private _onAfterUnbindObserver;
  18325. /**
  18326. * Set a after unbind callback in the texture.
  18327. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18328. */
  18329. onAfterUnbind: () => void;
  18330. /**
  18331. * An event triggered before rendering the texture
  18332. */
  18333. onBeforeRenderObservable: Observable<number>;
  18334. private _onBeforeRenderObserver;
  18335. /**
  18336. * Set a before render callback in the texture.
  18337. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18338. */
  18339. onBeforeRender: (faceIndex: number) => void;
  18340. /**
  18341. * An event triggered after rendering the texture
  18342. */
  18343. onAfterRenderObservable: Observable<number>;
  18344. private _onAfterRenderObserver;
  18345. /**
  18346. * Set a after render callback in the texture.
  18347. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18348. */
  18349. onAfterRender: (faceIndex: number) => void;
  18350. /**
  18351. * An event triggered after the texture clear
  18352. */
  18353. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18354. private _onClearObserver;
  18355. /**
  18356. * Set a clear callback in the texture.
  18357. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18358. */
  18359. onClear: (Engine: Engine) => void;
  18360. /**
  18361. * Define the clear color of the Render Target if it should be different from the scene.
  18362. */
  18363. clearColor: Color4;
  18364. protected _size: number | {
  18365. width: number;
  18366. height: number;
  18367. };
  18368. protected _initialSizeParameter: number | {
  18369. width: number;
  18370. height: number;
  18371. } | {
  18372. ratio: number;
  18373. };
  18374. protected _sizeRatio: Nullable<number>;
  18375. /** @hidden */
  18376. _generateMipMaps: boolean;
  18377. protected _renderingManager: RenderingManager;
  18378. /** @hidden */
  18379. _waitingRenderList: string[];
  18380. protected _doNotChangeAspectRatio: boolean;
  18381. protected _currentRefreshId: number;
  18382. protected _refreshRate: number;
  18383. protected _textureMatrix: Matrix;
  18384. protected _samples: number;
  18385. protected _renderTargetOptions: RenderTargetCreationOptions;
  18386. /**
  18387. * Gets render target creation options that were used.
  18388. */
  18389. readonly renderTargetOptions: RenderTargetCreationOptions;
  18390. protected _engine: Engine;
  18391. protected _onRatioRescale(): void;
  18392. /**
  18393. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18394. * It must define where the camera used to render the texture is set
  18395. */
  18396. boundingBoxPosition: Vector3;
  18397. private _boundingBoxSize;
  18398. /**
  18399. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18400. * When defined, the cubemap will switch to local mode
  18401. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18402. * @example https://www.babylonjs-playground.com/#RNASML
  18403. */
  18404. boundingBoxSize: Vector3;
  18405. /**
  18406. * In case the RTT has been created with a depth texture, get the associated
  18407. * depth texture.
  18408. * Otherwise, return null.
  18409. */
  18410. depthStencilTexture: Nullable<InternalTexture>;
  18411. /**
  18412. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18413. * or used a shadow, depth texture...
  18414. * @param name The friendly name of the texture
  18415. * @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)
  18416. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18417. * @param generateMipMaps True if mip maps need to be generated after render.
  18418. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18419. * @param type The type of the buffer in the RTT (int, half float, float...)
  18420. * @param isCube True if a cube texture needs to be created
  18421. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18422. * @param generateDepthBuffer True to generate a depth buffer
  18423. * @param generateStencilBuffer True to generate a stencil buffer
  18424. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18425. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18426. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18427. */
  18428. constructor(name: string, size: number | {
  18429. width: number;
  18430. height: number;
  18431. } | {
  18432. ratio: number;
  18433. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18434. /**
  18435. * Creates a depth stencil texture.
  18436. * This is only available in WebGL 2 or with the depth texture extension available.
  18437. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18438. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18439. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18440. */
  18441. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18442. private _processSizeParameter;
  18443. /**
  18444. * Define the number of samples to use in case of MSAA.
  18445. * It defaults to one meaning no MSAA has been enabled.
  18446. */
  18447. samples: number;
  18448. /**
  18449. * Resets the refresh counter of the texture and start bak from scratch.
  18450. * Could be useful to regenerate the texture if it is setup to render only once.
  18451. */
  18452. resetRefreshCounter(): void;
  18453. /**
  18454. * Define the refresh rate of the texture or the rendering frequency.
  18455. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18456. */
  18457. refreshRate: number;
  18458. /**
  18459. * Adds a post process to the render target rendering passes.
  18460. * @param postProcess define the post process to add
  18461. */
  18462. addPostProcess(postProcess: PostProcess): void;
  18463. /**
  18464. * Clear all the post processes attached to the render target
  18465. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18466. */
  18467. clearPostProcesses(dispose?: boolean): void;
  18468. /**
  18469. * Remove one of the post process from the list of attached post processes to the texture
  18470. * @param postProcess define the post process to remove from the list
  18471. */
  18472. removePostProcess(postProcess: PostProcess): void;
  18473. /** @hidden */
  18474. _shouldRender(): boolean;
  18475. /**
  18476. * Gets the actual render size of the texture.
  18477. * @returns the width of the render size
  18478. */
  18479. getRenderSize(): number;
  18480. /**
  18481. * Gets the actual render width of the texture.
  18482. * @returns the width of the render size
  18483. */
  18484. getRenderWidth(): number;
  18485. /**
  18486. * Gets the actual render height of the texture.
  18487. * @returns the height of the render size
  18488. */
  18489. getRenderHeight(): number;
  18490. /**
  18491. * Get if the texture can be rescaled or not.
  18492. */
  18493. readonly canRescale: boolean;
  18494. /**
  18495. * Resize the texture using a ratio.
  18496. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18497. */
  18498. scale(ratio: number): void;
  18499. /**
  18500. * Get the texture reflection matrix used to rotate/transform the reflection.
  18501. * @returns the reflection matrix
  18502. */
  18503. getReflectionTextureMatrix(): Matrix;
  18504. /**
  18505. * Resize the texture to a new desired size.
  18506. * Be carrefull as it will recreate all the data in the new texture.
  18507. * @param size Define the new size. It can be:
  18508. * - a number for squared texture,
  18509. * - an object containing { width: number, height: number }
  18510. * - or an object containing a ratio { ratio: number }
  18511. */
  18512. resize(size: number | {
  18513. width: number;
  18514. height: number;
  18515. } | {
  18516. ratio: number;
  18517. }): void;
  18518. /**
  18519. * Renders all the objects from the render list into the texture.
  18520. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18521. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18522. */
  18523. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18524. private _bestReflectionRenderTargetDimension;
  18525. /**
  18526. * @hidden
  18527. * @param faceIndex face index to bind to if this is a cubetexture
  18528. */
  18529. _bindFrameBuffer(faceIndex?: number): void;
  18530. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18531. private renderToTarget;
  18532. /**
  18533. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18534. * This allowed control for front to back rendering or reversly depending of the special needs.
  18535. *
  18536. * @param renderingGroupId The rendering group id corresponding to its index
  18537. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18538. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18539. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18540. */
  18541. 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;
  18542. /**
  18543. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18544. *
  18545. * @param renderingGroupId The rendering group id corresponding to its index
  18546. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18547. */
  18548. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18549. /**
  18550. * Clones the texture.
  18551. * @returns the cloned texture
  18552. */
  18553. clone(): RenderTargetTexture;
  18554. /**
  18555. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18556. * @returns The JSON representation of the texture
  18557. */
  18558. serialize(): any;
  18559. /**
  18560. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18561. */
  18562. disposeFramebufferObjects(): void;
  18563. /**
  18564. * Dispose the texture and release its associated resources.
  18565. */
  18566. dispose(): void;
  18567. /** @hidden */
  18568. _rebuild(): void;
  18569. /**
  18570. * Clear the info related to rendering groups preventing retention point in material dispose.
  18571. */
  18572. freeRenderingGroups(): void;
  18573. /**
  18574. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18575. * @returns the view count
  18576. */
  18577. getViewCount(): number;
  18578. }
  18579. }
  18580. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18581. import { Scene } from "babylonjs/scene";
  18582. import { Plane } from "babylonjs/Maths/math";
  18583. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18584. /**
  18585. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18586. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18587. * You can then easily use it as a reflectionTexture on a flat surface.
  18588. * In case the surface is not a plane, please consider relying on reflection probes.
  18589. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18590. */
  18591. export class MirrorTexture extends RenderTargetTexture {
  18592. private scene;
  18593. /**
  18594. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18595. * 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.
  18596. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18597. */
  18598. mirrorPlane: Plane;
  18599. /**
  18600. * Define the blur ratio used to blur the reflection if needed.
  18601. */
  18602. blurRatio: number;
  18603. /**
  18604. * Define the adaptive blur kernel used to blur the reflection if needed.
  18605. * This will autocompute the closest best match for the `blurKernel`
  18606. */
  18607. adaptiveBlurKernel: number;
  18608. /**
  18609. * Define the blur kernel used to blur the reflection if needed.
  18610. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18611. */
  18612. blurKernel: number;
  18613. /**
  18614. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18615. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18616. */
  18617. blurKernelX: number;
  18618. /**
  18619. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18620. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18621. */
  18622. blurKernelY: number;
  18623. private _autoComputeBlurKernel;
  18624. protected _onRatioRescale(): void;
  18625. private _updateGammaSpace;
  18626. private _imageProcessingConfigChangeObserver;
  18627. private _transformMatrix;
  18628. private _mirrorMatrix;
  18629. private _savedViewMatrix;
  18630. private _blurX;
  18631. private _blurY;
  18632. private _adaptiveBlurKernel;
  18633. private _blurKernelX;
  18634. private _blurKernelY;
  18635. private _blurRatio;
  18636. /**
  18637. * Instantiates a Mirror Texture.
  18638. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18639. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18640. * You can then easily use it as a reflectionTexture on a flat surface.
  18641. * In case the surface is not a plane, please consider relying on reflection probes.
  18642. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18643. * @param name
  18644. * @param size
  18645. * @param scene
  18646. * @param generateMipMaps
  18647. * @param type
  18648. * @param samplingMode
  18649. * @param generateDepthBuffer
  18650. */
  18651. constructor(name: string, size: number | {
  18652. width: number;
  18653. height: number;
  18654. } | {
  18655. ratio: number;
  18656. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18657. private _preparePostProcesses;
  18658. /**
  18659. * Clone the mirror texture.
  18660. * @returns the cloned texture
  18661. */
  18662. clone(): MirrorTexture;
  18663. /**
  18664. * Serialize the texture to a JSON representation you could use in Parse later on
  18665. * @returns the serialized JSON representation
  18666. */
  18667. serialize(): any;
  18668. /**
  18669. * Dispose the texture and release its associated resources.
  18670. */
  18671. dispose(): void;
  18672. }
  18673. }
  18674. declare module "babylonjs/Materials/Textures/texture" {
  18675. import { Observable } from "babylonjs/Misc/observable";
  18676. import { Nullable } from "babylonjs/types";
  18677. import { Scene } from "babylonjs/scene";
  18678. import { Matrix } from "babylonjs/Maths/math";
  18679. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18680. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18681. /**
  18682. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18683. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18684. */
  18685. export class Texture extends BaseTexture {
  18686. /** @hidden */
  18687. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18688. /** @hidden */
  18689. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18690. /** @hidden */
  18691. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18692. /** nearest is mag = nearest and min = nearest and mip = linear */
  18693. static readonly NEAREST_SAMPLINGMODE: number;
  18694. /** nearest is mag = nearest and min = nearest and mip = linear */
  18695. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18696. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18697. static readonly BILINEAR_SAMPLINGMODE: number;
  18698. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18699. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18700. /** Trilinear is mag = linear and min = linear and mip = linear */
  18701. static readonly TRILINEAR_SAMPLINGMODE: number;
  18702. /** Trilinear is mag = linear and min = linear and mip = linear */
  18703. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18704. /** mag = nearest and min = nearest and mip = nearest */
  18705. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18706. /** mag = nearest and min = linear and mip = nearest */
  18707. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18708. /** mag = nearest and min = linear and mip = linear */
  18709. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18710. /** mag = nearest and min = linear and mip = none */
  18711. static readonly NEAREST_LINEAR: number;
  18712. /** mag = nearest and min = nearest and mip = none */
  18713. static readonly NEAREST_NEAREST: number;
  18714. /** mag = linear and min = nearest and mip = nearest */
  18715. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18716. /** mag = linear and min = nearest and mip = linear */
  18717. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18718. /** mag = linear and min = linear and mip = none */
  18719. static readonly LINEAR_LINEAR: number;
  18720. /** mag = linear and min = nearest and mip = none */
  18721. static readonly LINEAR_NEAREST: number;
  18722. /** Explicit coordinates mode */
  18723. static readonly EXPLICIT_MODE: number;
  18724. /** Spherical coordinates mode */
  18725. static readonly SPHERICAL_MODE: number;
  18726. /** Planar coordinates mode */
  18727. static readonly PLANAR_MODE: number;
  18728. /** Cubic coordinates mode */
  18729. static readonly CUBIC_MODE: number;
  18730. /** Projection coordinates mode */
  18731. static readonly PROJECTION_MODE: number;
  18732. /** Inverse Cubic coordinates mode */
  18733. static readonly SKYBOX_MODE: number;
  18734. /** Inverse Cubic coordinates mode */
  18735. static readonly INVCUBIC_MODE: number;
  18736. /** Equirectangular coordinates mode */
  18737. static readonly EQUIRECTANGULAR_MODE: number;
  18738. /** Equirectangular Fixed coordinates mode */
  18739. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18740. /** Equirectangular Fixed Mirrored coordinates mode */
  18741. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18742. /** Texture is not repeating outside of 0..1 UVs */
  18743. static readonly CLAMP_ADDRESSMODE: number;
  18744. /** Texture is repeating outside of 0..1 UVs */
  18745. static readonly WRAP_ADDRESSMODE: number;
  18746. /** Texture is repeating and mirrored */
  18747. static readonly MIRROR_ADDRESSMODE: number;
  18748. /**
  18749. * 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
  18750. */
  18751. static UseSerializedUrlIfAny: boolean;
  18752. /**
  18753. * Define the url of the texture.
  18754. */
  18755. url: Nullable<string>;
  18756. /**
  18757. * Define an offset on the texture to offset the u coordinates of the UVs
  18758. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18759. */
  18760. uOffset: number;
  18761. /**
  18762. * Define an offset on the texture to offset the v coordinates of the UVs
  18763. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18764. */
  18765. vOffset: number;
  18766. /**
  18767. * Define an offset on the texture to scale the u coordinates of the UVs
  18768. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18769. */
  18770. uScale: number;
  18771. /**
  18772. * Define an offset on the texture to scale the v coordinates of the UVs
  18773. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18774. */
  18775. vScale: number;
  18776. /**
  18777. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18778. * @see http://doc.babylonjs.com/how_to/more_materials
  18779. */
  18780. uAng: number;
  18781. /**
  18782. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18783. * @see http://doc.babylonjs.com/how_to/more_materials
  18784. */
  18785. vAng: number;
  18786. /**
  18787. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18788. * @see http://doc.babylonjs.com/how_to/more_materials
  18789. */
  18790. wAng: number;
  18791. /**
  18792. * Defines the center of rotation (U)
  18793. */
  18794. uRotationCenter: number;
  18795. /**
  18796. * Defines the center of rotation (V)
  18797. */
  18798. vRotationCenter: number;
  18799. /**
  18800. * Defines the center of rotation (W)
  18801. */
  18802. wRotationCenter: number;
  18803. /**
  18804. * Are mip maps generated for this texture or not.
  18805. */
  18806. readonly noMipmap: boolean;
  18807. /**
  18808. * List of inspectable custom properties (used by the Inspector)
  18809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18810. */
  18811. inspectableCustomProperties: Nullable<IInspectable[]>;
  18812. private _noMipmap;
  18813. /** @hidden */
  18814. _invertY: boolean;
  18815. private _rowGenerationMatrix;
  18816. private _cachedTextureMatrix;
  18817. private _projectionModeMatrix;
  18818. private _t0;
  18819. private _t1;
  18820. private _t2;
  18821. private _cachedUOffset;
  18822. private _cachedVOffset;
  18823. private _cachedUScale;
  18824. private _cachedVScale;
  18825. private _cachedUAng;
  18826. private _cachedVAng;
  18827. private _cachedWAng;
  18828. private _cachedProjectionMatrixId;
  18829. private _cachedCoordinatesMode;
  18830. /** @hidden */
  18831. protected _initialSamplingMode: number;
  18832. /** @hidden */
  18833. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18834. private _deleteBuffer;
  18835. protected _format: Nullable<number>;
  18836. private _delayedOnLoad;
  18837. private _delayedOnError;
  18838. /**
  18839. * Observable triggered once the texture has been loaded.
  18840. */
  18841. onLoadObservable: Observable<Texture>;
  18842. protected _isBlocking: boolean;
  18843. /**
  18844. * Is the texture preventing material to render while loading.
  18845. * If false, a default texture will be used instead of the loading one during the preparation step.
  18846. */
  18847. isBlocking: boolean;
  18848. /**
  18849. * Get the current sampling mode associated with the texture.
  18850. */
  18851. readonly samplingMode: number;
  18852. /**
  18853. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18854. */
  18855. readonly invertY: boolean;
  18856. /**
  18857. * Instantiates a new texture.
  18858. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18859. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18860. * @param url define the url of the picture to load as a texture
  18861. * @param scene define the scene the texture will belong to
  18862. * @param noMipmap define if the texture will require mip maps or not
  18863. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18864. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18865. * @param onLoad define a callback triggered when the texture has been loaded
  18866. * @param onError define a callback triggered when an error occurred during the loading session
  18867. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18868. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18869. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18870. */
  18871. 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);
  18872. /**
  18873. * Update the url (and optional buffer) of this texture if url was null during construction.
  18874. * @param url the url of the texture
  18875. * @param buffer the buffer of the texture (defaults to null)
  18876. * @param onLoad callback called when the texture is loaded (defaults to null)
  18877. */
  18878. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18879. /**
  18880. * Finish the loading sequence of a texture flagged as delayed load.
  18881. * @hidden
  18882. */
  18883. delayLoad(): void;
  18884. private _prepareRowForTextureGeneration;
  18885. /**
  18886. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18887. * @returns the transform matrix of the texture.
  18888. */
  18889. getTextureMatrix(): Matrix;
  18890. /**
  18891. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18892. * @returns The reflection texture transform
  18893. */
  18894. getReflectionTextureMatrix(): Matrix;
  18895. /**
  18896. * Clones the texture.
  18897. * @returns the cloned texture
  18898. */
  18899. clone(): Texture;
  18900. /**
  18901. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18902. * @returns The JSON representation of the texture
  18903. */
  18904. serialize(): any;
  18905. /**
  18906. * Get the current class name of the texture useful for serialization or dynamic coding.
  18907. * @returns "Texture"
  18908. */
  18909. getClassName(): string;
  18910. /**
  18911. * Dispose the texture and release its associated resources.
  18912. */
  18913. dispose(): void;
  18914. /**
  18915. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18916. * @param parsedTexture Define the JSON representation of the texture
  18917. * @param scene Define the scene the parsed texture should be instantiated in
  18918. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18919. * @returns The parsed texture if successful
  18920. */
  18921. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18922. /**
  18923. * Creates a texture from its base 64 representation.
  18924. * @param data Define the base64 payload without the data: prefix
  18925. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18926. * @param scene Define the scene the texture should belong to
  18927. * @param noMipmap Forces the texture to not create mip map information if true
  18928. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18929. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18930. * @param onLoad define a callback triggered when the texture has been loaded
  18931. * @param onError define a callback triggered when an error occurred during the loading session
  18932. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18933. * @returns the created texture
  18934. */
  18935. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18936. /**
  18937. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18938. * @param data Define the base64 payload without the data: prefix
  18939. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18940. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18941. * @param scene Define the scene the texture should belong to
  18942. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18943. * @param noMipmap Forces the texture to not create mip map information if true
  18944. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18945. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18946. * @param onLoad define a callback triggered when the texture has been loaded
  18947. * @param onError define a callback triggered when an error occurred during the loading session
  18948. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18949. * @returns the created texture
  18950. */
  18951. 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;
  18952. }
  18953. }
  18954. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18955. import { Nullable } from "babylonjs/types";
  18956. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18957. import { Scene } from "babylonjs/scene";
  18958. module "babylonjs/Engines/engine" {
  18959. interface Engine {
  18960. /**
  18961. * Creates a raw texture
  18962. * @param data defines the data to store in the texture
  18963. * @param width defines the width of the texture
  18964. * @param height defines the height of the texture
  18965. * @param format defines the format of the data
  18966. * @param generateMipMaps defines if the engine should generate the mip levels
  18967. * @param invertY defines if data must be stored with Y axis inverted
  18968. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18969. * @param compression defines the compression used (null by default)
  18970. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18971. * @returns the raw texture inside an InternalTexture
  18972. */
  18973. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18974. /**
  18975. * Update a raw texture
  18976. * @param texture defines the texture to update
  18977. * @param data defines the data to store in the texture
  18978. * @param format defines the format of the data
  18979. * @param invertY defines if data must be stored with Y axis inverted
  18980. */
  18981. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18982. /**
  18983. * Update a raw texture
  18984. * @param texture defines the texture to update
  18985. * @param data defines the data to store in the texture
  18986. * @param format defines the format of the data
  18987. * @param invertY defines if data must be stored with Y axis inverted
  18988. * @param compression defines the compression used (null by default)
  18989. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18990. */
  18991. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18992. /**
  18993. * Creates a new raw cube texture
  18994. * @param data defines the array of data to use to create each face
  18995. * @param size defines the size of the textures
  18996. * @param format defines the format of the data
  18997. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18998. * @param generateMipMaps defines if the engine should generate the mip levels
  18999. * @param invertY defines if data must be stored with Y axis inverted
  19000. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19001. * @param compression defines the compression used (null by default)
  19002. * @returns the cube texture as an InternalTexture
  19003. */
  19004. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  19005. /**
  19006. * Update a raw cube texture
  19007. * @param texture defines the texture to udpdate
  19008. * @param data defines the data to store
  19009. * @param format defines the data format
  19010. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19011. * @param invertY defines if data must be stored with Y axis inverted
  19012. */
  19013. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  19014. /**
  19015. * Update a raw cube texture
  19016. * @param texture defines the texture to udpdate
  19017. * @param data defines the data to store
  19018. * @param format defines the data format
  19019. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19020. * @param invertY defines if data must be stored with Y axis inverted
  19021. * @param compression defines the compression used (null by default)
  19022. */
  19023. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  19024. /**
  19025. * Update a raw cube texture
  19026. * @param texture defines the texture to udpdate
  19027. * @param data defines the data to store
  19028. * @param format defines the data format
  19029. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  19030. * @param invertY defines if data must be stored with Y axis inverted
  19031. * @param compression defines the compression used (null by default)
  19032. * @param level defines which level of the texture to update
  19033. */
  19034. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  19035. /**
  19036. * Creates a new raw cube texture from a specified url
  19037. * @param url defines the url where the data is located
  19038. * @param scene defines the current scene
  19039. * @param size defines the size of the textures
  19040. * @param format defines the format of the data
  19041. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19042. * @param noMipmap defines if the engine should avoid generating the mip levels
  19043. * @param callback defines a callback used to extract texture data from loaded data
  19044. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19045. * @param onLoad defines a callback called when texture is loaded
  19046. * @param onError defines a callback called if there is an error
  19047. * @returns the cube texture as an InternalTexture
  19048. */
  19049. 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>): InternalTexture;
  19050. /**
  19051. * Creates a new raw cube texture from a specified url
  19052. * @param url defines the url where the data is located
  19053. * @param scene defines the current scene
  19054. * @param size defines the size of the textures
  19055. * @param format defines the format of the data
  19056. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  19057. * @param noMipmap defines if the engine should avoid generating the mip levels
  19058. * @param callback defines a callback used to extract texture data from loaded data
  19059. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  19060. * @param onLoad defines a callback called when texture is loaded
  19061. * @param onError defines a callback called if there is an error
  19062. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19063. * @param invertY defines if data must be stored with Y axis inverted
  19064. * @returns the cube texture as an InternalTexture
  19065. */
  19066. 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;
  19067. /**
  19068. * Creates a new raw 3D texture
  19069. * @param data defines the data used to create the texture
  19070. * @param width defines the width of the texture
  19071. * @param height defines the height of the texture
  19072. * @param depth defines the depth of the texture
  19073. * @param format defines the format of the texture
  19074. * @param generateMipMaps defines if the engine must generate mip levels
  19075. * @param invertY defines if data must be stored with Y axis inverted
  19076. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  19077. * @param compression defines the compressed used (can be null)
  19078. * @param textureType defines the compressed used (can be null)
  19079. * @returns a new raw 3D texture (stored in an InternalTexture)
  19080. */
  19081. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  19082. /**
  19083. * Update a raw 3D texture
  19084. * @param texture defines the texture to update
  19085. * @param data defines the data to store
  19086. * @param format defines the data format
  19087. * @param invertY defines if data must be stored with Y axis inverted
  19088. */
  19089. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  19090. /**
  19091. * Update a raw 3D texture
  19092. * @param texture defines the texture to update
  19093. * @param data defines the data to store
  19094. * @param format defines the data format
  19095. * @param invertY defines if data must be stored with Y axis inverted
  19096. * @param compression defines the used compression (can be null)
  19097. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  19098. */
  19099. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  19100. }
  19101. }
  19102. }
  19103. declare module "babylonjs/Materials/Textures/rawTexture" {
  19104. import { Scene } from "babylonjs/scene";
  19105. import { Texture } from "babylonjs/Materials/Textures/texture";
  19106. import "babylonjs/Engines/Extensions/engine.rawTexture";
  19107. /**
  19108. * Raw texture can help creating a texture directly from an array of data.
  19109. * This can be super useful if you either get the data from an uncompressed source or
  19110. * if you wish to create your texture pixel by pixel.
  19111. */
  19112. export class RawTexture extends Texture {
  19113. /**
  19114. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19115. */
  19116. format: number;
  19117. private _engine;
  19118. /**
  19119. * Instantiates a new RawTexture.
  19120. * Raw texture can help creating a texture directly from an array of data.
  19121. * This can be super useful if you either get the data from an uncompressed source or
  19122. * if you wish to create your texture pixel by pixel.
  19123. * @param data define the array of data to use to create the texture
  19124. * @param width define the width of the texture
  19125. * @param height define the height of the texture
  19126. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19127. * @param scene define the scene the texture belongs to
  19128. * @param generateMipMaps define whether mip maps should be generated or not
  19129. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19130. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19131. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19132. */
  19133. constructor(data: ArrayBufferView, width: number, height: number,
  19134. /**
  19135. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  19136. */
  19137. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  19138. /**
  19139. * Updates the texture underlying data.
  19140. * @param data Define the new data of the texture
  19141. */
  19142. update(data: ArrayBufferView): void;
  19143. /**
  19144. * Creates a luminance texture from some data.
  19145. * @param data Define the texture data
  19146. * @param width Define the width of the texture
  19147. * @param height Define the height of the texture
  19148. * @param scene Define the scene the texture belongs to
  19149. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19150. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19151. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19152. * @returns the luminance texture
  19153. */
  19154. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19155. /**
  19156. * Creates a luminance alpha texture from some data.
  19157. * @param data Define the texture data
  19158. * @param width Define the width of the texture
  19159. * @param height Define the height of the texture
  19160. * @param scene Define the scene the texture belongs to
  19161. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19162. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19163. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19164. * @returns the luminance alpha texture
  19165. */
  19166. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19167. /**
  19168. * Creates an alpha texture from some data.
  19169. * @param data Define the texture data
  19170. * @param width Define the width of the texture
  19171. * @param height Define the height of the texture
  19172. * @param scene Define the scene the texture belongs to
  19173. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19174. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19175. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19176. * @returns the alpha texture
  19177. */
  19178. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19179. /**
  19180. * Creates a RGB texture from some data.
  19181. * @param data Define the texture data
  19182. * @param width Define the width of the texture
  19183. * @param height Define the height of the texture
  19184. * @param scene Define the scene the texture belongs to
  19185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19188. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19189. * @returns the RGB alpha texture
  19190. */
  19191. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19192. /**
  19193. * Creates a RGBA texture from some data.
  19194. * @param data Define the texture data
  19195. * @param width Define the width of the texture
  19196. * @param height Define the height of the texture
  19197. * @param scene Define the scene the texture belongs to
  19198. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19199. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19200. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19201. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19202. * @returns the RGBA texture
  19203. */
  19204. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19205. /**
  19206. * Creates a R texture from some data.
  19207. * @param data Define the texture data
  19208. * @param width Define the width of the texture
  19209. * @param height Define the height of the texture
  19210. * @param scene Define the scene the texture belongs to
  19211. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19212. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19213. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19214. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19215. * @returns the R texture
  19216. */
  19217. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19218. }
  19219. }
  19220. declare module "babylonjs/Animations/runtimeAnimation" {
  19221. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19222. import { Animatable } from "babylonjs/Animations/animatable";
  19223. import { Scene } from "babylonjs/scene";
  19224. /**
  19225. * Defines a runtime animation
  19226. */
  19227. export class RuntimeAnimation {
  19228. private _events;
  19229. /**
  19230. * The current frame of the runtime animation
  19231. */
  19232. private _currentFrame;
  19233. /**
  19234. * The animation used by the runtime animation
  19235. */
  19236. private _animation;
  19237. /**
  19238. * The target of the runtime animation
  19239. */
  19240. private _target;
  19241. /**
  19242. * The initiating animatable
  19243. */
  19244. private _host;
  19245. /**
  19246. * The original value of the runtime animation
  19247. */
  19248. private _originalValue;
  19249. /**
  19250. * The original blend value of the runtime animation
  19251. */
  19252. private _originalBlendValue;
  19253. /**
  19254. * The offsets cache of the runtime animation
  19255. */
  19256. private _offsetsCache;
  19257. /**
  19258. * The high limits cache of the runtime animation
  19259. */
  19260. private _highLimitsCache;
  19261. /**
  19262. * Specifies if the runtime animation has been stopped
  19263. */
  19264. private _stopped;
  19265. /**
  19266. * The blending factor of the runtime animation
  19267. */
  19268. private _blendingFactor;
  19269. /**
  19270. * The BabylonJS scene
  19271. */
  19272. private _scene;
  19273. /**
  19274. * The current value of the runtime animation
  19275. */
  19276. private _currentValue;
  19277. /** @hidden */
  19278. _animationState: _IAnimationState;
  19279. /**
  19280. * The active target of the runtime animation
  19281. */
  19282. private _activeTargets;
  19283. private _currentActiveTarget;
  19284. private _directTarget;
  19285. /**
  19286. * The target path of the runtime animation
  19287. */
  19288. private _targetPath;
  19289. /**
  19290. * The weight of the runtime animation
  19291. */
  19292. private _weight;
  19293. /**
  19294. * The ratio offset of the runtime animation
  19295. */
  19296. private _ratioOffset;
  19297. /**
  19298. * The previous delay of the runtime animation
  19299. */
  19300. private _previousDelay;
  19301. /**
  19302. * The previous ratio of the runtime animation
  19303. */
  19304. private _previousRatio;
  19305. private _enableBlending;
  19306. private _keys;
  19307. private _minFrame;
  19308. private _maxFrame;
  19309. private _minValue;
  19310. private _maxValue;
  19311. private _targetIsArray;
  19312. /**
  19313. * Gets the current frame of the runtime animation
  19314. */
  19315. readonly currentFrame: number;
  19316. /**
  19317. * Gets the weight of the runtime animation
  19318. */
  19319. readonly weight: number;
  19320. /**
  19321. * Gets the current value of the runtime animation
  19322. */
  19323. readonly currentValue: any;
  19324. /**
  19325. * Gets the target path of the runtime animation
  19326. */
  19327. readonly targetPath: string;
  19328. /**
  19329. * Gets the actual target of the runtime animation
  19330. */
  19331. readonly target: any;
  19332. /** @hidden */
  19333. _onLoop: () => void;
  19334. /**
  19335. * Create a new RuntimeAnimation object
  19336. * @param target defines the target of the animation
  19337. * @param animation defines the source animation object
  19338. * @param scene defines the hosting scene
  19339. * @param host defines the initiating Animatable
  19340. */
  19341. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19342. private _preparePath;
  19343. /**
  19344. * Gets the animation from the runtime animation
  19345. */
  19346. readonly animation: Animation;
  19347. /**
  19348. * Resets the runtime animation to the beginning
  19349. * @param restoreOriginal defines whether to restore the target property to the original value
  19350. */
  19351. reset(restoreOriginal?: boolean): void;
  19352. /**
  19353. * Specifies if the runtime animation is stopped
  19354. * @returns Boolean specifying if the runtime animation is stopped
  19355. */
  19356. isStopped(): boolean;
  19357. /**
  19358. * Disposes of the runtime animation
  19359. */
  19360. dispose(): void;
  19361. /**
  19362. * Apply the interpolated value to the target
  19363. * @param currentValue defines the value computed by the animation
  19364. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19365. */
  19366. setValue(currentValue: any, weight: number): void;
  19367. private _getOriginalValues;
  19368. private _setValue;
  19369. /**
  19370. * Gets the loop pmode of the runtime animation
  19371. * @returns Loop Mode
  19372. */
  19373. private _getCorrectLoopMode;
  19374. /**
  19375. * Move the current animation to a given frame
  19376. * @param frame defines the frame to move to
  19377. */
  19378. goToFrame(frame: number): void;
  19379. /**
  19380. * @hidden Internal use only
  19381. */
  19382. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19383. /**
  19384. * Execute the current animation
  19385. * @param delay defines the delay to add to the current frame
  19386. * @param from defines the lower bound of the animation range
  19387. * @param to defines the upper bound of the animation range
  19388. * @param loop defines if the current animation must loop
  19389. * @param speedRatio defines the current speed ratio
  19390. * @param weight defines the weight of the animation (default is -1 so no weight)
  19391. * @param onLoop optional callback called when animation loops
  19392. * @returns a boolean indicating if the animation is running
  19393. */
  19394. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19395. }
  19396. }
  19397. declare module "babylonjs/Animations/animatable" {
  19398. import { Animation } from "babylonjs/Animations/animation";
  19399. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19400. import { Nullable } from "babylonjs/types";
  19401. import { Observable } from "babylonjs/Misc/observable";
  19402. import { Scene } from "babylonjs/scene";
  19403. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19404. import { Node } from "babylonjs/node";
  19405. /**
  19406. * Class used to store an actual running animation
  19407. */
  19408. export class Animatable {
  19409. /** defines the target object */
  19410. target: any;
  19411. /** defines the starting frame number (default is 0) */
  19412. fromFrame: number;
  19413. /** defines the ending frame number (default is 100) */
  19414. toFrame: number;
  19415. /** defines if the animation must loop (default is false) */
  19416. loopAnimation: boolean;
  19417. /** defines a callback to call when animation ends if it is not looping */
  19418. onAnimationEnd?: (() => void) | null | undefined;
  19419. /** defines a callback to call when animation loops */
  19420. onAnimationLoop?: (() => void) | null | undefined;
  19421. private _localDelayOffset;
  19422. private _pausedDelay;
  19423. private _runtimeAnimations;
  19424. private _paused;
  19425. private _scene;
  19426. private _speedRatio;
  19427. private _weight;
  19428. private _syncRoot;
  19429. /**
  19430. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19431. * This will only apply for non looping animation (default is true)
  19432. */
  19433. disposeOnEnd: boolean;
  19434. /**
  19435. * Gets a boolean indicating if the animation has started
  19436. */
  19437. animationStarted: boolean;
  19438. /**
  19439. * Observer raised when the animation ends
  19440. */
  19441. onAnimationEndObservable: Observable<Animatable>;
  19442. /**
  19443. * Observer raised when the animation loops
  19444. */
  19445. onAnimationLoopObservable: Observable<Animatable>;
  19446. /**
  19447. * Gets the root Animatable used to synchronize and normalize animations
  19448. */
  19449. readonly syncRoot: Nullable<Animatable>;
  19450. /**
  19451. * Gets the current frame of the first RuntimeAnimation
  19452. * Used to synchronize Animatables
  19453. */
  19454. readonly masterFrame: number;
  19455. /**
  19456. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19457. */
  19458. weight: number;
  19459. /**
  19460. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19461. */
  19462. speedRatio: number;
  19463. /**
  19464. * Creates a new Animatable
  19465. * @param scene defines the hosting scene
  19466. * @param target defines the target object
  19467. * @param fromFrame defines the starting frame number (default is 0)
  19468. * @param toFrame defines the ending frame number (default is 100)
  19469. * @param loopAnimation defines if the animation must loop (default is false)
  19470. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19471. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19472. * @param animations defines a group of animation to add to the new Animatable
  19473. * @param onAnimationLoop defines a callback to call when animation loops
  19474. */
  19475. constructor(scene: Scene,
  19476. /** defines the target object */
  19477. target: any,
  19478. /** defines the starting frame number (default is 0) */
  19479. fromFrame?: number,
  19480. /** defines the ending frame number (default is 100) */
  19481. toFrame?: number,
  19482. /** defines if the animation must loop (default is false) */
  19483. loopAnimation?: boolean, speedRatio?: number,
  19484. /** defines a callback to call when animation ends if it is not looping */
  19485. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19486. /** defines a callback to call when animation loops */
  19487. onAnimationLoop?: (() => void) | null | undefined);
  19488. /**
  19489. * Synchronize and normalize current Animatable with a source Animatable
  19490. * This is useful when using animation weights and when animations are not of the same length
  19491. * @param root defines the root Animatable to synchronize with
  19492. * @returns the current Animatable
  19493. */
  19494. syncWith(root: Animatable): Animatable;
  19495. /**
  19496. * Gets the list of runtime animations
  19497. * @returns an array of RuntimeAnimation
  19498. */
  19499. getAnimations(): RuntimeAnimation[];
  19500. /**
  19501. * Adds more animations to the current animatable
  19502. * @param target defines the target of the animations
  19503. * @param animations defines the new animations to add
  19504. */
  19505. appendAnimations(target: any, animations: Animation[]): void;
  19506. /**
  19507. * Gets the source animation for a specific property
  19508. * @param property defines the propertyu to look for
  19509. * @returns null or the source animation for the given property
  19510. */
  19511. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19512. /**
  19513. * Gets the runtime animation for a specific property
  19514. * @param property defines the propertyu to look for
  19515. * @returns null or the runtime animation for the given property
  19516. */
  19517. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19518. /**
  19519. * Resets the animatable to its original state
  19520. */
  19521. reset(): void;
  19522. /**
  19523. * Allows the animatable to blend with current running animations
  19524. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19525. * @param blendingSpeed defines the blending speed to use
  19526. */
  19527. enableBlending(blendingSpeed: number): void;
  19528. /**
  19529. * Disable animation blending
  19530. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19531. */
  19532. disableBlending(): void;
  19533. /**
  19534. * Jump directly to a given frame
  19535. * @param frame defines the frame to jump to
  19536. */
  19537. goToFrame(frame: number): void;
  19538. /**
  19539. * Pause the animation
  19540. */
  19541. pause(): void;
  19542. /**
  19543. * Restart the animation
  19544. */
  19545. restart(): void;
  19546. private _raiseOnAnimationEnd;
  19547. /**
  19548. * Stop and delete the current animation
  19549. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19550. * @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)
  19551. */
  19552. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19553. /**
  19554. * Wait asynchronously for the animation to end
  19555. * @returns a promise which will be fullfilled when the animation ends
  19556. */
  19557. waitAsync(): Promise<Animatable>;
  19558. /** @hidden */
  19559. _animate(delay: number): boolean;
  19560. }
  19561. module "babylonjs/scene" {
  19562. interface Scene {
  19563. /** @hidden */
  19564. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19565. /** @hidden */
  19566. _processLateAnimationBindingsForMatrices(holder: {
  19567. totalWeight: number;
  19568. animations: RuntimeAnimation[];
  19569. originalValue: Matrix;
  19570. }): any;
  19571. /** @hidden */
  19572. _processLateAnimationBindingsForQuaternions(holder: {
  19573. totalWeight: number;
  19574. animations: RuntimeAnimation[];
  19575. originalValue: Quaternion;
  19576. }, refQuaternion: Quaternion): Quaternion;
  19577. /** @hidden */
  19578. _processLateAnimationBindings(): void;
  19579. /**
  19580. * Will start the animation sequence of a given target
  19581. * @param target defines the target
  19582. * @param from defines from which frame should animation start
  19583. * @param to defines until which frame should animation run.
  19584. * @param weight defines the weight to apply to the animation (1.0 by default)
  19585. * @param loop defines if the animation loops
  19586. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19587. * @param onAnimationEnd defines the function to be executed when the animation ends
  19588. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19589. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19590. * @param onAnimationLoop defines the callback to call when an animation loops
  19591. * @returns the animatable object created for this animation
  19592. */
  19593. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19594. /**
  19595. * Will start the animation sequence of a given target
  19596. * @param target defines the target
  19597. * @param from defines from which frame should animation start
  19598. * @param to defines until which frame should animation run.
  19599. * @param loop defines if the animation loops
  19600. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19601. * @param onAnimationEnd defines the function to be executed when the animation ends
  19602. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19603. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19604. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19605. * @param onAnimationLoop defines the callback to call when an animation loops
  19606. * @returns the animatable object created for this animation
  19607. */
  19608. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19609. /**
  19610. * Will start the animation sequence of a given target and its hierarchy
  19611. * @param target defines the target
  19612. * @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.
  19613. * @param from defines from which frame should animation start
  19614. * @param to defines until which frame should animation run.
  19615. * @param loop defines if the animation loops
  19616. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19617. * @param onAnimationEnd defines the function to be executed when the animation ends
  19618. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19619. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19620. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19621. * @param onAnimationLoop defines the callback to call when an animation loops
  19622. * @returns the list of created animatables
  19623. */
  19624. 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[];
  19625. /**
  19626. * Begin a new animation on a given node
  19627. * @param target defines the target where the animation will take place
  19628. * @param animations defines the list of animations to start
  19629. * @param from defines the initial value
  19630. * @param to defines the final value
  19631. * @param loop defines if you want animation to loop (off by default)
  19632. * @param speedRatio defines the speed ratio to apply to all animations
  19633. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19634. * @param onAnimationLoop defines the callback to call when an animation loops
  19635. * @returns the list of created animatables
  19636. */
  19637. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19638. /**
  19639. * Begin a new animation on a given node and its hierarchy
  19640. * @param target defines the root node where the animation will take place
  19641. * @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.
  19642. * @param animations defines the list of animations to start
  19643. * @param from defines the initial value
  19644. * @param to defines the final value
  19645. * @param loop defines if you want animation to loop (off by default)
  19646. * @param speedRatio defines the speed ratio to apply to all animations
  19647. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19648. * @param onAnimationLoop defines the callback to call when an animation loops
  19649. * @returns the list of animatables created for all nodes
  19650. */
  19651. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19652. /**
  19653. * Gets the animatable associated with a specific target
  19654. * @param target defines the target of the animatable
  19655. * @returns the required animatable if found
  19656. */
  19657. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19658. /**
  19659. * Gets all animatables associated with a given target
  19660. * @param target defines the target to look animatables for
  19661. * @returns an array of Animatables
  19662. */
  19663. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19664. /**
  19665. * Stops and removes all animations that have been applied to the scene
  19666. */
  19667. stopAllAnimations(): void;
  19668. }
  19669. }
  19670. module "babylonjs/Bones/bone" {
  19671. interface Bone {
  19672. /**
  19673. * Copy an animation range from another bone
  19674. * @param source defines the source bone
  19675. * @param rangeName defines the range name to copy
  19676. * @param frameOffset defines the frame offset
  19677. * @param rescaleAsRequired defines if rescaling must be applied if required
  19678. * @param skelDimensionsRatio defines the scaling ratio
  19679. * @returns true if operation was successful
  19680. */
  19681. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19682. }
  19683. }
  19684. }
  19685. declare module "babylonjs/Bones/skeleton" {
  19686. import { Bone } from "babylonjs/Bones/bone";
  19687. import { IAnimatable } from "babylonjs/Misc/tools";
  19688. import { Observable } from "babylonjs/Misc/observable";
  19689. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19690. import { Scene } from "babylonjs/scene";
  19691. import { Nullable } from "babylonjs/types";
  19692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19693. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19694. import { Animatable } from "babylonjs/Animations/animatable";
  19695. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19696. import { Animation } from "babylonjs/Animations/animation";
  19697. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19698. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19699. /**
  19700. * Class used to handle skinning animations
  19701. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19702. */
  19703. export class Skeleton implements IAnimatable {
  19704. /** defines the skeleton name */
  19705. name: string;
  19706. /** defines the skeleton Id */
  19707. id: string;
  19708. /**
  19709. * Defines the list of child bones
  19710. */
  19711. bones: Bone[];
  19712. /**
  19713. * Defines an estimate of the dimension of the skeleton at rest
  19714. */
  19715. dimensionsAtRest: Vector3;
  19716. /**
  19717. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19718. */
  19719. needInitialSkinMatrix: boolean;
  19720. /**
  19721. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19722. */
  19723. overrideMesh: Nullable<AbstractMesh>;
  19724. /**
  19725. * Gets the list of animations attached to this skeleton
  19726. */
  19727. animations: Array<Animation>;
  19728. private _scene;
  19729. private _isDirty;
  19730. private _transformMatrices;
  19731. private _transformMatrixTexture;
  19732. private _meshesWithPoseMatrix;
  19733. private _animatables;
  19734. private _identity;
  19735. private _synchronizedWithMesh;
  19736. private _ranges;
  19737. private _lastAbsoluteTransformsUpdateId;
  19738. private _canUseTextureForBones;
  19739. private _uniqueId;
  19740. /** @hidden */
  19741. _numBonesWithLinkedTransformNode: number;
  19742. /** @hidden */
  19743. _hasWaitingData: Nullable<boolean>;
  19744. /**
  19745. * Specifies if the skeleton should be serialized
  19746. */
  19747. doNotSerialize: boolean;
  19748. private _useTextureToStoreBoneMatrices;
  19749. /**
  19750. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19751. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19752. */
  19753. useTextureToStoreBoneMatrices: boolean;
  19754. private _animationPropertiesOverride;
  19755. /**
  19756. * Gets or sets the animation properties override
  19757. */
  19758. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19759. /**
  19760. * List of inspectable custom properties (used by the Inspector)
  19761. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19762. */
  19763. inspectableCustomProperties: IInspectable[];
  19764. /**
  19765. * An observable triggered before computing the skeleton's matrices
  19766. */
  19767. onBeforeComputeObservable: Observable<Skeleton>;
  19768. /**
  19769. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19770. */
  19771. readonly isUsingTextureForMatrices: boolean;
  19772. /**
  19773. * Gets the unique ID of this skeleton
  19774. */
  19775. readonly uniqueId: number;
  19776. /**
  19777. * Creates a new skeleton
  19778. * @param name defines the skeleton name
  19779. * @param id defines the skeleton Id
  19780. * @param scene defines the hosting scene
  19781. */
  19782. constructor(
  19783. /** defines the skeleton name */
  19784. name: string,
  19785. /** defines the skeleton Id */
  19786. id: string, scene: Scene);
  19787. /**
  19788. * Gets the current object class name.
  19789. * @return the class name
  19790. */
  19791. getClassName(): string;
  19792. /**
  19793. * Returns an array containing the root bones
  19794. * @returns an array containing the root bones
  19795. */
  19796. getChildren(): Array<Bone>;
  19797. /**
  19798. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19799. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19800. * @returns a Float32Array containing matrices data
  19801. */
  19802. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19803. /**
  19804. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19805. * @returns a raw texture containing the data
  19806. */
  19807. getTransformMatrixTexture(): Nullable<RawTexture>;
  19808. /**
  19809. * Gets the current hosting scene
  19810. * @returns a scene object
  19811. */
  19812. getScene(): Scene;
  19813. /**
  19814. * Gets a string representing the current skeleton data
  19815. * @param fullDetails defines a boolean indicating if we want a verbose version
  19816. * @returns a string representing the current skeleton data
  19817. */
  19818. toString(fullDetails?: boolean): string;
  19819. /**
  19820. * Get bone's index searching by name
  19821. * @param name defines bone's name to search for
  19822. * @return the indice of the bone. Returns -1 if not found
  19823. */
  19824. getBoneIndexByName(name: string): number;
  19825. /**
  19826. * Creater a new animation range
  19827. * @param name defines the name of the range
  19828. * @param from defines the start key
  19829. * @param to defines the end key
  19830. */
  19831. createAnimationRange(name: string, from: number, to: number): void;
  19832. /**
  19833. * Delete a specific animation range
  19834. * @param name defines the name of the range
  19835. * @param deleteFrames defines if frames must be removed as well
  19836. */
  19837. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19838. /**
  19839. * Gets a specific animation range
  19840. * @param name defines the name of the range to look for
  19841. * @returns the requested animation range or null if not found
  19842. */
  19843. getAnimationRange(name: string): Nullable<AnimationRange>;
  19844. /**
  19845. * Gets the list of all animation ranges defined on this skeleton
  19846. * @returns an array
  19847. */
  19848. getAnimationRanges(): Nullable<AnimationRange>[];
  19849. /**
  19850. * Copy animation range from a source skeleton.
  19851. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19852. * @param source defines the source skeleton
  19853. * @param name defines the name of the range to copy
  19854. * @param rescaleAsRequired defines if rescaling must be applied if required
  19855. * @returns true if operation was successful
  19856. */
  19857. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19858. /**
  19859. * Forces the skeleton to go to rest pose
  19860. */
  19861. returnToRest(): void;
  19862. private _getHighestAnimationFrame;
  19863. /**
  19864. * Begin a specific animation range
  19865. * @param name defines the name of the range to start
  19866. * @param loop defines if looping must be turned on (false by default)
  19867. * @param speedRatio defines the speed ratio to apply (1 by default)
  19868. * @param onAnimationEnd defines a callback which will be called when animation will end
  19869. * @returns a new animatable
  19870. */
  19871. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19872. /** @hidden */
  19873. _markAsDirty(): void;
  19874. /** @hidden */
  19875. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19876. /** @hidden */
  19877. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19878. private _computeTransformMatrices;
  19879. /**
  19880. * Build all resources required to render a skeleton
  19881. */
  19882. prepare(): void;
  19883. /**
  19884. * Gets the list of animatables currently running for this skeleton
  19885. * @returns an array of animatables
  19886. */
  19887. getAnimatables(): IAnimatable[];
  19888. /**
  19889. * Clone the current skeleton
  19890. * @param name defines the name of the new skeleton
  19891. * @param id defines the id of the new skeleton
  19892. * @returns the new skeleton
  19893. */
  19894. clone(name: string, id: string): Skeleton;
  19895. /**
  19896. * Enable animation blending for this skeleton
  19897. * @param blendingSpeed defines the blending speed to apply
  19898. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19899. */
  19900. enableBlending(blendingSpeed?: number): void;
  19901. /**
  19902. * Releases all resources associated with the current skeleton
  19903. */
  19904. dispose(): void;
  19905. /**
  19906. * Serialize the skeleton in a JSON object
  19907. * @returns a JSON object
  19908. */
  19909. serialize(): any;
  19910. /**
  19911. * Creates a new skeleton from serialized data
  19912. * @param parsedSkeleton defines the serialized data
  19913. * @param scene defines the hosting scene
  19914. * @returns a new skeleton
  19915. */
  19916. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19917. /**
  19918. * Compute all node absolute transforms
  19919. * @param forceUpdate defines if computation must be done even if cache is up to date
  19920. */
  19921. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19922. /**
  19923. * Gets the root pose matrix
  19924. * @returns a matrix
  19925. */
  19926. getPoseMatrix(): Nullable<Matrix>;
  19927. /**
  19928. * Sorts bones per internal index
  19929. */
  19930. sortBones(): void;
  19931. private _sortBones;
  19932. }
  19933. }
  19934. declare module "babylonjs/Morph/morphTarget" {
  19935. import { IAnimatable } from "babylonjs/Misc/tools";
  19936. import { Observable } from "babylonjs/Misc/observable";
  19937. import { Nullable, FloatArray } from "babylonjs/types";
  19938. import { Scene } from "babylonjs/scene";
  19939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19940. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19941. /**
  19942. * Defines a target to use with MorphTargetManager
  19943. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19944. */
  19945. export class MorphTarget implements IAnimatable {
  19946. /** defines the name of the target */
  19947. name: string;
  19948. /**
  19949. * Gets or sets the list of animations
  19950. */
  19951. animations: import("babylonjs/Animations/animation").Animation[];
  19952. private _scene;
  19953. private _positions;
  19954. private _normals;
  19955. private _tangents;
  19956. private _influence;
  19957. /**
  19958. * Observable raised when the influence changes
  19959. */
  19960. onInfluenceChanged: Observable<boolean>;
  19961. /** @hidden */
  19962. _onDataLayoutChanged: Observable<void>;
  19963. /**
  19964. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19965. */
  19966. influence: number;
  19967. /**
  19968. * Gets or sets the id of the morph Target
  19969. */
  19970. id: string;
  19971. private _animationPropertiesOverride;
  19972. /**
  19973. * Gets or sets the animation properties override
  19974. */
  19975. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19976. /**
  19977. * Creates a new MorphTarget
  19978. * @param name defines the name of the target
  19979. * @param influence defines the influence to use
  19980. * @param scene defines the scene the morphtarget belongs to
  19981. */
  19982. constructor(
  19983. /** defines the name of the target */
  19984. name: string, influence?: number, scene?: Nullable<Scene>);
  19985. /**
  19986. * Gets a boolean defining if the target contains position data
  19987. */
  19988. readonly hasPositions: boolean;
  19989. /**
  19990. * Gets a boolean defining if the target contains normal data
  19991. */
  19992. readonly hasNormals: boolean;
  19993. /**
  19994. * Gets a boolean defining if the target contains tangent data
  19995. */
  19996. readonly hasTangents: boolean;
  19997. /**
  19998. * Affects position data to this target
  19999. * @param data defines the position data to use
  20000. */
  20001. setPositions(data: Nullable<FloatArray>): void;
  20002. /**
  20003. * Gets the position data stored in this target
  20004. * @returns a FloatArray containing the position data (or null if not present)
  20005. */
  20006. getPositions(): Nullable<FloatArray>;
  20007. /**
  20008. * Affects normal data to this target
  20009. * @param data defines the normal data to use
  20010. */
  20011. setNormals(data: Nullable<FloatArray>): void;
  20012. /**
  20013. * Gets the normal data stored in this target
  20014. * @returns a FloatArray containing the normal data (or null if not present)
  20015. */
  20016. getNormals(): Nullable<FloatArray>;
  20017. /**
  20018. * Affects tangent data to this target
  20019. * @param data defines the tangent data to use
  20020. */
  20021. setTangents(data: Nullable<FloatArray>): void;
  20022. /**
  20023. * Gets the tangent data stored in this target
  20024. * @returns a FloatArray containing the tangent data (or null if not present)
  20025. */
  20026. getTangents(): Nullable<FloatArray>;
  20027. /**
  20028. * Serializes the current target into a Serialization object
  20029. * @returns the serialized object
  20030. */
  20031. serialize(): any;
  20032. /**
  20033. * Returns the string "MorphTarget"
  20034. * @returns "MorphTarget"
  20035. */
  20036. getClassName(): string;
  20037. /**
  20038. * Creates a new target from serialized data
  20039. * @param serializationObject defines the serialized data to use
  20040. * @returns a new MorphTarget
  20041. */
  20042. static Parse(serializationObject: any): MorphTarget;
  20043. /**
  20044. * Creates a MorphTarget from mesh data
  20045. * @param mesh defines the source mesh
  20046. * @param name defines the name to use for the new target
  20047. * @param influence defines the influence to attach to the target
  20048. * @returns a new MorphTarget
  20049. */
  20050. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  20051. }
  20052. }
  20053. declare module "babylonjs/Morph/morphTargetManager" {
  20054. import { Nullable } from "babylonjs/types";
  20055. import { Scene } from "babylonjs/scene";
  20056. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  20057. /**
  20058. * This class is used to deform meshes using morphing between different targets
  20059. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20060. */
  20061. export class MorphTargetManager {
  20062. private _targets;
  20063. private _targetInfluenceChangedObservers;
  20064. private _targetDataLayoutChangedObservers;
  20065. private _activeTargets;
  20066. private _scene;
  20067. private _influences;
  20068. private _supportsNormals;
  20069. private _supportsTangents;
  20070. private _vertexCount;
  20071. private _uniqueId;
  20072. private _tempInfluences;
  20073. /**
  20074. * Creates a new MorphTargetManager
  20075. * @param scene defines the current scene
  20076. */
  20077. constructor(scene?: Nullable<Scene>);
  20078. /**
  20079. * Gets the unique ID of this manager
  20080. */
  20081. readonly uniqueId: number;
  20082. /**
  20083. * Gets the number of vertices handled by this manager
  20084. */
  20085. readonly vertexCount: number;
  20086. /**
  20087. * Gets a boolean indicating if this manager supports morphing of normals
  20088. */
  20089. readonly supportsNormals: boolean;
  20090. /**
  20091. * Gets a boolean indicating if this manager supports morphing of tangents
  20092. */
  20093. readonly supportsTangents: boolean;
  20094. /**
  20095. * Gets the number of targets stored in this manager
  20096. */
  20097. readonly numTargets: number;
  20098. /**
  20099. * Gets the number of influencers (ie. the number of targets with influences > 0)
  20100. */
  20101. readonly numInfluencers: number;
  20102. /**
  20103. * Gets the list of influences (one per target)
  20104. */
  20105. readonly influences: Float32Array;
  20106. /**
  20107. * Gets the active target at specified index. An active target is a target with an influence > 0
  20108. * @param index defines the index to check
  20109. * @returns the requested target
  20110. */
  20111. getActiveTarget(index: number): MorphTarget;
  20112. /**
  20113. * Gets the target at specified index
  20114. * @param index defines the index to check
  20115. * @returns the requested target
  20116. */
  20117. getTarget(index: number): MorphTarget;
  20118. /**
  20119. * Add a new target to this manager
  20120. * @param target defines the target to add
  20121. */
  20122. addTarget(target: MorphTarget): void;
  20123. /**
  20124. * Removes a target from the manager
  20125. * @param target defines the target to remove
  20126. */
  20127. removeTarget(target: MorphTarget): void;
  20128. /**
  20129. * Serializes the current manager into a Serialization object
  20130. * @returns the serialized object
  20131. */
  20132. serialize(): any;
  20133. private _syncActiveTargets;
  20134. /**
  20135. * Syncrhonize the targets with all the meshes using this morph target manager
  20136. */
  20137. synchronize(): void;
  20138. /**
  20139. * Creates a new MorphTargetManager from serialized data
  20140. * @param serializationObject defines the serialized data
  20141. * @param scene defines the hosting scene
  20142. * @returns the new MorphTargetManager
  20143. */
  20144. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  20145. }
  20146. }
  20147. declare module "babylonjs/Meshes/meshLODLevel" {
  20148. import { Mesh } from "babylonjs/Meshes/mesh";
  20149. import { Nullable } from "babylonjs/types";
  20150. /**
  20151. * Class used to represent a specific level of detail of a mesh
  20152. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20153. */
  20154. export class MeshLODLevel {
  20155. /** Defines the distance where this level should star being displayed */
  20156. distance: number;
  20157. /** Defines the mesh to use to render this level */
  20158. mesh: Nullable<Mesh>;
  20159. /**
  20160. * Creates a new LOD level
  20161. * @param distance defines the distance where this level should star being displayed
  20162. * @param mesh defines the mesh to use to render this level
  20163. */
  20164. constructor(
  20165. /** Defines the distance where this level should star being displayed */
  20166. distance: number,
  20167. /** Defines the mesh to use to render this level */
  20168. mesh: Nullable<Mesh>);
  20169. }
  20170. }
  20171. declare module "babylonjs/Meshes/groundMesh" {
  20172. import { Scene } from "babylonjs/scene";
  20173. import { Vector3 } from "babylonjs/Maths/math";
  20174. import { Mesh } from "babylonjs/Meshes/mesh";
  20175. /**
  20176. * Mesh representing the gorund
  20177. */
  20178. export class GroundMesh extends Mesh {
  20179. /** If octree should be generated */
  20180. generateOctree: boolean;
  20181. private _heightQuads;
  20182. /** @hidden */
  20183. _subdivisionsX: number;
  20184. /** @hidden */
  20185. _subdivisionsY: number;
  20186. /** @hidden */
  20187. _width: number;
  20188. /** @hidden */
  20189. _height: number;
  20190. /** @hidden */
  20191. _minX: number;
  20192. /** @hidden */
  20193. _maxX: number;
  20194. /** @hidden */
  20195. _minZ: number;
  20196. /** @hidden */
  20197. _maxZ: number;
  20198. constructor(name: string, scene: Scene);
  20199. /**
  20200. * "GroundMesh"
  20201. * @returns "GroundMesh"
  20202. */
  20203. getClassName(): string;
  20204. /**
  20205. * The minimum of x and y subdivisions
  20206. */
  20207. readonly subdivisions: number;
  20208. /**
  20209. * X subdivisions
  20210. */
  20211. readonly subdivisionsX: number;
  20212. /**
  20213. * Y subdivisions
  20214. */
  20215. readonly subdivisionsY: number;
  20216. /**
  20217. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20218. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20219. * @param chunksCount the number of subdivisions for x and y
  20220. * @param octreeBlocksSize (Default: 32)
  20221. */
  20222. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20223. /**
  20224. * Returns a height (y) value in the Worl system :
  20225. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20226. * @param x x coordinate
  20227. * @param z z coordinate
  20228. * @returns the ground y position if (x, z) are outside the ground surface.
  20229. */
  20230. getHeightAtCoordinates(x: number, z: number): number;
  20231. /**
  20232. * Returns a normalized vector (Vector3) orthogonal to the ground
  20233. * at the ground coordinates (x, z) expressed in the World system.
  20234. * @param x x coordinate
  20235. * @param z z coordinate
  20236. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20237. */
  20238. getNormalAtCoordinates(x: number, z: number): Vector3;
  20239. /**
  20240. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20241. * at the ground coordinates (x, z) expressed in the World system.
  20242. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20243. * @param x x coordinate
  20244. * @param z z coordinate
  20245. * @param ref vector to store the result
  20246. * @returns the GroundMesh.
  20247. */
  20248. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20249. /**
  20250. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20251. * if the ground has been updated.
  20252. * This can be used in the render loop.
  20253. * @returns the GroundMesh.
  20254. */
  20255. updateCoordinateHeights(): GroundMesh;
  20256. private _getFacetAt;
  20257. private _initHeightQuads;
  20258. private _computeHeightQuads;
  20259. /**
  20260. * Serializes this ground mesh
  20261. * @param serializationObject object to write serialization to
  20262. */
  20263. serialize(serializationObject: any): void;
  20264. /**
  20265. * Parses a serialized ground mesh
  20266. * @param parsedMesh the serialized mesh
  20267. * @param scene the scene to create the ground mesh in
  20268. * @returns the created ground mesh
  20269. */
  20270. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20271. }
  20272. }
  20273. declare module "babylonjs/Physics/physicsJoint" {
  20274. import { Vector3 } from "babylonjs/Maths/math";
  20275. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20276. /**
  20277. * Interface for Physics-Joint data
  20278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20279. */
  20280. export interface PhysicsJointData {
  20281. /**
  20282. * The main pivot of the joint
  20283. */
  20284. mainPivot?: Vector3;
  20285. /**
  20286. * The connected pivot of the joint
  20287. */
  20288. connectedPivot?: Vector3;
  20289. /**
  20290. * The main axis of the joint
  20291. */
  20292. mainAxis?: Vector3;
  20293. /**
  20294. * The connected axis of the joint
  20295. */
  20296. connectedAxis?: Vector3;
  20297. /**
  20298. * The collision of the joint
  20299. */
  20300. collision?: boolean;
  20301. /**
  20302. * Native Oimo/Cannon/Energy data
  20303. */
  20304. nativeParams?: any;
  20305. }
  20306. /**
  20307. * This is a holder class for the physics joint created by the physics plugin
  20308. * It holds a set of functions to control the underlying joint
  20309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20310. */
  20311. export class PhysicsJoint {
  20312. /**
  20313. * The type of the physics joint
  20314. */
  20315. type: number;
  20316. /**
  20317. * The data for the physics joint
  20318. */
  20319. jointData: PhysicsJointData;
  20320. private _physicsJoint;
  20321. protected _physicsPlugin: IPhysicsEnginePlugin;
  20322. /**
  20323. * Initializes the physics joint
  20324. * @param type The type of the physics joint
  20325. * @param jointData The data for the physics joint
  20326. */
  20327. constructor(
  20328. /**
  20329. * The type of the physics joint
  20330. */
  20331. type: number,
  20332. /**
  20333. * The data for the physics joint
  20334. */
  20335. jointData: PhysicsJointData);
  20336. /**
  20337. * Gets the physics joint
  20338. */
  20339. /**
  20340. * Sets the physics joint
  20341. */
  20342. physicsJoint: any;
  20343. /**
  20344. * Sets the physics plugin
  20345. */
  20346. physicsPlugin: IPhysicsEnginePlugin;
  20347. /**
  20348. * Execute a function that is physics-plugin specific.
  20349. * @param {Function} func the function that will be executed.
  20350. * It accepts two parameters: the physics world and the physics joint
  20351. */
  20352. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20353. /**
  20354. * Distance-Joint type
  20355. */
  20356. static DistanceJoint: number;
  20357. /**
  20358. * Hinge-Joint type
  20359. */
  20360. static HingeJoint: number;
  20361. /**
  20362. * Ball-and-Socket joint type
  20363. */
  20364. static BallAndSocketJoint: number;
  20365. /**
  20366. * Wheel-Joint type
  20367. */
  20368. static WheelJoint: number;
  20369. /**
  20370. * Slider-Joint type
  20371. */
  20372. static SliderJoint: number;
  20373. /**
  20374. * Prismatic-Joint type
  20375. */
  20376. static PrismaticJoint: number;
  20377. /**
  20378. * Universal-Joint type
  20379. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20380. */
  20381. static UniversalJoint: number;
  20382. /**
  20383. * Hinge-Joint 2 type
  20384. */
  20385. static Hinge2Joint: number;
  20386. /**
  20387. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20388. */
  20389. static PointToPointJoint: number;
  20390. /**
  20391. * Spring-Joint type
  20392. */
  20393. static SpringJoint: number;
  20394. /**
  20395. * Lock-Joint type
  20396. */
  20397. static LockJoint: number;
  20398. }
  20399. /**
  20400. * A class representing a physics distance joint
  20401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20402. */
  20403. export class DistanceJoint extends PhysicsJoint {
  20404. /**
  20405. *
  20406. * @param jointData The data for the Distance-Joint
  20407. */
  20408. constructor(jointData: DistanceJointData);
  20409. /**
  20410. * Update the predefined distance.
  20411. * @param maxDistance The maximum preferred distance
  20412. * @param minDistance The minimum preferred distance
  20413. */
  20414. updateDistance(maxDistance: number, minDistance?: number): void;
  20415. }
  20416. /**
  20417. * Represents a Motor-Enabled Joint
  20418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20419. */
  20420. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20421. /**
  20422. * Initializes the Motor-Enabled Joint
  20423. * @param type The type of the joint
  20424. * @param jointData The physica joint data for the joint
  20425. */
  20426. constructor(type: number, jointData: PhysicsJointData);
  20427. /**
  20428. * Set the motor values.
  20429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20430. * @param force the force to apply
  20431. * @param maxForce max force for this motor.
  20432. */
  20433. setMotor(force?: number, maxForce?: number): void;
  20434. /**
  20435. * Set the motor's limits.
  20436. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20437. * @param upperLimit The upper limit of the motor
  20438. * @param lowerLimit The lower limit of the motor
  20439. */
  20440. setLimit(upperLimit: number, lowerLimit?: number): void;
  20441. }
  20442. /**
  20443. * This class represents a single physics Hinge-Joint
  20444. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20445. */
  20446. export class HingeJoint extends MotorEnabledJoint {
  20447. /**
  20448. * Initializes the Hinge-Joint
  20449. * @param jointData The joint data for the Hinge-Joint
  20450. */
  20451. constructor(jointData: PhysicsJointData);
  20452. /**
  20453. * Set the motor values.
  20454. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20455. * @param {number} force the force to apply
  20456. * @param {number} maxForce max force for this motor.
  20457. */
  20458. setMotor(force?: number, maxForce?: number): void;
  20459. /**
  20460. * Set the motor's limits.
  20461. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20462. * @param upperLimit The upper limit of the motor
  20463. * @param lowerLimit The lower limit of the motor
  20464. */
  20465. setLimit(upperLimit: number, lowerLimit?: number): void;
  20466. }
  20467. /**
  20468. * This class represents a dual hinge physics joint (same as wheel joint)
  20469. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20470. */
  20471. export class Hinge2Joint extends MotorEnabledJoint {
  20472. /**
  20473. * Initializes the Hinge2-Joint
  20474. * @param jointData The joint data for the Hinge2-Joint
  20475. */
  20476. constructor(jointData: PhysicsJointData);
  20477. /**
  20478. * Set the motor values.
  20479. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20480. * @param {number} targetSpeed the speed the motor is to reach
  20481. * @param {number} maxForce max force for this motor.
  20482. * @param {motorIndex} the motor's index, 0 or 1.
  20483. */
  20484. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20485. /**
  20486. * Set the motor limits.
  20487. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20488. * @param {number} upperLimit the upper limit
  20489. * @param {number} lowerLimit lower limit
  20490. * @param {motorIndex} the motor's index, 0 or 1.
  20491. */
  20492. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20493. }
  20494. /**
  20495. * Interface for a motor enabled joint
  20496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20497. */
  20498. export interface IMotorEnabledJoint {
  20499. /**
  20500. * Physics joint
  20501. */
  20502. physicsJoint: any;
  20503. /**
  20504. * Sets the motor of the motor-enabled joint
  20505. * @param force The force of the motor
  20506. * @param maxForce The maximum force of the motor
  20507. * @param motorIndex The index of the motor
  20508. */
  20509. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20510. /**
  20511. * Sets the limit of the motor
  20512. * @param upperLimit The upper limit of the motor
  20513. * @param lowerLimit The lower limit of the motor
  20514. * @param motorIndex The index of the motor
  20515. */
  20516. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20517. }
  20518. /**
  20519. * Joint data for a Distance-Joint
  20520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20521. */
  20522. export interface DistanceJointData extends PhysicsJointData {
  20523. /**
  20524. * Max distance the 2 joint objects can be apart
  20525. */
  20526. maxDistance: number;
  20527. }
  20528. /**
  20529. * Joint data from a spring joint
  20530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20531. */
  20532. export interface SpringJointData extends PhysicsJointData {
  20533. /**
  20534. * Length of the spring
  20535. */
  20536. length: number;
  20537. /**
  20538. * Stiffness of the spring
  20539. */
  20540. stiffness: number;
  20541. /**
  20542. * Damping of the spring
  20543. */
  20544. damping: number;
  20545. /** this callback will be called when applying the force to the impostors. */
  20546. forceApplicationCallback: () => void;
  20547. }
  20548. }
  20549. declare module "babylonjs/Physics/physicsRaycastResult" {
  20550. import { Vector3 } from "babylonjs/Maths/math";
  20551. /**
  20552. * Holds the data for the raycast result
  20553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20554. */
  20555. export class PhysicsRaycastResult {
  20556. private _hasHit;
  20557. private _hitDistance;
  20558. private _hitNormalWorld;
  20559. private _hitPointWorld;
  20560. private _rayFromWorld;
  20561. private _rayToWorld;
  20562. /**
  20563. * Gets if there was a hit
  20564. */
  20565. readonly hasHit: boolean;
  20566. /**
  20567. * Gets the distance from the hit
  20568. */
  20569. readonly hitDistance: number;
  20570. /**
  20571. * Gets the hit normal/direction in the world
  20572. */
  20573. readonly hitNormalWorld: Vector3;
  20574. /**
  20575. * Gets the hit point in the world
  20576. */
  20577. readonly hitPointWorld: Vector3;
  20578. /**
  20579. * Gets the ray "start point" of the ray in the world
  20580. */
  20581. readonly rayFromWorld: Vector3;
  20582. /**
  20583. * Gets the ray "end point" of the ray in the world
  20584. */
  20585. readonly rayToWorld: Vector3;
  20586. /**
  20587. * Sets the hit data (normal & point in world space)
  20588. * @param hitNormalWorld defines the normal in world space
  20589. * @param hitPointWorld defines the point in world space
  20590. */
  20591. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20592. /**
  20593. * Sets the distance from the start point to the hit point
  20594. * @param distance
  20595. */
  20596. setHitDistance(distance: number): void;
  20597. /**
  20598. * Calculates the distance manually
  20599. */
  20600. calculateHitDistance(): void;
  20601. /**
  20602. * Resets all the values to default
  20603. * @param from The from point on world space
  20604. * @param to The to point on world space
  20605. */
  20606. reset(from?: Vector3, to?: Vector3): void;
  20607. }
  20608. /**
  20609. * Interface for the size containing width and height
  20610. */
  20611. interface IXYZ {
  20612. /**
  20613. * X
  20614. */
  20615. x: number;
  20616. /**
  20617. * Y
  20618. */
  20619. y: number;
  20620. /**
  20621. * Z
  20622. */
  20623. z: number;
  20624. }
  20625. }
  20626. declare module "babylonjs/Physics/IPhysicsEngine" {
  20627. import { Nullable } from "babylonjs/types";
  20628. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20630. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20631. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20632. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20633. /**
  20634. * Interface used to describe a physics joint
  20635. */
  20636. export interface PhysicsImpostorJoint {
  20637. /** Defines the main impostor to which the joint is linked */
  20638. mainImpostor: PhysicsImpostor;
  20639. /** Defines the impostor that is connected to the main impostor using this joint */
  20640. connectedImpostor: PhysicsImpostor;
  20641. /** Defines the joint itself */
  20642. joint: PhysicsJoint;
  20643. }
  20644. /** @hidden */
  20645. export interface IPhysicsEnginePlugin {
  20646. world: any;
  20647. name: string;
  20648. setGravity(gravity: Vector3): void;
  20649. setTimeStep(timeStep: number): void;
  20650. getTimeStep(): number;
  20651. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20652. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20653. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20654. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20655. removePhysicsBody(impostor: PhysicsImpostor): void;
  20656. generateJoint(joint: PhysicsImpostorJoint): void;
  20657. removeJoint(joint: PhysicsImpostorJoint): void;
  20658. isSupported(): boolean;
  20659. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20660. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20661. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20662. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20663. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20664. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20665. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20666. getBodyMass(impostor: PhysicsImpostor): number;
  20667. getBodyFriction(impostor: PhysicsImpostor): number;
  20668. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20669. getBodyRestitution(impostor: PhysicsImpostor): number;
  20670. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20671. getBodyPressure?(impostor: PhysicsImpostor): number;
  20672. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20673. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20674. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20675. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20676. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20677. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20678. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20679. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20680. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20681. sleepBody(impostor: PhysicsImpostor): void;
  20682. wakeUpBody(impostor: PhysicsImpostor): void;
  20683. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20684. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20685. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20686. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20687. getRadius(impostor: PhysicsImpostor): number;
  20688. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20689. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20690. dispose(): void;
  20691. }
  20692. /**
  20693. * Interface used to define a physics engine
  20694. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20695. */
  20696. export interface IPhysicsEngine {
  20697. /**
  20698. * Gets the gravity vector used by the simulation
  20699. */
  20700. gravity: Vector3;
  20701. /**
  20702. * Sets the gravity vector used by the simulation
  20703. * @param gravity defines the gravity vector to use
  20704. */
  20705. setGravity(gravity: Vector3): void;
  20706. /**
  20707. * Set the time step of the physics engine.
  20708. * Default is 1/60.
  20709. * To slow it down, enter 1/600 for example.
  20710. * To speed it up, 1/30
  20711. * @param newTimeStep the new timestep to apply to this world.
  20712. */
  20713. setTimeStep(newTimeStep: number): void;
  20714. /**
  20715. * Get the time step of the physics engine.
  20716. * @returns the current time step
  20717. */
  20718. getTimeStep(): number;
  20719. /**
  20720. * Release all resources
  20721. */
  20722. dispose(): void;
  20723. /**
  20724. * Gets the name of the current physics plugin
  20725. * @returns the name of the plugin
  20726. */
  20727. getPhysicsPluginName(): string;
  20728. /**
  20729. * Adding a new impostor for the impostor tracking.
  20730. * This will be done by the impostor itself.
  20731. * @param impostor the impostor to add
  20732. */
  20733. addImpostor(impostor: PhysicsImpostor): void;
  20734. /**
  20735. * Remove an impostor from the engine.
  20736. * This impostor and its mesh will not longer be updated by the physics engine.
  20737. * @param impostor the impostor to remove
  20738. */
  20739. removeImpostor(impostor: PhysicsImpostor): void;
  20740. /**
  20741. * Add a joint to the physics engine
  20742. * @param mainImpostor defines the main impostor to which the joint is added.
  20743. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20744. * @param joint defines the joint that will connect both impostors.
  20745. */
  20746. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20747. /**
  20748. * Removes a joint from the simulation
  20749. * @param mainImpostor defines the impostor used with the joint
  20750. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20751. * @param joint defines the joint to remove
  20752. */
  20753. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20754. /**
  20755. * Gets the current plugin used to run the simulation
  20756. * @returns current plugin
  20757. */
  20758. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20759. /**
  20760. * Gets the list of physic impostors
  20761. * @returns an array of PhysicsImpostor
  20762. */
  20763. getImpostors(): Array<PhysicsImpostor>;
  20764. /**
  20765. * Gets the impostor for a physics enabled object
  20766. * @param object defines the object impersonated by the impostor
  20767. * @returns the PhysicsImpostor or null if not found
  20768. */
  20769. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20770. /**
  20771. * Gets the impostor for a physics body object
  20772. * @param body defines physics body used by the impostor
  20773. * @returns the PhysicsImpostor or null if not found
  20774. */
  20775. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20776. /**
  20777. * Does a raycast in the physics world
  20778. * @param from when should the ray start?
  20779. * @param to when should the ray end?
  20780. * @returns PhysicsRaycastResult
  20781. */
  20782. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20783. /**
  20784. * Called by the scene. No need to call it.
  20785. * @param delta defines the timespam between frames
  20786. */
  20787. _step(delta: number): void;
  20788. }
  20789. }
  20790. declare module "babylonjs/Physics/physicsImpostor" {
  20791. import { Nullable, IndicesArray } from "babylonjs/types";
  20792. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20793. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20795. import { Scene } from "babylonjs/scene";
  20796. import { Bone } from "babylonjs/Bones/bone";
  20797. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20798. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20799. /**
  20800. * The interface for the physics imposter parameters
  20801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20802. */
  20803. export interface PhysicsImpostorParameters {
  20804. /**
  20805. * The mass of the physics imposter
  20806. */
  20807. mass: number;
  20808. /**
  20809. * The friction of the physics imposter
  20810. */
  20811. friction?: number;
  20812. /**
  20813. * The coefficient of restitution of the physics imposter
  20814. */
  20815. restitution?: number;
  20816. /**
  20817. * The native options of the physics imposter
  20818. */
  20819. nativeOptions?: any;
  20820. /**
  20821. * Specifies if the parent should be ignored
  20822. */
  20823. ignoreParent?: boolean;
  20824. /**
  20825. * Specifies if bi-directional transformations should be disabled
  20826. */
  20827. disableBidirectionalTransformation?: boolean;
  20828. /**
  20829. * The pressure inside the physics imposter, soft object only
  20830. */
  20831. pressure?: number;
  20832. /**
  20833. * The stiffness the physics imposter, soft object only
  20834. */
  20835. stiffness?: number;
  20836. /**
  20837. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20838. */
  20839. velocityIterations?: number;
  20840. /**
  20841. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20842. */
  20843. positionIterations?: number;
  20844. /**
  20845. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20846. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20847. * Add to fix multiple points
  20848. */
  20849. fixedPoints?: number;
  20850. /**
  20851. * The collision margin around a soft object
  20852. */
  20853. margin?: number;
  20854. /**
  20855. * The collision margin around a soft object
  20856. */
  20857. damping?: number;
  20858. /**
  20859. * The path for a rope based on an extrusion
  20860. */
  20861. path?: any;
  20862. /**
  20863. * The shape of an extrusion used for a rope based on an extrusion
  20864. */
  20865. shape?: any;
  20866. }
  20867. /**
  20868. * Interface for a physics-enabled object
  20869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20870. */
  20871. export interface IPhysicsEnabledObject {
  20872. /**
  20873. * The position of the physics-enabled object
  20874. */
  20875. position: Vector3;
  20876. /**
  20877. * The rotation of the physics-enabled object
  20878. */
  20879. rotationQuaternion: Nullable<Quaternion>;
  20880. /**
  20881. * The scale of the physics-enabled object
  20882. */
  20883. scaling: Vector3;
  20884. /**
  20885. * The rotation of the physics-enabled object
  20886. */
  20887. rotation?: Vector3;
  20888. /**
  20889. * The parent of the physics-enabled object
  20890. */
  20891. parent?: any;
  20892. /**
  20893. * The bounding info of the physics-enabled object
  20894. * @returns The bounding info of the physics-enabled object
  20895. */
  20896. getBoundingInfo(): BoundingInfo;
  20897. /**
  20898. * Computes the world matrix
  20899. * @param force Specifies if the world matrix should be computed by force
  20900. * @returns A world matrix
  20901. */
  20902. computeWorldMatrix(force: boolean): Matrix;
  20903. /**
  20904. * Gets the world matrix
  20905. * @returns A world matrix
  20906. */
  20907. getWorldMatrix?(): Matrix;
  20908. /**
  20909. * Gets the child meshes
  20910. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20911. * @returns An array of abstract meshes
  20912. */
  20913. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20914. /**
  20915. * Gets the vertex data
  20916. * @param kind The type of vertex data
  20917. * @returns A nullable array of numbers, or a float32 array
  20918. */
  20919. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20920. /**
  20921. * Gets the indices from the mesh
  20922. * @returns A nullable array of index arrays
  20923. */
  20924. getIndices?(): Nullable<IndicesArray>;
  20925. /**
  20926. * Gets the scene from the mesh
  20927. * @returns the indices array or null
  20928. */
  20929. getScene?(): Scene;
  20930. /**
  20931. * Gets the absolute position from the mesh
  20932. * @returns the absolute position
  20933. */
  20934. getAbsolutePosition(): Vector3;
  20935. /**
  20936. * Gets the absolute pivot point from the mesh
  20937. * @returns the absolute pivot point
  20938. */
  20939. getAbsolutePivotPoint(): Vector3;
  20940. /**
  20941. * Rotates the mesh
  20942. * @param axis The axis of rotation
  20943. * @param amount The amount of rotation
  20944. * @param space The space of the rotation
  20945. * @returns The rotation transform node
  20946. */
  20947. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20948. /**
  20949. * Translates the mesh
  20950. * @param axis The axis of translation
  20951. * @param distance The distance of translation
  20952. * @param space The space of the translation
  20953. * @returns The transform node
  20954. */
  20955. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20956. /**
  20957. * Sets the absolute position of the mesh
  20958. * @param absolutePosition The absolute position of the mesh
  20959. * @returns The transform node
  20960. */
  20961. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20962. /**
  20963. * Gets the class name of the mesh
  20964. * @returns The class name
  20965. */
  20966. getClassName(): string;
  20967. }
  20968. /**
  20969. * Represents a physics imposter
  20970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20971. */
  20972. export class PhysicsImpostor {
  20973. /**
  20974. * The physics-enabled object used as the physics imposter
  20975. */
  20976. object: IPhysicsEnabledObject;
  20977. /**
  20978. * The type of the physics imposter
  20979. */
  20980. type: number;
  20981. private _options;
  20982. private _scene?;
  20983. /**
  20984. * The default object size of the imposter
  20985. */
  20986. static DEFAULT_OBJECT_SIZE: Vector3;
  20987. /**
  20988. * The identity quaternion of the imposter
  20989. */
  20990. static IDENTITY_QUATERNION: Quaternion;
  20991. /** @hidden */
  20992. _pluginData: any;
  20993. private _physicsEngine;
  20994. private _physicsBody;
  20995. private _bodyUpdateRequired;
  20996. private _onBeforePhysicsStepCallbacks;
  20997. private _onAfterPhysicsStepCallbacks;
  20998. /** @hidden */
  20999. _onPhysicsCollideCallbacks: Array<{
  21000. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  21001. otherImpostors: Array<PhysicsImpostor>;
  21002. }>;
  21003. private _deltaPosition;
  21004. private _deltaRotation;
  21005. private _deltaRotationConjugated;
  21006. /** @hidden */
  21007. _isFromLine: boolean;
  21008. private _parent;
  21009. private _isDisposed;
  21010. private static _tmpVecs;
  21011. private static _tmpQuat;
  21012. /**
  21013. * Specifies if the physics imposter is disposed
  21014. */
  21015. readonly isDisposed: boolean;
  21016. /**
  21017. * Gets the mass of the physics imposter
  21018. */
  21019. mass: number;
  21020. /**
  21021. * Gets the coefficient of friction
  21022. */
  21023. /**
  21024. * Sets the coefficient of friction
  21025. */
  21026. friction: number;
  21027. /**
  21028. * Gets the coefficient of restitution
  21029. */
  21030. /**
  21031. * Sets the coefficient of restitution
  21032. */
  21033. restitution: number;
  21034. /**
  21035. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  21036. */
  21037. /**
  21038. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  21039. */
  21040. pressure: number;
  21041. /**
  21042. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21043. */
  21044. /**
  21045. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  21046. */
  21047. stiffness: number;
  21048. /**
  21049. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21050. */
  21051. /**
  21052. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  21053. */
  21054. velocityIterations: number;
  21055. /**
  21056. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21057. */
  21058. /**
  21059. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  21060. */
  21061. positionIterations: number;
  21062. /**
  21063. * The unique id of the physics imposter
  21064. * set by the physics engine when adding this impostor to the array
  21065. */
  21066. uniqueId: number;
  21067. /**
  21068. * @hidden
  21069. */
  21070. soft: boolean;
  21071. /**
  21072. * @hidden
  21073. */
  21074. segments: number;
  21075. private _joints;
  21076. /**
  21077. * Initializes the physics imposter
  21078. * @param object The physics-enabled object used as the physics imposter
  21079. * @param type The type of the physics imposter
  21080. * @param _options The options for the physics imposter
  21081. * @param _scene The Babylon scene
  21082. */
  21083. constructor(
  21084. /**
  21085. * The physics-enabled object used as the physics imposter
  21086. */
  21087. object: IPhysicsEnabledObject,
  21088. /**
  21089. * The type of the physics imposter
  21090. */
  21091. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  21092. /**
  21093. * This function will completly initialize this impostor.
  21094. * It will create a new body - but only if this mesh has no parent.
  21095. * If it has, this impostor will not be used other than to define the impostor
  21096. * of the child mesh.
  21097. * @hidden
  21098. */
  21099. _init(): void;
  21100. private _getPhysicsParent;
  21101. /**
  21102. * Should a new body be generated.
  21103. * @returns boolean specifying if body initialization is required
  21104. */
  21105. isBodyInitRequired(): boolean;
  21106. /**
  21107. * Sets the updated scaling
  21108. * @param updated Specifies if the scaling is updated
  21109. */
  21110. setScalingUpdated(): void;
  21111. /**
  21112. * Force a regeneration of this or the parent's impostor's body.
  21113. * Use under cautious - This will remove all joints already implemented.
  21114. */
  21115. forceUpdate(): void;
  21116. /**
  21117. * Gets the body that holds this impostor. Either its own, or its parent.
  21118. */
  21119. /**
  21120. * Set the physics body. Used mainly by the physics engine/plugin
  21121. */
  21122. physicsBody: any;
  21123. /**
  21124. * Get the parent of the physics imposter
  21125. * @returns Physics imposter or null
  21126. */
  21127. /**
  21128. * Sets the parent of the physics imposter
  21129. */
  21130. parent: Nullable<PhysicsImpostor>;
  21131. /**
  21132. * Resets the update flags
  21133. */
  21134. resetUpdateFlags(): void;
  21135. /**
  21136. * Gets the object extend size
  21137. * @returns the object extend size
  21138. */
  21139. getObjectExtendSize(): Vector3;
  21140. /**
  21141. * Gets the object center
  21142. * @returns The object center
  21143. */
  21144. getObjectCenter(): Vector3;
  21145. /**
  21146. * Get a specific parametes from the options parameter
  21147. * @param paramName The object parameter name
  21148. * @returns The object parameter
  21149. */
  21150. getParam(paramName: string): any;
  21151. /**
  21152. * Sets a specific parameter in the options given to the physics plugin
  21153. * @param paramName The parameter name
  21154. * @param value The value of the parameter
  21155. */
  21156. setParam(paramName: string, value: number): void;
  21157. /**
  21158. * Specifically change the body's mass option. Won't recreate the physics body object
  21159. * @param mass The mass of the physics imposter
  21160. */
  21161. setMass(mass: number): void;
  21162. /**
  21163. * Gets the linear velocity
  21164. * @returns linear velocity or null
  21165. */
  21166. getLinearVelocity(): Nullable<Vector3>;
  21167. /**
  21168. * Sets the linear velocity
  21169. * @param velocity linear velocity or null
  21170. */
  21171. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21172. /**
  21173. * Gets the angular velocity
  21174. * @returns angular velocity or null
  21175. */
  21176. getAngularVelocity(): Nullable<Vector3>;
  21177. /**
  21178. * Sets the angular velocity
  21179. * @param velocity The velocity or null
  21180. */
  21181. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21182. /**
  21183. * Execute a function with the physics plugin native code
  21184. * Provide a function the will have two variables - the world object and the physics body object
  21185. * @param func The function to execute with the physics plugin native code
  21186. */
  21187. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21188. /**
  21189. * Register a function that will be executed before the physics world is stepping forward
  21190. * @param func The function to execute before the physics world is stepped forward
  21191. */
  21192. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21193. /**
  21194. * Unregister a function that will be executed before the physics world is stepping forward
  21195. * @param func The function to execute before the physics world is stepped forward
  21196. */
  21197. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21198. /**
  21199. * Register a function that will be executed after the physics step
  21200. * @param func The function to execute after physics step
  21201. */
  21202. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21203. /**
  21204. * Unregisters a function that will be executed after the physics step
  21205. * @param func The function to execute after physics step
  21206. */
  21207. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21208. /**
  21209. * register a function that will be executed when this impostor collides against a different body
  21210. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21211. * @param func Callback that is executed on collision
  21212. */
  21213. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21214. /**
  21215. * Unregisters the physics imposter on contact
  21216. * @param collideAgainst The physics object to collide against
  21217. * @param func Callback to execute on collision
  21218. */
  21219. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21220. private _tmpQuat;
  21221. private _tmpQuat2;
  21222. /**
  21223. * Get the parent rotation
  21224. * @returns The parent rotation
  21225. */
  21226. getParentsRotation(): Quaternion;
  21227. /**
  21228. * this function is executed by the physics engine.
  21229. */
  21230. beforeStep: () => void;
  21231. /**
  21232. * this function is executed by the physics engine
  21233. */
  21234. afterStep: () => void;
  21235. /**
  21236. * Legacy collision detection event support
  21237. */
  21238. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21239. /**
  21240. * event and body object due to cannon's event-based architecture.
  21241. */
  21242. onCollide: (e: {
  21243. body: any;
  21244. }) => void;
  21245. /**
  21246. * Apply a force
  21247. * @param force The force to apply
  21248. * @param contactPoint The contact point for the force
  21249. * @returns The physics imposter
  21250. */
  21251. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21252. /**
  21253. * Apply an impulse
  21254. * @param force The impulse force
  21255. * @param contactPoint The contact point for the impulse force
  21256. * @returns The physics imposter
  21257. */
  21258. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21259. /**
  21260. * A help function to create a joint
  21261. * @param otherImpostor A physics imposter used to create a joint
  21262. * @param jointType The type of joint
  21263. * @param jointData The data for the joint
  21264. * @returns The physics imposter
  21265. */
  21266. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21267. /**
  21268. * Add a joint to this impostor with a different impostor
  21269. * @param otherImpostor A physics imposter used to add a joint
  21270. * @param joint The joint to add
  21271. * @returns The physics imposter
  21272. */
  21273. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21274. /**
  21275. * Add an anchor to a cloth impostor
  21276. * @param otherImpostor rigid impostor to anchor to
  21277. * @param width ratio across width from 0 to 1
  21278. * @param height ratio up height from 0 to 1
  21279. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21280. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21281. * @returns impostor the soft imposter
  21282. */
  21283. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21284. /**
  21285. * Add a hook to a rope impostor
  21286. * @param otherImpostor rigid impostor to anchor to
  21287. * @param length ratio across rope from 0 to 1
  21288. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21289. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21290. * @returns impostor the rope imposter
  21291. */
  21292. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21293. /**
  21294. * Will keep this body still, in a sleep mode.
  21295. * @returns the physics imposter
  21296. */
  21297. sleep(): PhysicsImpostor;
  21298. /**
  21299. * Wake the body up.
  21300. * @returns The physics imposter
  21301. */
  21302. wakeUp(): PhysicsImpostor;
  21303. /**
  21304. * Clones the physics imposter
  21305. * @param newObject The physics imposter clones to this physics-enabled object
  21306. * @returns A nullable physics imposter
  21307. */
  21308. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21309. /**
  21310. * Disposes the physics imposter
  21311. */
  21312. dispose(): void;
  21313. /**
  21314. * Sets the delta position
  21315. * @param position The delta position amount
  21316. */
  21317. setDeltaPosition(position: Vector3): void;
  21318. /**
  21319. * Sets the delta rotation
  21320. * @param rotation The delta rotation amount
  21321. */
  21322. setDeltaRotation(rotation: Quaternion): void;
  21323. /**
  21324. * Gets the box size of the physics imposter and stores the result in the input parameter
  21325. * @param result Stores the box size
  21326. * @returns The physics imposter
  21327. */
  21328. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21329. /**
  21330. * Gets the radius of the physics imposter
  21331. * @returns Radius of the physics imposter
  21332. */
  21333. getRadius(): number;
  21334. /**
  21335. * Sync a bone with this impostor
  21336. * @param bone The bone to sync to the impostor.
  21337. * @param boneMesh The mesh that the bone is influencing.
  21338. * @param jointPivot The pivot of the joint / bone in local space.
  21339. * @param distToJoint Optional distance from the impostor to the joint.
  21340. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21341. */
  21342. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21343. /**
  21344. * Sync impostor to a bone
  21345. * @param bone The bone that the impostor will be synced to.
  21346. * @param boneMesh The mesh that the bone is influencing.
  21347. * @param jointPivot The pivot of the joint / bone in local space.
  21348. * @param distToJoint Optional distance from the impostor to the joint.
  21349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21350. * @param boneAxis Optional vector3 axis the bone is aligned with
  21351. */
  21352. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21353. /**
  21354. * No-Imposter type
  21355. */
  21356. static NoImpostor: number;
  21357. /**
  21358. * Sphere-Imposter type
  21359. */
  21360. static SphereImpostor: number;
  21361. /**
  21362. * Box-Imposter type
  21363. */
  21364. static BoxImpostor: number;
  21365. /**
  21366. * Plane-Imposter type
  21367. */
  21368. static PlaneImpostor: number;
  21369. /**
  21370. * Mesh-imposter type
  21371. */
  21372. static MeshImpostor: number;
  21373. /**
  21374. * Cylinder-Imposter type
  21375. */
  21376. static CylinderImpostor: number;
  21377. /**
  21378. * Particle-Imposter type
  21379. */
  21380. static ParticleImpostor: number;
  21381. /**
  21382. * Heightmap-Imposter type
  21383. */
  21384. static HeightmapImpostor: number;
  21385. /**
  21386. * ConvexHull-Impostor type (Ammo.js plugin only)
  21387. */
  21388. static ConvexHullImpostor: number;
  21389. /**
  21390. * Rope-Imposter type
  21391. */
  21392. static RopeImpostor: number;
  21393. /**
  21394. * Cloth-Imposter type
  21395. */
  21396. static ClothImpostor: number;
  21397. /**
  21398. * Softbody-Imposter type
  21399. */
  21400. static SoftbodyImpostor: number;
  21401. }
  21402. }
  21403. declare module "babylonjs/Meshes/mesh" {
  21404. import { Observable } from "babylonjs/Misc/observable";
  21405. import { IAnimatable } from "babylonjs/Misc/tools";
  21406. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21407. import { Camera } from "babylonjs/Cameras/camera";
  21408. import { Scene } from "babylonjs/scene";
  21409. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21410. import { Engine } from "babylonjs/Engines/engine";
  21411. import { Node } from "babylonjs/node";
  21412. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21413. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21414. import { Buffer } from "babylonjs/Meshes/buffer";
  21415. import { Geometry } from "babylonjs/Meshes/geometry";
  21416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21418. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21419. import { Effect } from "babylonjs/Materials/effect";
  21420. import { Material } from "babylonjs/Materials/material";
  21421. import { Skeleton } from "babylonjs/Bones/skeleton";
  21422. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21423. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21424. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21425. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21426. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21427. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21428. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21429. /**
  21430. * @hidden
  21431. **/
  21432. export class _CreationDataStorage {
  21433. closePath?: boolean;
  21434. closeArray?: boolean;
  21435. idx: number[];
  21436. dashSize: number;
  21437. gapSize: number;
  21438. path3D: Path3D;
  21439. pathArray: Vector3[][];
  21440. arc: number;
  21441. radius: number;
  21442. cap: number;
  21443. tessellation: number;
  21444. }
  21445. /**
  21446. * @hidden
  21447. **/
  21448. class _InstanceDataStorage {
  21449. visibleInstances: any;
  21450. batchCache: _InstancesBatch;
  21451. instancesBufferSize: number;
  21452. instancesBuffer: Nullable<Buffer>;
  21453. instancesData: Float32Array;
  21454. overridenInstanceCount: number;
  21455. isFrozen: boolean;
  21456. previousBatch: _InstancesBatch;
  21457. hardwareInstancedRendering: boolean;
  21458. sideOrientation: number;
  21459. }
  21460. /**
  21461. * @hidden
  21462. **/
  21463. export class _InstancesBatch {
  21464. mustReturn: boolean;
  21465. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21466. renderSelf: boolean[];
  21467. hardwareInstancedRendering: boolean[];
  21468. }
  21469. /**
  21470. * Class used to represent renderable models
  21471. */
  21472. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21473. /**
  21474. * Mesh side orientation : usually the external or front surface
  21475. */
  21476. static readonly FRONTSIDE: number;
  21477. /**
  21478. * Mesh side orientation : usually the internal or back surface
  21479. */
  21480. static readonly BACKSIDE: number;
  21481. /**
  21482. * Mesh side orientation : both internal and external or front and back surfaces
  21483. */
  21484. static readonly DOUBLESIDE: number;
  21485. /**
  21486. * Mesh side orientation : by default, `FRONTSIDE`
  21487. */
  21488. static readonly DEFAULTSIDE: number;
  21489. /**
  21490. * Mesh cap setting : no cap
  21491. */
  21492. static readonly NO_CAP: number;
  21493. /**
  21494. * Mesh cap setting : one cap at the beginning of the mesh
  21495. */
  21496. static readonly CAP_START: number;
  21497. /**
  21498. * Mesh cap setting : one cap at the end of the mesh
  21499. */
  21500. static readonly CAP_END: number;
  21501. /**
  21502. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21503. */
  21504. static readonly CAP_ALL: number;
  21505. /**
  21506. * Mesh pattern setting : no flip or rotate
  21507. */
  21508. static readonly NO_FLIP: number;
  21509. /**
  21510. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  21511. */
  21512. static readonly FLIP_TILE: number;
  21513. /**
  21514. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  21515. */
  21516. static readonly ROTATE_TILE: number;
  21517. /**
  21518. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  21519. */
  21520. static readonly FLIP_ROW: number;
  21521. /**
  21522. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  21523. */
  21524. static readonly ROTATE_ROW: number;
  21525. /**
  21526. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  21527. */
  21528. static readonly FLIP_N_ROTATE_TILE: number;
  21529. /**
  21530. * Mesh pattern setting : rotate pattern and rotate
  21531. */
  21532. static readonly FLIP_N_ROTATE_ROW: number;
  21533. /**
  21534. * Mesh tile positioning : part tiles same on left/right or top/bottom
  21535. */
  21536. static readonly CENTER: number;
  21537. /**
  21538. * Mesh tile positioning : part tiles on left
  21539. */
  21540. static readonly LEFT: number;
  21541. /**
  21542. * Mesh tile positioning : part tiles on right
  21543. */
  21544. static readonly RIGHT: number;
  21545. /**
  21546. * Mesh tile positioning : part tiles on top
  21547. */
  21548. static readonly TOP: number;
  21549. /**
  21550. * Mesh tile positioning : part tiles on bottom
  21551. */
  21552. static readonly BOTTOM: number;
  21553. /**
  21554. * Gets the default side orientation.
  21555. * @param orientation the orientation to value to attempt to get
  21556. * @returns the default orientation
  21557. * @hidden
  21558. */
  21559. static _GetDefaultSideOrientation(orientation?: number): number;
  21560. private _internalMeshDataInfo;
  21561. /**
  21562. * An event triggered before rendering the mesh
  21563. */
  21564. readonly onBeforeRenderObservable: Observable<Mesh>;
  21565. /**
  21566. * An event triggered before binding the mesh
  21567. */
  21568. readonly onBeforeBindObservable: Observable<Mesh>;
  21569. /**
  21570. * An event triggered after rendering the mesh
  21571. */
  21572. readonly onAfterRenderObservable: Observable<Mesh>;
  21573. /**
  21574. * An event triggered before drawing the mesh
  21575. */
  21576. readonly onBeforeDrawObservable: Observable<Mesh>;
  21577. private _onBeforeDrawObserver;
  21578. /**
  21579. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21580. */
  21581. onBeforeDraw: () => void;
  21582. /**
  21583. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21584. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21585. */
  21586. delayLoadState: number;
  21587. /**
  21588. * Gets the list of instances created from this mesh
  21589. * it is not supposed to be modified manually.
  21590. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21591. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21592. */
  21593. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21594. /**
  21595. * Gets the file containing delay loading data for this mesh
  21596. */
  21597. delayLoadingFile: string;
  21598. /** @hidden */
  21599. _binaryInfo: any;
  21600. /**
  21601. * User defined function used to change how LOD level selection is done
  21602. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21603. */
  21604. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21605. /**
  21606. * Gets or sets the morph target manager
  21607. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21608. */
  21609. morphTargetManager: Nullable<MorphTargetManager>;
  21610. /** @hidden */
  21611. _creationDataStorage: Nullable<_CreationDataStorage>;
  21612. /** @hidden */
  21613. _geometry: Nullable<Geometry>;
  21614. /** @hidden */
  21615. _delayInfo: Array<string>;
  21616. /** @hidden */
  21617. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21618. /** @hidden */
  21619. _instanceDataStorage: _InstanceDataStorage;
  21620. private _effectiveMaterial;
  21621. /** @hidden */
  21622. _shouldGenerateFlatShading: boolean;
  21623. /** @hidden */
  21624. _originalBuilderSideOrientation: number;
  21625. /**
  21626. * Use this property to change the original side orientation defined at construction time
  21627. */
  21628. overrideMaterialSideOrientation: Nullable<number>;
  21629. /**
  21630. * Gets the source mesh (the one used to clone this one from)
  21631. */
  21632. readonly source: Nullable<Mesh>;
  21633. /**
  21634. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21635. */
  21636. isUnIndexed: boolean;
  21637. /**
  21638. * @constructor
  21639. * @param name The value used by scene.getMeshByName() to do a lookup.
  21640. * @param scene The scene to add this mesh to.
  21641. * @param parent The parent of this mesh, if it has one
  21642. * @param source An optional Mesh from which geometry is shared, cloned.
  21643. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21644. * When false, achieved by calling a clone(), also passing False.
  21645. * This will make creation of children, recursive.
  21646. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21647. */
  21648. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21649. /**
  21650. * Gets the class name
  21651. * @returns the string "Mesh".
  21652. */
  21653. getClassName(): string;
  21654. /** @hidden */
  21655. readonly _isMesh: boolean;
  21656. /**
  21657. * Returns a description of this mesh
  21658. * @param fullDetails define if full details about this mesh must be used
  21659. * @returns a descriptive string representing this mesh
  21660. */
  21661. toString(fullDetails?: boolean): string;
  21662. /** @hidden */
  21663. _unBindEffect(): void;
  21664. /**
  21665. * Gets a boolean indicating if this mesh has LOD
  21666. */
  21667. readonly hasLODLevels: boolean;
  21668. /**
  21669. * Gets the list of MeshLODLevel associated with the current mesh
  21670. * @returns an array of MeshLODLevel
  21671. */
  21672. getLODLevels(): MeshLODLevel[];
  21673. private _sortLODLevels;
  21674. /**
  21675. * Add a mesh as LOD level triggered at the given distance.
  21676. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21677. * @param distance The distance from the center of the object to show this level
  21678. * @param mesh The mesh to be added as LOD level (can be null)
  21679. * @return This mesh (for chaining)
  21680. */
  21681. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21682. /**
  21683. * Returns the LOD level mesh at the passed distance or null if not found.
  21684. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21685. * @param distance The distance from the center of the object to show this level
  21686. * @returns a Mesh or `null`
  21687. */
  21688. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21689. /**
  21690. * Remove a mesh from the LOD array
  21691. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21692. * @param mesh defines the mesh to be removed
  21693. * @return This mesh (for chaining)
  21694. */
  21695. removeLODLevel(mesh: Mesh): Mesh;
  21696. /**
  21697. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21698. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21699. * @param camera defines the camera to use to compute distance
  21700. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21701. * @return This mesh (for chaining)
  21702. */
  21703. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21704. /**
  21705. * Gets the mesh internal Geometry object
  21706. */
  21707. readonly geometry: Nullable<Geometry>;
  21708. /**
  21709. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21710. * @returns the total number of vertices
  21711. */
  21712. getTotalVertices(): number;
  21713. /**
  21714. * Returns the content of an associated vertex buffer
  21715. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21716. * - VertexBuffer.PositionKind
  21717. * - VertexBuffer.UVKind
  21718. * - VertexBuffer.UV2Kind
  21719. * - VertexBuffer.UV3Kind
  21720. * - VertexBuffer.UV4Kind
  21721. * - VertexBuffer.UV5Kind
  21722. * - VertexBuffer.UV6Kind
  21723. * - VertexBuffer.ColorKind
  21724. * - VertexBuffer.MatricesIndicesKind
  21725. * - VertexBuffer.MatricesIndicesExtraKind
  21726. * - VertexBuffer.MatricesWeightsKind
  21727. * - VertexBuffer.MatricesWeightsExtraKind
  21728. * @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
  21729. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21730. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21731. */
  21732. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21733. /**
  21734. * Returns the mesh VertexBuffer object from the requested `kind`
  21735. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21736. * - VertexBuffer.PositionKind
  21737. * - VertexBuffer.NormalKind
  21738. * - VertexBuffer.UVKind
  21739. * - VertexBuffer.UV2Kind
  21740. * - VertexBuffer.UV3Kind
  21741. * - VertexBuffer.UV4Kind
  21742. * - VertexBuffer.UV5Kind
  21743. * - VertexBuffer.UV6Kind
  21744. * - VertexBuffer.ColorKind
  21745. * - VertexBuffer.MatricesIndicesKind
  21746. * - VertexBuffer.MatricesIndicesExtraKind
  21747. * - VertexBuffer.MatricesWeightsKind
  21748. * - VertexBuffer.MatricesWeightsExtraKind
  21749. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21750. */
  21751. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21752. /**
  21753. * Tests if a specific vertex buffer is associated with this mesh
  21754. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21755. * - VertexBuffer.PositionKind
  21756. * - VertexBuffer.NormalKind
  21757. * - VertexBuffer.UVKind
  21758. * - VertexBuffer.UV2Kind
  21759. * - VertexBuffer.UV3Kind
  21760. * - VertexBuffer.UV4Kind
  21761. * - VertexBuffer.UV5Kind
  21762. * - VertexBuffer.UV6Kind
  21763. * - VertexBuffer.ColorKind
  21764. * - VertexBuffer.MatricesIndicesKind
  21765. * - VertexBuffer.MatricesIndicesExtraKind
  21766. * - VertexBuffer.MatricesWeightsKind
  21767. * - VertexBuffer.MatricesWeightsExtraKind
  21768. * @returns a boolean
  21769. */
  21770. isVerticesDataPresent(kind: string): boolean;
  21771. /**
  21772. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21773. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21774. * - VertexBuffer.PositionKind
  21775. * - VertexBuffer.UVKind
  21776. * - VertexBuffer.UV2Kind
  21777. * - VertexBuffer.UV3Kind
  21778. * - VertexBuffer.UV4Kind
  21779. * - VertexBuffer.UV5Kind
  21780. * - VertexBuffer.UV6Kind
  21781. * - VertexBuffer.ColorKind
  21782. * - VertexBuffer.MatricesIndicesKind
  21783. * - VertexBuffer.MatricesIndicesExtraKind
  21784. * - VertexBuffer.MatricesWeightsKind
  21785. * - VertexBuffer.MatricesWeightsExtraKind
  21786. * @returns a boolean
  21787. */
  21788. isVertexBufferUpdatable(kind: string): boolean;
  21789. /**
  21790. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21791. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21792. * - VertexBuffer.PositionKind
  21793. * - VertexBuffer.NormalKind
  21794. * - VertexBuffer.UVKind
  21795. * - VertexBuffer.UV2Kind
  21796. * - VertexBuffer.UV3Kind
  21797. * - VertexBuffer.UV4Kind
  21798. * - VertexBuffer.UV5Kind
  21799. * - VertexBuffer.UV6Kind
  21800. * - VertexBuffer.ColorKind
  21801. * - VertexBuffer.MatricesIndicesKind
  21802. * - VertexBuffer.MatricesIndicesExtraKind
  21803. * - VertexBuffer.MatricesWeightsKind
  21804. * - VertexBuffer.MatricesWeightsExtraKind
  21805. * @returns an array of strings
  21806. */
  21807. getVerticesDataKinds(): string[];
  21808. /**
  21809. * Returns a positive integer : the total number of indices in this mesh geometry.
  21810. * @returns the numner of indices or zero if the mesh has no geometry.
  21811. */
  21812. getTotalIndices(): number;
  21813. /**
  21814. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21815. * @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.
  21816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21817. * @returns the indices array or an empty array if the mesh has no geometry
  21818. */
  21819. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21820. readonly isBlocked: boolean;
  21821. /**
  21822. * Determine if the current mesh is ready to be rendered
  21823. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21824. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21825. * @returns true if all associated assets are ready (material, textures, shaders)
  21826. */
  21827. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21828. /**
  21829. * 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.
  21830. */
  21831. readonly areNormalsFrozen: boolean;
  21832. /**
  21833. * 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.
  21834. * @returns the current mesh
  21835. */
  21836. freezeNormals(): Mesh;
  21837. /**
  21838. * 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
  21839. * @returns the current mesh
  21840. */
  21841. unfreezeNormals(): Mesh;
  21842. /**
  21843. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21844. */
  21845. overridenInstanceCount: number;
  21846. /** @hidden */
  21847. _preActivate(): Mesh;
  21848. /** @hidden */
  21849. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21850. /** @hidden */
  21851. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21852. /**
  21853. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21854. * This means the mesh underlying bounding box and sphere are recomputed.
  21855. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21856. * @returns the current mesh
  21857. */
  21858. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21859. /** @hidden */
  21860. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21861. /**
  21862. * This function will subdivide the mesh into multiple submeshes
  21863. * @param count defines the expected number of submeshes
  21864. */
  21865. subdivide(count: number): void;
  21866. /**
  21867. * Copy a FloatArray into a specific associated vertex buffer
  21868. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21869. * - VertexBuffer.PositionKind
  21870. * - VertexBuffer.UVKind
  21871. * - VertexBuffer.UV2Kind
  21872. * - VertexBuffer.UV3Kind
  21873. * - VertexBuffer.UV4Kind
  21874. * - VertexBuffer.UV5Kind
  21875. * - VertexBuffer.UV6Kind
  21876. * - VertexBuffer.ColorKind
  21877. * - VertexBuffer.MatricesIndicesKind
  21878. * - VertexBuffer.MatricesIndicesExtraKind
  21879. * - VertexBuffer.MatricesWeightsKind
  21880. * - VertexBuffer.MatricesWeightsExtraKind
  21881. * @param data defines the data source
  21882. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21883. * @param stride defines the data stride size (can be null)
  21884. * @returns the current mesh
  21885. */
  21886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21887. /**
  21888. * Flags an associated vertex buffer as updatable
  21889. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21890. * - VertexBuffer.PositionKind
  21891. * - VertexBuffer.UVKind
  21892. * - VertexBuffer.UV2Kind
  21893. * - VertexBuffer.UV3Kind
  21894. * - VertexBuffer.UV4Kind
  21895. * - VertexBuffer.UV5Kind
  21896. * - VertexBuffer.UV6Kind
  21897. * - VertexBuffer.ColorKind
  21898. * - VertexBuffer.MatricesIndicesKind
  21899. * - VertexBuffer.MatricesIndicesExtraKind
  21900. * - VertexBuffer.MatricesWeightsKind
  21901. * - VertexBuffer.MatricesWeightsExtraKind
  21902. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21903. */
  21904. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21905. /**
  21906. * Sets the mesh global Vertex Buffer
  21907. * @param buffer defines the buffer to use
  21908. * @returns the current mesh
  21909. */
  21910. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21911. /**
  21912. * Update a specific associated vertex buffer
  21913. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21914. * - VertexBuffer.PositionKind
  21915. * - VertexBuffer.UVKind
  21916. * - VertexBuffer.UV2Kind
  21917. * - VertexBuffer.UV3Kind
  21918. * - VertexBuffer.UV4Kind
  21919. * - VertexBuffer.UV5Kind
  21920. * - VertexBuffer.UV6Kind
  21921. * - VertexBuffer.ColorKind
  21922. * - VertexBuffer.MatricesIndicesKind
  21923. * - VertexBuffer.MatricesIndicesExtraKind
  21924. * - VertexBuffer.MatricesWeightsKind
  21925. * - VertexBuffer.MatricesWeightsExtraKind
  21926. * @param data defines the data source
  21927. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21928. * @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)
  21929. * @returns the current mesh
  21930. */
  21931. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21932. /**
  21933. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21934. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21935. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21936. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21937. * @returns the current mesh
  21938. */
  21939. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21940. /**
  21941. * Creates a un-shared specific occurence of the geometry for the mesh.
  21942. * @returns the current mesh
  21943. */
  21944. makeGeometryUnique(): Mesh;
  21945. /**
  21946. * Set the index buffer of this mesh
  21947. * @param indices defines the source data
  21948. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21949. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21950. * @returns the current mesh
  21951. */
  21952. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21953. /**
  21954. * Update the current index buffer
  21955. * @param indices defines the source data
  21956. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21957. * @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)
  21958. * @returns the current mesh
  21959. */
  21960. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21961. /**
  21962. * Invert the geometry to move from a right handed system to a left handed one.
  21963. * @returns the current mesh
  21964. */
  21965. toLeftHanded(): Mesh;
  21966. /** @hidden */
  21967. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21968. /** @hidden */
  21969. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21970. /**
  21971. * Registers for this mesh a javascript function called just before the rendering process
  21972. * @param func defines the function to call before rendering this mesh
  21973. * @returns the current mesh
  21974. */
  21975. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21976. /**
  21977. * Disposes a previously registered javascript function called before the rendering
  21978. * @param func defines the function to remove
  21979. * @returns the current mesh
  21980. */
  21981. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21982. /**
  21983. * Registers for this mesh a javascript function called just after the rendering is complete
  21984. * @param func defines the function to call after rendering this mesh
  21985. * @returns the current mesh
  21986. */
  21987. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21988. /**
  21989. * Disposes a previously registered javascript function called after the rendering.
  21990. * @param func defines the function to remove
  21991. * @returns the current mesh
  21992. */
  21993. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21994. /** @hidden */
  21995. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21996. /** @hidden */
  21997. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21998. /** @hidden */
  21999. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  22000. /** @hidden */
  22001. _freeze(): void;
  22002. /** @hidden */
  22003. _unFreeze(): void;
  22004. /**
  22005. * 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
  22006. * @param subMesh defines the subMesh to render
  22007. * @param enableAlphaMode defines if alpha mode can be changed
  22008. * @returns the current mesh
  22009. */
  22010. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  22011. private _onBeforeDraw;
  22012. /**
  22013. * Renormalize the mesh and patch it up if there are no weights
  22014. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  22015. * However in the case of zero weights then we set just a single influence to 1.
  22016. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  22017. */
  22018. cleanMatrixWeights(): void;
  22019. private normalizeSkinFourWeights;
  22020. private normalizeSkinWeightsAndExtra;
  22021. /**
  22022. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  22023. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  22024. * the user know there was an issue with importing the mesh
  22025. * @returns a validation object with skinned, valid and report string
  22026. */
  22027. validateSkinning(): {
  22028. skinned: boolean;
  22029. valid: boolean;
  22030. report: string;
  22031. };
  22032. /** @hidden */
  22033. _checkDelayState(): Mesh;
  22034. private _queueLoad;
  22035. /**
  22036. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  22037. * A mesh is in the frustum if its bounding box intersects the frustum
  22038. * @param frustumPlanes defines the frustum to test
  22039. * @returns true if the mesh is in the frustum planes
  22040. */
  22041. isInFrustum(frustumPlanes: Plane[]): boolean;
  22042. /**
  22043. * Sets the mesh material by the material or multiMaterial `id` property
  22044. * @param id is a string identifying the material or the multiMaterial
  22045. * @returns the current mesh
  22046. */
  22047. setMaterialByID(id: string): Mesh;
  22048. /**
  22049. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  22050. * @returns an array of IAnimatable
  22051. */
  22052. getAnimatables(): IAnimatable[];
  22053. /**
  22054. * Modifies the mesh geometry according to the passed transformation matrix.
  22055. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  22056. * The mesh normals are modified using the same transformation.
  22057. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22058. * @param transform defines the transform matrix to use
  22059. * @see http://doc.babylonjs.com/resources/baking_transformations
  22060. * @returns the current mesh
  22061. */
  22062. bakeTransformIntoVertices(transform: Matrix): Mesh;
  22063. /**
  22064. * Modifies the mesh geometry according to its own current World Matrix.
  22065. * The mesh World Matrix is then reset.
  22066. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  22067. * Note that, under the hood, this method sets a new VertexBuffer each call.
  22068. * @see http://doc.babylonjs.com/resources/baking_transformations
  22069. * @returns the current mesh
  22070. */
  22071. bakeCurrentTransformIntoVertices(): Mesh;
  22072. /** @hidden */
  22073. readonly _positions: Nullable<Vector3[]>;
  22074. /** @hidden */
  22075. _resetPointsArrayCache(): Mesh;
  22076. /** @hidden */
  22077. _generatePointsArray(): boolean;
  22078. /**
  22079. * Returns a new Mesh object generated from the current mesh properties.
  22080. * This method must not get confused with createInstance()
  22081. * @param name is a string, the name given to the new mesh
  22082. * @param newParent can be any Node object (default `null`)
  22083. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  22084. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  22085. * @returns a new mesh
  22086. */
  22087. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  22088. /**
  22089. * Releases resources associated with this mesh.
  22090. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  22091. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  22092. */
  22093. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  22094. /**
  22095. * Modifies the mesh geometry according to a displacement map.
  22096. * 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.
  22097. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22098. * @param url is a string, the URL from the image file is to be downloaded.
  22099. * @param minHeight is the lower limit of the displacement.
  22100. * @param maxHeight is the upper limit of the displacement.
  22101. * @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.
  22102. * @param uvOffset is an optional vector2 used to offset UV.
  22103. * @param uvScale is an optional vector2 used to scale UV.
  22104. * @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.
  22105. * @returns the Mesh.
  22106. */
  22107. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22108. /**
  22109. * Modifies the mesh geometry according to a displacementMap buffer.
  22110. * 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.
  22111. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  22112. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  22113. * @param heightMapWidth is the width of the buffer image.
  22114. * @param heightMapHeight is the height of the buffer image.
  22115. * @param minHeight is the lower limit of the displacement.
  22116. * @param maxHeight is the upper limit of the displacement.
  22117. * @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.
  22118. * @param uvOffset is an optional vector2 used to offset UV.
  22119. * @param uvScale is an optional vector2 used to scale UV.
  22120. * @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.
  22121. * @returns the Mesh.
  22122. */
  22123. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  22124. /**
  22125. * Modify the mesh to get a flat shading rendering.
  22126. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  22127. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  22128. * @returns current mesh
  22129. */
  22130. convertToFlatShadedMesh(): Mesh;
  22131. /**
  22132. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  22133. * In other words, more vertices, no more indices and a single bigger VBO.
  22134. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  22135. * @returns current mesh
  22136. */
  22137. convertToUnIndexedMesh(): Mesh;
  22138. /**
  22139. * Inverses facet orientations.
  22140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22141. * @param flipNormals will also inverts the normals
  22142. * @returns current mesh
  22143. */
  22144. flipFaces(flipNormals?: boolean): Mesh;
  22145. /**
  22146. * Increase the number of facets and hence vertices in a mesh
  22147. * Vertex normals are interpolated from existing vertex normals
  22148. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22149. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22150. */
  22151. increaseVertices(numberPerEdge: number): void;
  22152. /**
  22153. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22154. * This will undo any application of covertToFlatShadedMesh
  22155. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22156. */
  22157. forceSharedVertices(): void;
  22158. /** @hidden */
  22159. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22160. /** @hidden */
  22161. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22162. /**
  22163. * Creates a new InstancedMesh object from the mesh model.
  22164. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22165. * @param name defines the name of the new instance
  22166. * @returns a new InstancedMesh
  22167. */
  22168. createInstance(name: string): InstancedMesh;
  22169. /**
  22170. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22171. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22172. * @returns the current mesh
  22173. */
  22174. synchronizeInstances(): Mesh;
  22175. /**
  22176. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22177. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22178. * This should be used together with the simplification to avoid disappearing triangles.
  22179. * @param successCallback an optional success callback to be called after the optimization finished.
  22180. * @returns the current mesh
  22181. */
  22182. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22183. /**
  22184. * Serialize current mesh
  22185. * @param serializationObject defines the object which will receive the serialization data
  22186. */
  22187. serialize(serializationObject: any): void;
  22188. /** @hidden */
  22189. _syncGeometryWithMorphTargetManager(): void;
  22190. /** @hidden */
  22191. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22192. /**
  22193. * Returns a new Mesh object parsed from the source provided.
  22194. * @param parsedMesh is the source
  22195. * @param scene defines the hosting scene
  22196. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22197. * @returns a new Mesh
  22198. */
  22199. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22200. /**
  22201. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22202. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22203. * @param name defines the name of the mesh to create
  22204. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22205. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22206. * @param closePath creates a seam between the first and the last points of each path of the path array
  22207. * @param offset is taken in account only if the `pathArray` is containing a single path
  22208. * @param scene defines the hosting scene
  22209. * @param updatable defines if the mesh must be flagged as updatable
  22210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22211. * @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)
  22212. * @returns a new Mesh
  22213. */
  22214. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22215. /**
  22216. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22217. * @param name defines the name of the mesh to create
  22218. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22219. * @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
  22220. * @param scene defines the hosting scene
  22221. * @param updatable defines if the mesh must be flagged as updatable
  22222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22223. * @returns a new Mesh
  22224. */
  22225. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22226. /**
  22227. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22228. * @param name defines the name of the mesh to create
  22229. * @param size sets the size (float) of each box side (default 1)
  22230. * @param scene defines the hosting scene
  22231. * @param updatable defines if the mesh must be flagged as updatable
  22232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22233. * @returns a new Mesh
  22234. */
  22235. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22236. /**
  22237. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22238. * @param name defines the name of the mesh to create
  22239. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22240. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22241. * @param scene defines the hosting scene
  22242. * @param updatable defines if the mesh must be flagged as updatable
  22243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22244. * @returns a new Mesh
  22245. */
  22246. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22247. /**
  22248. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22249. * @param name defines the name of the mesh to create
  22250. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22251. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22252. * @param scene defines the hosting scene
  22253. * @returns a new Mesh
  22254. */
  22255. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22256. /**
  22257. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22258. * @param name defines the name of the mesh to create
  22259. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22260. * @param diameterTop set the top cap diameter (floats, default 1)
  22261. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22262. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22263. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22264. * @param scene defines the hosting scene
  22265. * @param updatable defines if the mesh must be flagged as updatable
  22266. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22267. * @returns a new Mesh
  22268. */
  22269. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22270. /**
  22271. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22272. * @param name defines the name of the mesh to create
  22273. * @param diameter sets the diameter size (float) of the torus (default 1)
  22274. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22275. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22276. * @param scene defines the hosting scene
  22277. * @param updatable defines if the mesh must be flagged as updatable
  22278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22279. * @returns a new Mesh
  22280. */
  22281. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22282. /**
  22283. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22284. * @param name defines the name of the mesh to create
  22285. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22286. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22287. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22288. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22289. * @param p the number of windings on X axis (positive integers, default 2)
  22290. * @param q the number of windings on Y axis (positive integers, default 3)
  22291. * @param scene defines the hosting scene
  22292. * @param updatable defines if the mesh must be flagged as updatable
  22293. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22294. * @returns a new Mesh
  22295. */
  22296. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22297. /**
  22298. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22299. * @param name defines the name of the mesh to create
  22300. * @param points is an array successive Vector3
  22301. * @param scene defines the hosting scene
  22302. * @param updatable defines if the mesh must be flagged as updatable
  22303. * @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).
  22304. * @returns a new Mesh
  22305. */
  22306. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22307. /**
  22308. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22309. * @param name defines the name of the mesh to create
  22310. * @param points is an array successive Vector3
  22311. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22312. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22313. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22314. * @param scene defines the hosting scene
  22315. * @param updatable defines if the mesh must be flagged as updatable
  22316. * @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)
  22317. * @returns a new Mesh
  22318. */
  22319. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22320. /**
  22321. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22322. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22323. * 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.
  22324. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22325. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22326. * Remember you can only change the shape positions, not their number when updating a polygon.
  22327. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22328. * @param name defines the name of the mesh to create
  22329. * @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
  22330. * @param scene defines the hosting scene
  22331. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22332. * @param updatable defines if the mesh must be flagged as updatable
  22333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22334. * @param earcutInjection can be used to inject your own earcut reference
  22335. * @returns a new Mesh
  22336. */
  22337. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22338. /**
  22339. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22340. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22341. * @param name defines the name of the mesh to create
  22342. * @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
  22343. * @param depth defines the height of extrusion
  22344. * @param scene defines the hosting scene
  22345. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22346. * @param updatable defines if the mesh must be flagged as updatable
  22347. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22348. * @param earcutInjection can be used to inject your own earcut reference
  22349. * @returns a new Mesh
  22350. */
  22351. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22352. /**
  22353. * Creates an extruded shape mesh.
  22354. * 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
  22355. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22356. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22357. * @param name defines the name of the mesh to create
  22358. * @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
  22359. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22360. * @param scale is the value to scale the shape
  22361. * @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
  22362. * @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
  22363. * @param scene defines the hosting scene
  22364. * @param updatable defines if the mesh must be flagged as updatable
  22365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22366. * @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)
  22367. * @returns a new Mesh
  22368. */
  22369. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22370. /**
  22371. * Creates an custom extruded shape mesh.
  22372. * The custom extrusion is a parametric shape.
  22373. * It has no predefined shape. Its final shape will depend on the input parameters.
  22374. * Please consider using the same method from the MeshBuilder class instead
  22375. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22376. * @param name defines the name of the mesh to create
  22377. * @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
  22378. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22379. * @param scaleFunction is a custom Javascript function called on each path point
  22380. * @param rotationFunction is a custom Javascript function called on each path point
  22381. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22382. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22383. * @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
  22384. * @param scene defines the hosting scene
  22385. * @param updatable defines if the mesh must be flagged as updatable
  22386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22387. * @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)
  22388. * @returns a new Mesh
  22389. */
  22390. 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;
  22391. /**
  22392. * Creates lathe mesh.
  22393. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22394. * Please consider using the same method from the MeshBuilder class instead
  22395. * @param name defines the name of the mesh to create
  22396. * @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
  22397. * @param radius is the radius value of the lathe
  22398. * @param tessellation is the side number of the lathe.
  22399. * @param scene defines the hosting scene
  22400. * @param updatable defines if the mesh must be flagged as updatable
  22401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22402. * @returns a new Mesh
  22403. */
  22404. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22405. /**
  22406. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22407. * @param name defines the name of the mesh to create
  22408. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22409. * @param scene defines the hosting scene
  22410. * @param updatable defines if the mesh must be flagged as updatable
  22411. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22412. * @returns a new Mesh
  22413. */
  22414. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22415. /**
  22416. * Creates a ground mesh.
  22417. * Please consider using the same method from the MeshBuilder class instead
  22418. * @param name defines the name of the mesh to create
  22419. * @param width set the width of the ground
  22420. * @param height set the height of the ground
  22421. * @param subdivisions sets the number of subdivisions per side
  22422. * @param scene defines the hosting scene
  22423. * @param updatable defines if the mesh must be flagged as updatable
  22424. * @returns a new Mesh
  22425. */
  22426. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22427. /**
  22428. * Creates a tiled ground mesh.
  22429. * Please consider using the same method from the MeshBuilder class instead
  22430. * @param name defines the name of the mesh to create
  22431. * @param xmin set the ground minimum X coordinate
  22432. * @param zmin set the ground minimum Y coordinate
  22433. * @param xmax set the ground maximum X coordinate
  22434. * @param zmax set the ground maximum Z coordinate
  22435. * @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
  22436. * @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
  22437. * @param scene defines the hosting scene
  22438. * @param updatable defines if the mesh must be flagged as updatable
  22439. * @returns a new Mesh
  22440. */
  22441. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22442. w: number;
  22443. h: number;
  22444. }, precision: {
  22445. w: number;
  22446. h: number;
  22447. }, scene: Scene, updatable?: boolean): Mesh;
  22448. /**
  22449. * Creates a ground mesh from a height map.
  22450. * Please consider using the same method from the MeshBuilder class instead
  22451. * @see http://doc.babylonjs.com/babylon101/height_map
  22452. * @param name defines the name of the mesh to create
  22453. * @param url sets the URL of the height map image resource
  22454. * @param width set the ground width size
  22455. * @param height set the ground height size
  22456. * @param subdivisions sets the number of subdivision per side
  22457. * @param minHeight is the minimum altitude on the ground
  22458. * @param maxHeight is the maximum altitude on the ground
  22459. * @param scene defines the hosting scene
  22460. * @param updatable defines if the mesh must be flagged as updatable
  22461. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22462. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22463. * @returns a new Mesh
  22464. */
  22465. 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;
  22466. /**
  22467. * Creates a tube mesh.
  22468. * The tube is a parametric shape.
  22469. * It has no predefined shape. Its final shape will depend on the input parameters.
  22470. * Please consider using the same method from the MeshBuilder class instead
  22471. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22472. * @param name defines the name of the mesh to create
  22473. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22474. * @param radius sets the tube radius size
  22475. * @param tessellation is the number of sides on the tubular surface
  22476. * @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
  22477. * @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
  22478. * @param scene defines the hosting scene
  22479. * @param updatable defines if the mesh must be flagged as updatable
  22480. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22481. * @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)
  22482. * @returns a new Mesh
  22483. */
  22484. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22485. (i: number, distance: number): number;
  22486. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22487. /**
  22488. * Creates a polyhedron mesh.
  22489. * Please consider using the same method from the MeshBuilder class instead.
  22490. * * 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
  22491. * * The parameter `size` (positive float, default 1) sets the polygon size
  22492. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22493. * * 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`
  22494. * * 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
  22495. * * 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)`)
  22496. * * 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
  22497. * * 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
  22498. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * If you create a double-sided mesh, you can choose what parts of 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
  22500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22501. * @param name defines the name of the mesh to create
  22502. * @param options defines the options used to create the mesh
  22503. * @param scene defines the hosting scene
  22504. * @returns a new Mesh
  22505. */
  22506. static CreatePolyhedron(name: string, options: {
  22507. type?: number;
  22508. size?: number;
  22509. sizeX?: number;
  22510. sizeY?: number;
  22511. sizeZ?: number;
  22512. custom?: any;
  22513. faceUV?: Vector4[];
  22514. faceColors?: Color4[];
  22515. updatable?: boolean;
  22516. sideOrientation?: number;
  22517. }, scene: Scene): Mesh;
  22518. /**
  22519. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22520. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22521. * * 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`)
  22522. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22523. * * 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
  22524. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22525. * * If you create a double-sided mesh, you can choose what parts of 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
  22526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22527. * @param name defines the name of the mesh
  22528. * @param options defines the options used to create the mesh
  22529. * @param scene defines the hosting scene
  22530. * @returns a new Mesh
  22531. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22532. */
  22533. static CreateIcoSphere(name: string, options: {
  22534. radius?: number;
  22535. flat?: boolean;
  22536. subdivisions?: number;
  22537. sideOrientation?: number;
  22538. updatable?: boolean;
  22539. }, scene: Scene): Mesh;
  22540. /**
  22541. * Creates a decal mesh.
  22542. * Please consider using the same method from the MeshBuilder class instead.
  22543. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22544. * @param name defines the name of the mesh
  22545. * @param sourceMesh defines the mesh receiving the decal
  22546. * @param position sets the position of the decal in world coordinates
  22547. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22548. * @param size sets the decal scaling
  22549. * @param angle sets the angle to rotate the decal
  22550. * @returns a new Mesh
  22551. */
  22552. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22553. /**
  22554. * Prepare internal position array for software CPU skinning
  22555. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22556. */
  22557. setPositionsForCPUSkinning(): Float32Array;
  22558. /**
  22559. * Prepare internal normal array for software CPU skinning
  22560. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22561. */
  22562. setNormalsForCPUSkinning(): Float32Array;
  22563. /**
  22564. * Updates the vertex buffer by applying transformation from the bones
  22565. * @param skeleton defines the skeleton to apply to current mesh
  22566. * @returns the current mesh
  22567. */
  22568. applySkeleton(skeleton: Skeleton): Mesh;
  22569. /**
  22570. * 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
  22571. * @param meshes defines the list of meshes to scan
  22572. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22573. */
  22574. static MinMax(meshes: AbstractMesh[]): {
  22575. min: Vector3;
  22576. max: Vector3;
  22577. };
  22578. /**
  22579. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22580. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22581. * @returns a vector3
  22582. */
  22583. static Center(meshesOrMinMaxVector: {
  22584. min: Vector3;
  22585. max: Vector3;
  22586. } | AbstractMesh[]): Vector3;
  22587. /**
  22588. * Merge the array of meshes into a single mesh for performance reasons.
  22589. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22590. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22591. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22592. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22593. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22594. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22595. * @returns a new mesh
  22596. */
  22597. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22598. /** @hidden */
  22599. addInstance(instance: InstancedMesh): void;
  22600. /** @hidden */
  22601. removeInstance(instance: InstancedMesh): void;
  22602. }
  22603. }
  22604. declare module "babylonjs/Materials/material" {
  22605. import { IAnimatable } from "babylonjs/Misc/tools";
  22606. import { SmartArray } from "babylonjs/Misc/smartArray";
  22607. import { Observable } from "babylonjs/Misc/observable";
  22608. import { Nullable } from "babylonjs/types";
  22609. import { Scene } from "babylonjs/scene";
  22610. import { Matrix } from "babylonjs/Maths/math";
  22611. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22613. import { Mesh } from "babylonjs/Meshes/mesh";
  22614. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22615. import { Effect } from "babylonjs/Materials/effect";
  22616. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22618. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22619. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22620. import { Animation } from "babylonjs/Animations/animation";
  22621. /**
  22622. * Base class for the main features of a material in Babylon.js
  22623. */
  22624. export class Material implements IAnimatable {
  22625. /**
  22626. * Returns the triangle fill mode
  22627. */
  22628. static readonly TriangleFillMode: number;
  22629. /**
  22630. * Returns the wireframe mode
  22631. */
  22632. static readonly WireFrameFillMode: number;
  22633. /**
  22634. * Returns the point fill mode
  22635. */
  22636. static readonly PointFillMode: number;
  22637. /**
  22638. * Returns the point list draw mode
  22639. */
  22640. static readonly PointListDrawMode: number;
  22641. /**
  22642. * Returns the line list draw mode
  22643. */
  22644. static readonly LineListDrawMode: number;
  22645. /**
  22646. * Returns the line loop draw mode
  22647. */
  22648. static readonly LineLoopDrawMode: number;
  22649. /**
  22650. * Returns the line strip draw mode
  22651. */
  22652. static readonly LineStripDrawMode: number;
  22653. /**
  22654. * Returns the triangle strip draw mode
  22655. */
  22656. static readonly TriangleStripDrawMode: number;
  22657. /**
  22658. * Returns the triangle fan draw mode
  22659. */
  22660. static readonly TriangleFanDrawMode: number;
  22661. /**
  22662. * Stores the clock-wise side orientation
  22663. */
  22664. static readonly ClockWiseSideOrientation: number;
  22665. /**
  22666. * Stores the counter clock-wise side orientation
  22667. */
  22668. static readonly CounterClockWiseSideOrientation: number;
  22669. /**
  22670. * The dirty texture flag value
  22671. */
  22672. static readonly TextureDirtyFlag: number;
  22673. /**
  22674. * The dirty light flag value
  22675. */
  22676. static readonly LightDirtyFlag: number;
  22677. /**
  22678. * The dirty fresnel flag value
  22679. */
  22680. static readonly FresnelDirtyFlag: number;
  22681. /**
  22682. * The dirty attribute flag value
  22683. */
  22684. static readonly AttributesDirtyFlag: number;
  22685. /**
  22686. * The dirty misc flag value
  22687. */
  22688. static readonly MiscDirtyFlag: number;
  22689. /**
  22690. * The all dirty flag value
  22691. */
  22692. static readonly AllDirtyFlag: number;
  22693. /**
  22694. * The ID of the material
  22695. */
  22696. id: string;
  22697. /**
  22698. * Gets or sets the unique id of the material
  22699. */
  22700. uniqueId: number;
  22701. /**
  22702. * The name of the material
  22703. */
  22704. name: string;
  22705. /**
  22706. * Gets or sets user defined metadata
  22707. */
  22708. metadata: any;
  22709. /**
  22710. * For internal use only. Please do not use.
  22711. */
  22712. reservedDataStore: any;
  22713. /**
  22714. * Specifies if the ready state should be checked on each call
  22715. */
  22716. checkReadyOnEveryCall: boolean;
  22717. /**
  22718. * Specifies if the ready state should be checked once
  22719. */
  22720. checkReadyOnlyOnce: boolean;
  22721. /**
  22722. * The state of the material
  22723. */
  22724. state: string;
  22725. /**
  22726. * The alpha value of the material
  22727. */
  22728. protected _alpha: number;
  22729. /**
  22730. * List of inspectable custom properties (used by the Inspector)
  22731. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22732. */
  22733. inspectableCustomProperties: IInspectable[];
  22734. /**
  22735. * Sets the alpha value of the material
  22736. */
  22737. /**
  22738. * Gets the alpha value of the material
  22739. */
  22740. alpha: number;
  22741. /**
  22742. * Specifies if back face culling is enabled
  22743. */
  22744. protected _backFaceCulling: boolean;
  22745. /**
  22746. * Sets the back-face culling state
  22747. */
  22748. /**
  22749. * Gets the back-face culling state
  22750. */
  22751. backFaceCulling: boolean;
  22752. /**
  22753. * Stores the value for side orientation
  22754. */
  22755. sideOrientation: number;
  22756. /**
  22757. * Callback triggered when the material is compiled
  22758. */
  22759. onCompiled: Nullable<(effect: Effect) => void>;
  22760. /**
  22761. * Callback triggered when an error occurs
  22762. */
  22763. onError: Nullable<(effect: Effect, errors: string) => void>;
  22764. /**
  22765. * Callback triggered to get the render target textures
  22766. */
  22767. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22768. /**
  22769. * Gets a boolean indicating that current material needs to register RTT
  22770. */
  22771. readonly hasRenderTargetTextures: boolean;
  22772. /**
  22773. * Specifies if the material should be serialized
  22774. */
  22775. doNotSerialize: boolean;
  22776. /**
  22777. * @hidden
  22778. */
  22779. _storeEffectOnSubMeshes: boolean;
  22780. /**
  22781. * Stores the animations for the material
  22782. */
  22783. animations: Nullable<Array<Animation>>;
  22784. /**
  22785. * An event triggered when the material is disposed
  22786. */
  22787. onDisposeObservable: Observable<Material>;
  22788. /**
  22789. * An observer which watches for dispose events
  22790. */
  22791. private _onDisposeObserver;
  22792. private _onUnBindObservable;
  22793. /**
  22794. * Called during a dispose event
  22795. */
  22796. onDispose: () => void;
  22797. private _onBindObservable;
  22798. /**
  22799. * An event triggered when the material is bound
  22800. */
  22801. readonly onBindObservable: Observable<AbstractMesh>;
  22802. /**
  22803. * An observer which watches for bind events
  22804. */
  22805. private _onBindObserver;
  22806. /**
  22807. * Called during a bind event
  22808. */
  22809. onBind: (Mesh: AbstractMesh) => void;
  22810. /**
  22811. * An event triggered when the material is unbound
  22812. */
  22813. readonly onUnBindObservable: Observable<Material>;
  22814. /**
  22815. * Stores the value of the alpha mode
  22816. */
  22817. private _alphaMode;
  22818. /**
  22819. * Sets the value of the alpha mode.
  22820. *
  22821. * | Value | Type | Description |
  22822. * | --- | --- | --- |
  22823. * | 0 | ALPHA_DISABLE | |
  22824. * | 1 | ALPHA_ADD | |
  22825. * | 2 | ALPHA_COMBINE | |
  22826. * | 3 | ALPHA_SUBTRACT | |
  22827. * | 4 | ALPHA_MULTIPLY | |
  22828. * | 5 | ALPHA_MAXIMIZED | |
  22829. * | 6 | ALPHA_ONEONE | |
  22830. * | 7 | ALPHA_PREMULTIPLIED | |
  22831. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22832. * | 9 | ALPHA_INTERPOLATE | |
  22833. * | 10 | ALPHA_SCREENMODE | |
  22834. *
  22835. */
  22836. /**
  22837. * Gets the value of the alpha mode
  22838. */
  22839. alphaMode: number;
  22840. /**
  22841. * Stores the state of the need depth pre-pass value
  22842. */
  22843. private _needDepthPrePass;
  22844. /**
  22845. * Sets the need depth pre-pass value
  22846. */
  22847. /**
  22848. * Gets the depth pre-pass value
  22849. */
  22850. needDepthPrePass: boolean;
  22851. /**
  22852. * Specifies if depth writing should be disabled
  22853. */
  22854. disableDepthWrite: boolean;
  22855. /**
  22856. * Specifies if depth writing should be forced
  22857. */
  22858. forceDepthWrite: boolean;
  22859. /**
  22860. * Specifies if there should be a separate pass for culling
  22861. */
  22862. separateCullingPass: boolean;
  22863. /**
  22864. * Stores the state specifing if fog should be enabled
  22865. */
  22866. private _fogEnabled;
  22867. /**
  22868. * Sets the state for enabling fog
  22869. */
  22870. /**
  22871. * Gets the value of the fog enabled state
  22872. */
  22873. fogEnabled: boolean;
  22874. /**
  22875. * Stores the size of points
  22876. */
  22877. pointSize: number;
  22878. /**
  22879. * Stores the z offset value
  22880. */
  22881. zOffset: number;
  22882. /**
  22883. * Gets a value specifying if wireframe mode is enabled
  22884. */
  22885. /**
  22886. * Sets the state of wireframe mode
  22887. */
  22888. wireframe: boolean;
  22889. /**
  22890. * Gets the value specifying if point clouds are enabled
  22891. */
  22892. /**
  22893. * Sets the state of point cloud mode
  22894. */
  22895. pointsCloud: boolean;
  22896. /**
  22897. * Gets the material fill mode
  22898. */
  22899. /**
  22900. * Sets the material fill mode
  22901. */
  22902. fillMode: number;
  22903. /**
  22904. * @hidden
  22905. * Stores the effects for the material
  22906. */
  22907. _effect: Nullable<Effect>;
  22908. /**
  22909. * @hidden
  22910. * Specifies if the material was previously ready
  22911. */
  22912. _wasPreviouslyReady: boolean;
  22913. /**
  22914. * Specifies if uniform buffers should be used
  22915. */
  22916. private _useUBO;
  22917. /**
  22918. * Stores a reference to the scene
  22919. */
  22920. private _scene;
  22921. /**
  22922. * Stores the fill mode state
  22923. */
  22924. private _fillMode;
  22925. /**
  22926. * Specifies if the depth write state should be cached
  22927. */
  22928. private _cachedDepthWriteState;
  22929. /**
  22930. * Stores the uniform buffer
  22931. */
  22932. protected _uniformBuffer: UniformBuffer;
  22933. /** @hidden */
  22934. _indexInSceneMaterialArray: number;
  22935. /** @hidden */
  22936. meshMap: Nullable<{
  22937. [id: string]: AbstractMesh | undefined;
  22938. }>;
  22939. /**
  22940. * Creates a material instance
  22941. * @param name defines the name of the material
  22942. * @param scene defines the scene to reference
  22943. * @param doNotAdd specifies if the material should be added to the scene
  22944. */
  22945. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22946. /**
  22947. * Returns a string representation of the current material
  22948. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22949. * @returns a string with material information
  22950. */
  22951. toString(fullDetails?: boolean): string;
  22952. /**
  22953. * Gets the class name of the material
  22954. * @returns a string with the class name of the material
  22955. */
  22956. getClassName(): string;
  22957. /**
  22958. * Specifies if updates for the material been locked
  22959. */
  22960. readonly isFrozen: boolean;
  22961. /**
  22962. * Locks updates for the material
  22963. */
  22964. freeze(): void;
  22965. /**
  22966. * Unlocks updates for the material
  22967. */
  22968. unfreeze(): void;
  22969. /**
  22970. * Specifies if the material is ready to be used
  22971. * @param mesh defines the mesh to check
  22972. * @param useInstances specifies if instances should be used
  22973. * @returns a boolean indicating if the material is ready to be used
  22974. */
  22975. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22976. /**
  22977. * Specifies that the submesh is ready to be used
  22978. * @param mesh defines the mesh to check
  22979. * @param subMesh defines which submesh to check
  22980. * @param useInstances specifies that instances should be used
  22981. * @returns a boolean indicating that the submesh is ready or not
  22982. */
  22983. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22984. /**
  22985. * Returns the material effect
  22986. * @returns the effect associated with the material
  22987. */
  22988. getEffect(): Nullable<Effect>;
  22989. /**
  22990. * Returns the current scene
  22991. * @returns a Scene
  22992. */
  22993. getScene(): Scene;
  22994. /**
  22995. * Specifies if the material will require alpha blending
  22996. * @returns a boolean specifying if alpha blending is needed
  22997. */
  22998. needAlphaBlending(): boolean;
  22999. /**
  23000. * Specifies if the mesh will require alpha blending
  23001. * @param mesh defines the mesh to check
  23002. * @returns a boolean specifying if alpha blending is needed for the mesh
  23003. */
  23004. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23005. /**
  23006. * Specifies if this material should be rendered in alpha test mode
  23007. * @returns a boolean specifying if an alpha test is needed.
  23008. */
  23009. needAlphaTesting(): boolean;
  23010. /**
  23011. * Gets the texture used for the alpha test
  23012. * @returns the texture to use for alpha testing
  23013. */
  23014. getAlphaTestTexture(): Nullable<BaseTexture>;
  23015. /**
  23016. * Marks the material to indicate that it needs to be re-calculated
  23017. */
  23018. markDirty(): void;
  23019. /** @hidden */
  23020. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23021. /**
  23022. * Binds the material to the mesh
  23023. * @param world defines the world transformation matrix
  23024. * @param mesh defines the mesh to bind the material to
  23025. */
  23026. bind(world: Matrix, mesh?: Mesh): void;
  23027. /**
  23028. * Binds the submesh to the material
  23029. * @param world defines the world transformation matrix
  23030. * @param mesh defines the mesh containing the submesh
  23031. * @param subMesh defines the submesh to bind the material to
  23032. */
  23033. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23034. /**
  23035. * Binds the world matrix to the material
  23036. * @param world defines the world transformation matrix
  23037. */
  23038. bindOnlyWorldMatrix(world: Matrix): void;
  23039. /**
  23040. * Binds the scene's uniform buffer to the effect.
  23041. * @param effect defines the effect to bind to the scene uniform buffer
  23042. * @param sceneUbo defines the uniform buffer storing scene data
  23043. */
  23044. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23045. /**
  23046. * Binds the view matrix to the effect
  23047. * @param effect defines the effect to bind the view matrix to
  23048. */
  23049. bindView(effect: Effect): void;
  23050. /**
  23051. * Binds the view projection matrix to the effect
  23052. * @param effect defines the effect to bind the view projection matrix to
  23053. */
  23054. bindViewProjection(effect: Effect): void;
  23055. /**
  23056. * Specifies if material alpha testing should be turned on for the mesh
  23057. * @param mesh defines the mesh to check
  23058. */
  23059. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23060. /**
  23061. * Processes to execute after binding the material to a mesh
  23062. * @param mesh defines the rendered mesh
  23063. */
  23064. protected _afterBind(mesh?: Mesh): void;
  23065. /**
  23066. * Unbinds the material from the mesh
  23067. */
  23068. unbind(): void;
  23069. /**
  23070. * Gets the active textures from the material
  23071. * @returns an array of textures
  23072. */
  23073. getActiveTextures(): BaseTexture[];
  23074. /**
  23075. * Specifies if the material uses a texture
  23076. * @param texture defines the texture to check against the material
  23077. * @returns a boolean specifying if the material uses the texture
  23078. */
  23079. hasTexture(texture: BaseTexture): boolean;
  23080. /**
  23081. * Makes a duplicate of the material, and gives it a new name
  23082. * @param name defines the new name for the duplicated material
  23083. * @returns the cloned material
  23084. */
  23085. clone(name: string): Nullable<Material>;
  23086. /**
  23087. * Gets the meshes bound to the material
  23088. * @returns an array of meshes bound to the material
  23089. */
  23090. getBindedMeshes(): AbstractMesh[];
  23091. /**
  23092. * Force shader compilation
  23093. * @param mesh defines the mesh associated with this material
  23094. * @param onCompiled defines a function to execute once the material is compiled
  23095. * @param options defines the options to configure the compilation
  23096. */
  23097. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23098. clipPlane: boolean;
  23099. }>): void;
  23100. /**
  23101. * Force shader compilation
  23102. * @param mesh defines the mesh that will use this material
  23103. * @param options defines additional options for compiling the shaders
  23104. * @returns a promise that resolves when the compilation completes
  23105. */
  23106. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23107. clipPlane: boolean;
  23108. }>): Promise<void>;
  23109. private static readonly _AllDirtyCallBack;
  23110. private static readonly _ImageProcessingDirtyCallBack;
  23111. private static readonly _TextureDirtyCallBack;
  23112. private static readonly _FresnelDirtyCallBack;
  23113. private static readonly _MiscDirtyCallBack;
  23114. private static readonly _LightsDirtyCallBack;
  23115. private static readonly _AttributeDirtyCallBack;
  23116. private static _FresnelAndMiscDirtyCallBack;
  23117. private static _TextureAndMiscDirtyCallBack;
  23118. private static readonly _DirtyCallbackArray;
  23119. private static readonly _RunDirtyCallBacks;
  23120. /**
  23121. * Marks a define in the material to indicate that it needs to be re-computed
  23122. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23123. */
  23124. markAsDirty(flag: number): void;
  23125. /**
  23126. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23127. * @param func defines a function which checks material defines against the submeshes
  23128. */
  23129. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23130. /**
  23131. * Indicates that we need to re-calculated for all submeshes
  23132. */
  23133. protected _markAllSubMeshesAsAllDirty(): void;
  23134. /**
  23135. * Indicates that image processing needs to be re-calculated for all submeshes
  23136. */
  23137. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23138. /**
  23139. * Indicates that textures need to be re-calculated for all submeshes
  23140. */
  23141. protected _markAllSubMeshesAsTexturesDirty(): void;
  23142. /**
  23143. * Indicates that fresnel needs to be re-calculated for all submeshes
  23144. */
  23145. protected _markAllSubMeshesAsFresnelDirty(): void;
  23146. /**
  23147. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23148. */
  23149. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23150. /**
  23151. * Indicates that lights need to be re-calculated for all submeshes
  23152. */
  23153. protected _markAllSubMeshesAsLightsDirty(): void;
  23154. /**
  23155. * Indicates that attributes need to be re-calculated for all submeshes
  23156. */
  23157. protected _markAllSubMeshesAsAttributesDirty(): void;
  23158. /**
  23159. * Indicates that misc needs to be re-calculated for all submeshes
  23160. */
  23161. protected _markAllSubMeshesAsMiscDirty(): void;
  23162. /**
  23163. * Indicates that textures and misc need to be re-calculated for all submeshes
  23164. */
  23165. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23166. /**
  23167. * Disposes the material
  23168. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23169. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23170. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23171. */
  23172. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23173. /** @hidden */
  23174. private releaseVertexArrayObject;
  23175. /**
  23176. * Serializes this material
  23177. * @returns the serialized material object
  23178. */
  23179. serialize(): any;
  23180. /**
  23181. * Creates a material from parsed material data
  23182. * @param parsedMaterial defines parsed material data
  23183. * @param scene defines the hosting scene
  23184. * @param rootUrl defines the root URL to use to load textures
  23185. * @returns a new material
  23186. */
  23187. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23188. }
  23189. }
  23190. declare module "babylonjs/Meshes/subMesh" {
  23191. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23192. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23193. import { Engine } from "babylonjs/Engines/engine";
  23194. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23195. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23196. import { Effect } from "babylonjs/Materials/effect";
  23197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23198. import { Collider } from "babylonjs/Collisions/collider";
  23199. import { Material } from "babylonjs/Materials/material";
  23200. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23202. import { Mesh } from "babylonjs/Meshes/mesh";
  23203. import { Ray } from "babylonjs/Culling/ray";
  23204. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23205. /**
  23206. * Base class for submeshes
  23207. */
  23208. export class BaseSubMesh {
  23209. /** @hidden */
  23210. _materialDefines: Nullable<MaterialDefines>;
  23211. /** @hidden */
  23212. _materialEffect: Nullable<Effect>;
  23213. /**
  23214. * Gets associated effect
  23215. */
  23216. readonly effect: Nullable<Effect>;
  23217. /**
  23218. * Sets associated effect (effect used to render this submesh)
  23219. * @param effect defines the effect to associate with
  23220. * @param defines defines the set of defines used to compile this effect
  23221. */
  23222. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23223. }
  23224. /**
  23225. * Defines a subdivision inside a mesh
  23226. */
  23227. export class SubMesh extends BaseSubMesh implements ICullable {
  23228. /** the material index to use */
  23229. materialIndex: number;
  23230. /** vertex index start */
  23231. verticesStart: number;
  23232. /** vertices count */
  23233. verticesCount: number;
  23234. /** index start */
  23235. indexStart: number;
  23236. /** indices count */
  23237. indexCount: number;
  23238. /** @hidden */
  23239. _linesIndexCount: number;
  23240. private _mesh;
  23241. private _renderingMesh;
  23242. private _boundingInfo;
  23243. private _linesIndexBuffer;
  23244. /** @hidden */
  23245. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23246. /** @hidden */
  23247. _trianglePlanes: Plane[];
  23248. /** @hidden */
  23249. _lastColliderTransformMatrix: Nullable<Matrix>;
  23250. /** @hidden */
  23251. _renderId: number;
  23252. /** @hidden */
  23253. _alphaIndex: number;
  23254. /** @hidden */
  23255. _distanceToCamera: number;
  23256. /** @hidden */
  23257. _id: number;
  23258. private _currentMaterial;
  23259. /**
  23260. * Add a new submesh to a mesh
  23261. * @param materialIndex defines the material index to use
  23262. * @param verticesStart defines vertex index start
  23263. * @param verticesCount defines vertices count
  23264. * @param indexStart defines index start
  23265. * @param indexCount defines indices count
  23266. * @param mesh defines the parent mesh
  23267. * @param renderingMesh defines an optional rendering mesh
  23268. * @param createBoundingBox defines if bounding box should be created for this submesh
  23269. * @returns the new submesh
  23270. */
  23271. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23272. /**
  23273. * Creates a new submesh
  23274. * @param materialIndex defines the material index to use
  23275. * @param verticesStart defines vertex index start
  23276. * @param verticesCount defines vertices count
  23277. * @param indexStart defines index start
  23278. * @param indexCount defines indices count
  23279. * @param mesh defines the parent mesh
  23280. * @param renderingMesh defines an optional rendering mesh
  23281. * @param createBoundingBox defines if bounding box should be created for this submesh
  23282. */
  23283. constructor(
  23284. /** the material index to use */
  23285. materialIndex: number,
  23286. /** vertex index start */
  23287. verticesStart: number,
  23288. /** vertices count */
  23289. verticesCount: number,
  23290. /** index start */
  23291. indexStart: number,
  23292. /** indices count */
  23293. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23294. /**
  23295. * Returns true if this submesh covers the entire parent mesh
  23296. * @ignorenaming
  23297. */
  23298. readonly IsGlobal: boolean;
  23299. /**
  23300. * Returns the submesh BoudingInfo object
  23301. * @returns current bounding info (or mesh's one if the submesh is global)
  23302. */
  23303. getBoundingInfo(): BoundingInfo;
  23304. /**
  23305. * Sets the submesh BoundingInfo
  23306. * @param boundingInfo defines the new bounding info to use
  23307. * @returns the SubMesh
  23308. */
  23309. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23310. /**
  23311. * Returns the mesh of the current submesh
  23312. * @return the parent mesh
  23313. */
  23314. getMesh(): AbstractMesh;
  23315. /**
  23316. * Returns the rendering mesh of the submesh
  23317. * @returns the rendering mesh (could be different from parent mesh)
  23318. */
  23319. getRenderingMesh(): Mesh;
  23320. /**
  23321. * Returns the submesh material
  23322. * @returns null or the current material
  23323. */
  23324. getMaterial(): Nullable<Material>;
  23325. /**
  23326. * Sets a new updated BoundingInfo object to the submesh
  23327. * @param data defines an optional position array to use to determine the bounding info
  23328. * @returns the SubMesh
  23329. */
  23330. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23331. /** @hidden */
  23332. _checkCollision(collider: Collider): boolean;
  23333. /**
  23334. * Updates the submesh BoundingInfo
  23335. * @param world defines the world matrix to use to update the bounding info
  23336. * @returns the submesh
  23337. */
  23338. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23339. /**
  23340. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23341. * @param frustumPlanes defines the frustum planes
  23342. * @returns true if the submesh is intersecting with the frustum
  23343. */
  23344. isInFrustum(frustumPlanes: Plane[]): boolean;
  23345. /**
  23346. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23347. * @param frustumPlanes defines the frustum planes
  23348. * @returns true if the submesh is inside the frustum
  23349. */
  23350. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23351. /**
  23352. * Renders the submesh
  23353. * @param enableAlphaMode defines if alpha needs to be used
  23354. * @returns the submesh
  23355. */
  23356. render(enableAlphaMode: boolean): SubMesh;
  23357. /**
  23358. * @hidden
  23359. */
  23360. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23361. /**
  23362. * Checks if the submesh intersects with a ray
  23363. * @param ray defines the ray to test
  23364. * @returns true is the passed ray intersects the submesh bounding box
  23365. */
  23366. canIntersects(ray: Ray): boolean;
  23367. /**
  23368. * Intersects current submesh with a ray
  23369. * @param ray defines the ray to test
  23370. * @param positions defines mesh's positions array
  23371. * @param indices defines mesh's indices array
  23372. * @param fastCheck defines if only bounding info should be used
  23373. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23374. * @returns intersection info or null if no intersection
  23375. */
  23376. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23377. /** @hidden */
  23378. private _intersectLines;
  23379. /** @hidden */
  23380. private _intersectUnIndexedLines;
  23381. /** @hidden */
  23382. private _intersectTriangles;
  23383. /** @hidden */
  23384. private _intersectUnIndexedTriangles;
  23385. /** @hidden */
  23386. _rebuild(): void;
  23387. /**
  23388. * Creates a new submesh from the passed mesh
  23389. * @param newMesh defines the new hosting mesh
  23390. * @param newRenderingMesh defines an optional rendering mesh
  23391. * @returns the new submesh
  23392. */
  23393. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23394. /**
  23395. * Release associated resources
  23396. */
  23397. dispose(): void;
  23398. /**
  23399. * Gets the class name
  23400. * @returns the string "SubMesh".
  23401. */
  23402. getClassName(): string;
  23403. /**
  23404. * Creates a new submesh from indices data
  23405. * @param materialIndex the index of the main mesh material
  23406. * @param startIndex the index where to start the copy in the mesh indices array
  23407. * @param indexCount the number of indices to copy then from the startIndex
  23408. * @param mesh the main mesh to create the submesh from
  23409. * @param renderingMesh the optional rendering mesh
  23410. * @returns a new submesh
  23411. */
  23412. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23413. }
  23414. }
  23415. declare module "babylonjs/Meshes/geometry" {
  23416. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23417. import { Scene } from "babylonjs/scene";
  23418. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23419. import { Engine } from "babylonjs/Engines/engine";
  23420. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23421. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23422. import { Effect } from "babylonjs/Materials/effect";
  23423. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23424. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23425. import { Mesh } from "babylonjs/Meshes/mesh";
  23426. /**
  23427. * Class used to store geometry data (vertex buffers + index buffer)
  23428. */
  23429. export class Geometry implements IGetSetVerticesData {
  23430. /**
  23431. * Gets or sets the ID of the geometry
  23432. */
  23433. id: string;
  23434. /**
  23435. * Gets or sets the unique ID of the geometry
  23436. */
  23437. uniqueId: number;
  23438. /**
  23439. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23440. */
  23441. delayLoadState: number;
  23442. /**
  23443. * Gets the file containing the data to load when running in delay load state
  23444. */
  23445. delayLoadingFile: Nullable<string>;
  23446. /**
  23447. * Callback called when the geometry is updated
  23448. */
  23449. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23450. private _scene;
  23451. private _engine;
  23452. private _meshes;
  23453. private _totalVertices;
  23454. /** @hidden */
  23455. _indices: IndicesArray;
  23456. /** @hidden */
  23457. _vertexBuffers: {
  23458. [key: string]: VertexBuffer;
  23459. };
  23460. private _isDisposed;
  23461. private _extend;
  23462. private _boundingBias;
  23463. /** @hidden */
  23464. _delayInfo: Array<string>;
  23465. private _indexBuffer;
  23466. private _indexBufferIsUpdatable;
  23467. /** @hidden */
  23468. _boundingInfo: Nullable<BoundingInfo>;
  23469. /** @hidden */
  23470. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23471. /** @hidden */
  23472. _softwareSkinningFrameId: number;
  23473. private _vertexArrayObjects;
  23474. private _updatable;
  23475. /** @hidden */
  23476. _positions: Nullable<Vector3[]>;
  23477. /**
  23478. * 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
  23479. */
  23480. /**
  23481. * 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
  23482. */
  23483. boundingBias: Vector2;
  23484. /**
  23485. * Static function used to attach a new empty geometry to a mesh
  23486. * @param mesh defines the mesh to attach the geometry to
  23487. * @returns the new Geometry
  23488. */
  23489. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23490. /**
  23491. * Creates a new geometry
  23492. * @param id defines the unique ID
  23493. * @param scene defines the hosting scene
  23494. * @param vertexData defines the VertexData used to get geometry data
  23495. * @param updatable defines if geometry must be updatable (false by default)
  23496. * @param mesh defines the mesh that will be associated with the geometry
  23497. */
  23498. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23499. /**
  23500. * Gets the current extend of the geometry
  23501. */
  23502. readonly extend: {
  23503. minimum: Vector3;
  23504. maximum: Vector3;
  23505. };
  23506. /**
  23507. * Gets the hosting scene
  23508. * @returns the hosting Scene
  23509. */
  23510. getScene(): Scene;
  23511. /**
  23512. * Gets the hosting engine
  23513. * @returns the hosting Engine
  23514. */
  23515. getEngine(): Engine;
  23516. /**
  23517. * Defines if the geometry is ready to use
  23518. * @returns true if the geometry is ready to be used
  23519. */
  23520. isReady(): boolean;
  23521. /**
  23522. * Gets a value indicating that the geometry should not be serialized
  23523. */
  23524. readonly doNotSerialize: boolean;
  23525. /** @hidden */
  23526. _rebuild(): void;
  23527. /**
  23528. * Affects all geometry data in one call
  23529. * @param vertexData defines the geometry data
  23530. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23531. */
  23532. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23533. /**
  23534. * Set specific vertex data
  23535. * @param kind defines the data kind (Position, normal, etc...)
  23536. * @param data defines the vertex data to use
  23537. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23538. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23539. */
  23540. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23541. /**
  23542. * Removes a specific vertex data
  23543. * @param kind defines the data kind (Position, normal, etc...)
  23544. */
  23545. removeVerticesData(kind: string): void;
  23546. /**
  23547. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23548. * @param buffer defines the vertex buffer to use
  23549. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23550. */
  23551. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23552. /**
  23553. * Update a specific vertex buffer
  23554. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23555. * It will do nothing if the buffer is not updatable
  23556. * @param kind defines the data kind (Position, normal, etc...)
  23557. * @param data defines the data to use
  23558. * @param offset defines the offset in the target buffer where to store the data
  23559. * @param useBytes set to true if the offset is in bytes
  23560. */
  23561. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23562. /**
  23563. * Update a specific vertex buffer
  23564. * This function will create a new buffer if the current one is not updatable
  23565. * @param kind defines the data kind (Position, normal, etc...)
  23566. * @param data defines the data to use
  23567. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23568. */
  23569. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23570. private _updateBoundingInfo;
  23571. /** @hidden */
  23572. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23573. /**
  23574. * Gets total number of vertices
  23575. * @returns the total number of vertices
  23576. */
  23577. getTotalVertices(): number;
  23578. /**
  23579. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23580. * @param kind defines the data kind (Position, normal, etc...)
  23581. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23582. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23583. * @returns a float array containing vertex data
  23584. */
  23585. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23586. /**
  23587. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23588. * @param kind defines the data kind (Position, normal, etc...)
  23589. * @returns true if the vertex buffer with the specified kind is updatable
  23590. */
  23591. isVertexBufferUpdatable(kind: string): boolean;
  23592. /**
  23593. * Gets a specific vertex buffer
  23594. * @param kind defines the data kind (Position, normal, etc...)
  23595. * @returns a VertexBuffer
  23596. */
  23597. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23598. /**
  23599. * Returns all vertex buffers
  23600. * @return an object holding all vertex buffers indexed by kind
  23601. */
  23602. getVertexBuffers(): Nullable<{
  23603. [key: string]: VertexBuffer;
  23604. }>;
  23605. /**
  23606. * Gets a boolean indicating if specific vertex buffer is present
  23607. * @param kind defines the data kind (Position, normal, etc...)
  23608. * @returns true if data is present
  23609. */
  23610. isVerticesDataPresent(kind: string): boolean;
  23611. /**
  23612. * Gets a list of all attached data kinds (Position, normal, etc...)
  23613. * @returns a list of string containing all kinds
  23614. */
  23615. getVerticesDataKinds(): string[];
  23616. /**
  23617. * Update index buffer
  23618. * @param indices defines the indices to store in the index buffer
  23619. * @param offset defines the offset in the target buffer where to store the data
  23620. * @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)
  23621. */
  23622. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23623. /**
  23624. * Creates a new index buffer
  23625. * @param indices defines the indices to store in the index buffer
  23626. * @param totalVertices defines the total number of vertices (could be null)
  23627. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23628. */
  23629. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23630. /**
  23631. * Return the total number of indices
  23632. * @returns the total number of indices
  23633. */
  23634. getTotalIndices(): number;
  23635. /**
  23636. * Gets the index buffer array
  23637. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23638. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23639. * @returns the index buffer array
  23640. */
  23641. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23642. /**
  23643. * Gets the index buffer
  23644. * @return the index buffer
  23645. */
  23646. getIndexBuffer(): Nullable<DataBuffer>;
  23647. /** @hidden */
  23648. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23649. /**
  23650. * Release the associated resources for a specific mesh
  23651. * @param mesh defines the source mesh
  23652. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23653. */
  23654. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23655. /**
  23656. * Apply current geometry to a given mesh
  23657. * @param mesh defines the mesh to apply geometry to
  23658. */
  23659. applyToMesh(mesh: Mesh): void;
  23660. private _updateExtend;
  23661. private _applyToMesh;
  23662. private notifyUpdate;
  23663. /**
  23664. * Load the geometry if it was flagged as delay loaded
  23665. * @param scene defines the hosting scene
  23666. * @param onLoaded defines a callback called when the geometry is loaded
  23667. */
  23668. load(scene: Scene, onLoaded?: () => void): void;
  23669. private _queueLoad;
  23670. /**
  23671. * Invert the geometry to move from a right handed system to a left handed one.
  23672. */
  23673. toLeftHanded(): void;
  23674. /** @hidden */
  23675. _resetPointsArrayCache(): void;
  23676. /** @hidden */
  23677. _generatePointsArray(): boolean;
  23678. /**
  23679. * Gets a value indicating if the geometry is disposed
  23680. * @returns true if the geometry was disposed
  23681. */
  23682. isDisposed(): boolean;
  23683. private _disposeVertexArrayObjects;
  23684. /**
  23685. * Free all associated resources
  23686. */
  23687. dispose(): void;
  23688. /**
  23689. * Clone the current geometry into a new geometry
  23690. * @param id defines the unique ID of the new geometry
  23691. * @returns a new geometry object
  23692. */
  23693. copy(id: string): Geometry;
  23694. /**
  23695. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23696. * @return a JSON representation of the current geometry data (without the vertices data)
  23697. */
  23698. serialize(): any;
  23699. private toNumberArray;
  23700. /**
  23701. * Serialize all vertices data into a JSON oject
  23702. * @returns a JSON representation of the current geometry data
  23703. */
  23704. serializeVerticeData(): any;
  23705. /**
  23706. * Extracts a clone of a mesh geometry
  23707. * @param mesh defines the source mesh
  23708. * @param id defines the unique ID of the new geometry object
  23709. * @returns the new geometry object
  23710. */
  23711. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23712. /**
  23713. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23714. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23715. * Be aware Math.random() could cause collisions, but:
  23716. * "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"
  23717. * @returns a string containing a new GUID
  23718. */
  23719. static RandomId(): string;
  23720. /** @hidden */
  23721. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23722. private static _CleanMatricesWeights;
  23723. /**
  23724. * Create a new geometry from persisted data (Using .babylon file format)
  23725. * @param parsedVertexData defines the persisted data
  23726. * @param scene defines the hosting scene
  23727. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23728. * @returns the new geometry object
  23729. */
  23730. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23731. }
  23732. }
  23733. declare module "babylonjs/Meshes/mesh.vertexData" {
  23734. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23735. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23736. import { Geometry } from "babylonjs/Meshes/geometry";
  23737. import { Mesh } from "babylonjs/Meshes/mesh";
  23738. /**
  23739. * Define an interface for all classes that will get and set the data on vertices
  23740. */
  23741. export interface IGetSetVerticesData {
  23742. /**
  23743. * Gets a boolean indicating if specific vertex data is present
  23744. * @param kind defines the vertex data kind to use
  23745. * @returns true is data kind is present
  23746. */
  23747. isVerticesDataPresent(kind: string): boolean;
  23748. /**
  23749. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23750. * @param kind defines the data kind (Position, normal, etc...)
  23751. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23752. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23753. * @returns a float array containing vertex data
  23754. */
  23755. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23756. /**
  23757. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23758. * @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.
  23759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23760. * @returns the indices array or an empty array if the mesh has no geometry
  23761. */
  23762. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23763. /**
  23764. * Set specific vertex data
  23765. * @param kind defines the data kind (Position, normal, etc...)
  23766. * @param data defines the vertex data to use
  23767. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23768. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23769. */
  23770. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23771. /**
  23772. * Update a specific associated vertex buffer
  23773. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23774. * - VertexBuffer.PositionKind
  23775. * - VertexBuffer.UVKind
  23776. * - VertexBuffer.UV2Kind
  23777. * - VertexBuffer.UV3Kind
  23778. * - VertexBuffer.UV4Kind
  23779. * - VertexBuffer.UV5Kind
  23780. * - VertexBuffer.UV6Kind
  23781. * - VertexBuffer.ColorKind
  23782. * - VertexBuffer.MatricesIndicesKind
  23783. * - VertexBuffer.MatricesIndicesExtraKind
  23784. * - VertexBuffer.MatricesWeightsKind
  23785. * - VertexBuffer.MatricesWeightsExtraKind
  23786. * @param data defines the data source
  23787. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23788. * @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)
  23789. */
  23790. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23791. /**
  23792. * Creates a new index buffer
  23793. * @param indices defines the indices to store in the index buffer
  23794. * @param totalVertices defines the total number of vertices (could be null)
  23795. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23796. */
  23797. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23798. }
  23799. /**
  23800. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23801. */
  23802. export class VertexData {
  23803. /**
  23804. * Mesh side orientation : usually the external or front surface
  23805. */
  23806. static readonly FRONTSIDE: number;
  23807. /**
  23808. * Mesh side orientation : usually the internal or back surface
  23809. */
  23810. static readonly BACKSIDE: number;
  23811. /**
  23812. * Mesh side orientation : both internal and external or front and back surfaces
  23813. */
  23814. static readonly DOUBLESIDE: number;
  23815. /**
  23816. * Mesh side orientation : by default, `FRONTSIDE`
  23817. */
  23818. static readonly DEFAULTSIDE: number;
  23819. /**
  23820. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23821. */
  23822. positions: Nullable<FloatArray>;
  23823. /**
  23824. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23825. */
  23826. normals: Nullable<FloatArray>;
  23827. /**
  23828. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23829. */
  23830. tangents: Nullable<FloatArray>;
  23831. /**
  23832. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23833. */
  23834. uvs: Nullable<FloatArray>;
  23835. /**
  23836. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23837. */
  23838. uvs2: Nullable<FloatArray>;
  23839. /**
  23840. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23841. */
  23842. uvs3: Nullable<FloatArray>;
  23843. /**
  23844. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23845. */
  23846. uvs4: Nullable<FloatArray>;
  23847. /**
  23848. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23849. */
  23850. uvs5: Nullable<FloatArray>;
  23851. /**
  23852. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23853. */
  23854. uvs6: Nullable<FloatArray>;
  23855. /**
  23856. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23857. */
  23858. colors: Nullable<FloatArray>;
  23859. /**
  23860. * 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).
  23861. */
  23862. matricesIndices: Nullable<FloatArray>;
  23863. /**
  23864. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23865. */
  23866. matricesWeights: Nullable<FloatArray>;
  23867. /**
  23868. * An array extending the number of possible indices
  23869. */
  23870. matricesIndicesExtra: Nullable<FloatArray>;
  23871. /**
  23872. * An array extending the number of possible weights when the number of indices is extended
  23873. */
  23874. matricesWeightsExtra: Nullable<FloatArray>;
  23875. /**
  23876. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23877. */
  23878. indices: Nullable<IndicesArray>;
  23879. /**
  23880. * Uses the passed data array to set the set the values for the specified kind of data
  23881. * @param data a linear array of floating numbers
  23882. * @param kind the type of data that is being set, eg positions, colors etc
  23883. */
  23884. set(data: FloatArray, kind: string): void;
  23885. /**
  23886. * Associates the vertexData to the passed Mesh.
  23887. * Sets it as updatable or not (default `false`)
  23888. * @param mesh the mesh the vertexData is applied to
  23889. * @param updatable when used and having the value true allows new data to update the vertexData
  23890. * @returns the VertexData
  23891. */
  23892. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23893. /**
  23894. * Associates the vertexData to the passed Geometry.
  23895. * Sets it as updatable or not (default `false`)
  23896. * @param geometry the geometry the vertexData is applied to
  23897. * @param updatable when used and having the value true allows new data to update the vertexData
  23898. * @returns VertexData
  23899. */
  23900. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23901. /**
  23902. * Updates the associated mesh
  23903. * @param mesh the mesh to be updated
  23904. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23905. * @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
  23906. * @returns VertexData
  23907. */
  23908. updateMesh(mesh: Mesh): VertexData;
  23909. /**
  23910. * Updates the associated geometry
  23911. * @param geometry the geometry to be updated
  23912. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23913. * @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
  23914. * @returns VertexData.
  23915. */
  23916. updateGeometry(geometry: Geometry): VertexData;
  23917. private _applyTo;
  23918. private _update;
  23919. /**
  23920. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23921. * @param matrix the transforming matrix
  23922. * @returns the VertexData
  23923. */
  23924. transform(matrix: Matrix): VertexData;
  23925. /**
  23926. * Merges the passed VertexData into the current one
  23927. * @param other the VertexData to be merged into the current one
  23928. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23929. * @returns the modified VertexData
  23930. */
  23931. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23932. private _mergeElement;
  23933. private _validate;
  23934. /**
  23935. * Serializes the VertexData
  23936. * @returns a serialized object
  23937. */
  23938. serialize(): any;
  23939. /**
  23940. * Extracts the vertexData from a mesh
  23941. * @param mesh the mesh from which to extract the VertexData
  23942. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23943. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23944. * @returns the object VertexData associated to the passed mesh
  23945. */
  23946. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23947. /**
  23948. * Extracts the vertexData from the geometry
  23949. * @param geometry the geometry from which to extract the VertexData
  23950. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23951. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23952. * @returns the object VertexData associated to the passed mesh
  23953. */
  23954. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23955. private static _ExtractFrom;
  23956. /**
  23957. * Creates the VertexData for a Ribbon
  23958. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23959. * * pathArray array of paths, each of which an array of successive Vector3
  23960. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23961. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23962. * * 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
  23963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23964. * * 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)
  23965. * * 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)
  23966. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23967. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23968. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23969. * @returns the VertexData of the ribbon
  23970. */
  23971. static CreateRibbon(options: {
  23972. pathArray: Vector3[][];
  23973. closeArray?: boolean;
  23974. closePath?: boolean;
  23975. offset?: number;
  23976. sideOrientation?: number;
  23977. frontUVs?: Vector4;
  23978. backUVs?: Vector4;
  23979. invertUV?: boolean;
  23980. uvs?: Vector2[];
  23981. colors?: Color4[];
  23982. }): VertexData;
  23983. /**
  23984. * Creates the VertexData for a box
  23985. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23986. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23987. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23988. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23989. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23990. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23991. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23993. * * 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)
  23994. * * 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)
  23995. * @returns the VertexData of the box
  23996. */
  23997. static CreateBox(options: {
  23998. size?: number;
  23999. width?: number;
  24000. height?: number;
  24001. depth?: number;
  24002. faceUV?: Vector4[];
  24003. faceColors?: Color4[];
  24004. sideOrientation?: number;
  24005. frontUVs?: Vector4;
  24006. backUVs?: Vector4;
  24007. }): VertexData;
  24008. /**
  24009. * Creates the VertexData for a tiled box
  24010. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24011. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24012. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24013. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24015. * @returns the VertexData of the box
  24016. */
  24017. static CreateTiledBox(options: {
  24018. pattern?: number;
  24019. width?: number;
  24020. height?: number;
  24021. depth?: number;
  24022. tileSize?: number;
  24023. tileWidth?: number;
  24024. tileHeight?: number;
  24025. alignHorizontal?: number;
  24026. alignVertical?: number;
  24027. faceUV?: Vector4[];
  24028. faceColors?: Color4[];
  24029. sideOrientation?: number;
  24030. }): VertexData;
  24031. /**
  24032. * Creates the VertexData for a tiled plane
  24033. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24034. * * pattern a limited pattern arrangement depending on the number
  24035. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24036. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24037. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24039. * * 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)
  24040. * * 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)
  24041. * @returns the VertexData of the tiled plane
  24042. */
  24043. static CreateTiledPlane(options: {
  24044. pattern?: number;
  24045. tileSize?: number;
  24046. tileWidth?: number;
  24047. tileHeight?: number;
  24048. size?: number;
  24049. width?: number;
  24050. height?: number;
  24051. alignHorizontal?: number;
  24052. alignVertical?: number;
  24053. sideOrientation?: number;
  24054. frontUVs?: Vector4;
  24055. backUVs?: Vector4;
  24056. }): VertexData;
  24057. /**
  24058. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24059. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24060. * * segments sets the number of horizontal strips optional, default 32
  24061. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24062. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24063. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24064. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24065. * * 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
  24066. * * 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
  24067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24068. * * 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)
  24069. * * 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)
  24070. * @returns the VertexData of the ellipsoid
  24071. */
  24072. static CreateSphere(options: {
  24073. segments?: number;
  24074. diameter?: number;
  24075. diameterX?: number;
  24076. diameterY?: number;
  24077. diameterZ?: number;
  24078. arc?: number;
  24079. slice?: number;
  24080. sideOrientation?: number;
  24081. frontUVs?: Vector4;
  24082. backUVs?: Vector4;
  24083. }): VertexData;
  24084. /**
  24085. * Creates the VertexData for a cylinder, cone or prism
  24086. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24087. * * height sets the height (y direction) of the cylinder, optional, default 2
  24088. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24089. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24090. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24091. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24092. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24093. * * 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
  24094. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24095. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24096. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24097. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24098. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24099. * * 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)
  24100. * * 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)
  24101. * @returns the VertexData of the cylinder, cone or prism
  24102. */
  24103. static CreateCylinder(options: {
  24104. height?: number;
  24105. diameterTop?: number;
  24106. diameterBottom?: number;
  24107. diameter?: number;
  24108. tessellation?: number;
  24109. subdivisions?: number;
  24110. arc?: number;
  24111. faceColors?: Color4[];
  24112. faceUV?: Vector4[];
  24113. hasRings?: boolean;
  24114. enclose?: boolean;
  24115. sideOrientation?: number;
  24116. frontUVs?: Vector4;
  24117. backUVs?: Vector4;
  24118. }): VertexData;
  24119. /**
  24120. * Creates the VertexData for a torus
  24121. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24122. * * diameter the diameter of the torus, optional default 1
  24123. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24124. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24126. * * 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)
  24127. * * 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)
  24128. * @returns the VertexData of the torus
  24129. */
  24130. static CreateTorus(options: {
  24131. diameter?: number;
  24132. thickness?: number;
  24133. tessellation?: number;
  24134. sideOrientation?: number;
  24135. frontUVs?: Vector4;
  24136. backUVs?: Vector4;
  24137. }): VertexData;
  24138. /**
  24139. * Creates the VertexData of the LineSystem
  24140. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24141. * - lines an array of lines, each line being an array of successive Vector3
  24142. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24143. * @returns the VertexData of the LineSystem
  24144. */
  24145. static CreateLineSystem(options: {
  24146. lines: Vector3[][];
  24147. colors?: Nullable<Color4[][]>;
  24148. }): VertexData;
  24149. /**
  24150. * Create the VertexData for a DashedLines
  24151. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24152. * - points an array successive Vector3
  24153. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24154. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24155. * - dashNb the intended total number of dashes, optional, default 200
  24156. * @returns the VertexData for the DashedLines
  24157. */
  24158. static CreateDashedLines(options: {
  24159. points: Vector3[];
  24160. dashSize?: number;
  24161. gapSize?: number;
  24162. dashNb?: number;
  24163. }): VertexData;
  24164. /**
  24165. * Creates the VertexData for a Ground
  24166. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24167. * - width the width (x direction) of the ground, optional, default 1
  24168. * - height the height (z direction) of the ground, optional, default 1
  24169. * - subdivisions the number of subdivisions per side, optional, default 1
  24170. * @returns the VertexData of the Ground
  24171. */
  24172. static CreateGround(options: {
  24173. width?: number;
  24174. height?: number;
  24175. subdivisions?: number;
  24176. subdivisionsX?: number;
  24177. subdivisionsY?: number;
  24178. }): VertexData;
  24179. /**
  24180. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24181. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24182. * * xmin the ground minimum X coordinate, optional, default -1
  24183. * * zmin the ground minimum Z coordinate, optional, default -1
  24184. * * xmax the ground maximum X coordinate, optional, default 1
  24185. * * zmax the ground maximum Z coordinate, optional, default 1
  24186. * * 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}
  24187. * * 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}
  24188. * @returns the VertexData of the TiledGround
  24189. */
  24190. static CreateTiledGround(options: {
  24191. xmin: number;
  24192. zmin: number;
  24193. xmax: number;
  24194. zmax: number;
  24195. subdivisions?: {
  24196. w: number;
  24197. h: number;
  24198. };
  24199. precision?: {
  24200. w: number;
  24201. h: number;
  24202. };
  24203. }): VertexData;
  24204. /**
  24205. * Creates the VertexData of the Ground designed from a heightmap
  24206. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24207. * * width the width (x direction) of the ground
  24208. * * height the height (z direction) of the ground
  24209. * * subdivisions the number of subdivisions per side
  24210. * * minHeight the minimum altitude on the ground, optional, default 0
  24211. * * maxHeight the maximum altitude on the ground, optional default 1
  24212. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24213. * * buffer the array holding the image color data
  24214. * * bufferWidth the width of image
  24215. * * bufferHeight the height of image
  24216. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24217. * @returns the VertexData of the Ground designed from a heightmap
  24218. */
  24219. static CreateGroundFromHeightMap(options: {
  24220. width: number;
  24221. height: number;
  24222. subdivisions: number;
  24223. minHeight: number;
  24224. maxHeight: number;
  24225. colorFilter: Color3;
  24226. buffer: Uint8Array;
  24227. bufferWidth: number;
  24228. bufferHeight: number;
  24229. alphaFilter: number;
  24230. }): VertexData;
  24231. /**
  24232. * Creates the VertexData for a Plane
  24233. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24234. * * size sets the width and height of the plane to the value of size, optional default 1
  24235. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24236. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24238. * * 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)
  24239. * * 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)
  24240. * @returns the VertexData of the box
  24241. */
  24242. static CreatePlane(options: {
  24243. size?: number;
  24244. width?: number;
  24245. height?: number;
  24246. sideOrientation?: number;
  24247. frontUVs?: Vector4;
  24248. backUVs?: Vector4;
  24249. }): VertexData;
  24250. /**
  24251. * Creates the VertexData of the Disc or regular Polygon
  24252. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24253. * * radius the radius of the disc, optional default 0.5
  24254. * * tessellation the number of polygon sides, optional, default 64
  24255. * * 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
  24256. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24257. * * 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)
  24258. * * 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)
  24259. * @returns the VertexData of the box
  24260. */
  24261. static CreateDisc(options: {
  24262. radius?: number;
  24263. tessellation?: number;
  24264. arc?: number;
  24265. sideOrientation?: number;
  24266. frontUVs?: Vector4;
  24267. backUVs?: Vector4;
  24268. }): VertexData;
  24269. /**
  24270. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24271. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24272. * @param polygon a mesh built from polygonTriangulation.build()
  24273. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24274. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24275. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24276. * @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)
  24277. * @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)
  24278. * @returns the VertexData of the Polygon
  24279. */
  24280. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24281. /**
  24282. * Creates the VertexData of the IcoSphere
  24283. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24284. * * radius the radius of the IcoSphere, optional default 1
  24285. * * radiusX allows stretching in the x direction, optional, default radius
  24286. * * radiusY allows stretching in the y direction, optional, default radius
  24287. * * radiusZ allows stretching in the z direction, optional, default radius
  24288. * * flat when true creates a flat shaded mesh, optional, default true
  24289. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24290. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24291. * * 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)
  24292. * * 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)
  24293. * @returns the VertexData of the IcoSphere
  24294. */
  24295. static CreateIcoSphere(options: {
  24296. radius?: number;
  24297. radiusX?: number;
  24298. radiusY?: number;
  24299. radiusZ?: number;
  24300. flat?: boolean;
  24301. subdivisions?: number;
  24302. sideOrientation?: number;
  24303. frontUVs?: Vector4;
  24304. backUVs?: Vector4;
  24305. }): VertexData;
  24306. /**
  24307. * Creates the VertexData for a Polyhedron
  24308. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24309. * * type provided types are:
  24310. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24311. * * 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)
  24312. * * size the size of the IcoSphere, optional default 1
  24313. * * sizeX allows stretching in the x direction, optional, default size
  24314. * * sizeY allows stretching in the y direction, optional, default size
  24315. * * sizeZ allows stretching in the z direction, optional, default size
  24316. * * 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
  24317. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24318. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24319. * * flat when true creates a flat shaded mesh, optional, default true
  24320. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24322. * * 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)
  24323. * * 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)
  24324. * @returns the VertexData of the Polyhedron
  24325. */
  24326. static CreatePolyhedron(options: {
  24327. type?: number;
  24328. size?: number;
  24329. sizeX?: number;
  24330. sizeY?: number;
  24331. sizeZ?: number;
  24332. custom?: any;
  24333. faceUV?: Vector4[];
  24334. faceColors?: Color4[];
  24335. flat?: boolean;
  24336. sideOrientation?: number;
  24337. frontUVs?: Vector4;
  24338. backUVs?: Vector4;
  24339. }): VertexData;
  24340. /**
  24341. * Creates the VertexData for a TorusKnot
  24342. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24343. * * radius the radius of the torus knot, optional, default 2
  24344. * * tube the thickness of the tube, optional, default 0.5
  24345. * * radialSegments the number of sides on each tube segments, optional, default 32
  24346. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24347. * * p the number of windings around the z axis, optional, default 2
  24348. * * q the number of windings around the x axis, optional, default 3
  24349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24350. * * 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)
  24351. * * 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)
  24352. * @returns the VertexData of the Torus Knot
  24353. */
  24354. static CreateTorusKnot(options: {
  24355. radius?: number;
  24356. tube?: number;
  24357. radialSegments?: number;
  24358. tubularSegments?: number;
  24359. p?: number;
  24360. q?: number;
  24361. sideOrientation?: number;
  24362. frontUVs?: Vector4;
  24363. backUVs?: Vector4;
  24364. }): VertexData;
  24365. /**
  24366. * Compute normals for given positions and indices
  24367. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24368. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24369. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24370. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24371. * * facetNormals : optional array of facet normals (vector3)
  24372. * * facetPositions : optional array of facet positions (vector3)
  24373. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24374. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24375. * * bInfo : optional bounding info, required for facetPartitioning computation
  24376. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24377. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24378. * * useRightHandedSystem: optional boolean to for right handed system computation
  24379. * * depthSort : optional boolean to enable the facet depth sort computation
  24380. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24381. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24382. */
  24383. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24384. facetNormals?: any;
  24385. facetPositions?: any;
  24386. facetPartitioning?: any;
  24387. ratio?: number;
  24388. bInfo?: any;
  24389. bbSize?: Vector3;
  24390. subDiv?: any;
  24391. useRightHandedSystem?: boolean;
  24392. depthSort?: boolean;
  24393. distanceTo?: Vector3;
  24394. depthSortedFacets?: any;
  24395. }): void;
  24396. /** @hidden */
  24397. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24398. /**
  24399. * Applies VertexData created from the imported parameters to the geometry
  24400. * @param parsedVertexData the parsed data from an imported file
  24401. * @param geometry the geometry to apply the VertexData to
  24402. */
  24403. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24404. }
  24405. }
  24406. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24407. import { Nullable } from "babylonjs/types";
  24408. import { Scene } from "babylonjs/scene";
  24409. import { Vector4 } from "babylonjs/Maths/math";
  24410. import { Mesh } from "babylonjs/Meshes/mesh";
  24411. /**
  24412. * Class containing static functions to help procedurally build meshes
  24413. */
  24414. export class DiscBuilder {
  24415. /**
  24416. * Creates a plane polygonal mesh. By default, this is a disc
  24417. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24418. * * 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
  24419. * * 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
  24420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24423. * @param name defines the name of the mesh
  24424. * @param options defines the options used to create the mesh
  24425. * @param scene defines the hosting scene
  24426. * @returns the plane polygonal mesh
  24427. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24428. */
  24429. static CreateDisc(name: string, options: {
  24430. radius?: number;
  24431. tessellation?: number;
  24432. arc?: number;
  24433. updatable?: boolean;
  24434. sideOrientation?: number;
  24435. frontUVs?: Vector4;
  24436. backUVs?: Vector4;
  24437. }, scene?: Nullable<Scene>): Mesh;
  24438. }
  24439. }
  24440. declare module "babylonjs/Particles/solidParticleSystem" {
  24441. import { Vector3 } from "babylonjs/Maths/math";
  24442. import { Mesh } from "babylonjs/Meshes/mesh";
  24443. import { Scene, IDisposable } from "babylonjs/scene";
  24444. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24445. /**
  24446. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24447. *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.
  24448. * The SPS is also a particle system. It provides some methods to manage the particles.
  24449. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24450. *
  24451. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24452. */
  24453. export class SolidParticleSystem implements IDisposable {
  24454. /**
  24455. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24456. * Example : var p = SPS.particles[i];
  24457. */
  24458. particles: SolidParticle[];
  24459. /**
  24460. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24461. */
  24462. nbParticles: number;
  24463. /**
  24464. * If the particles must ever face the camera (default false). Useful for planar particles.
  24465. */
  24466. billboard: boolean;
  24467. /**
  24468. * Recompute normals when adding a shape
  24469. */
  24470. recomputeNormals: boolean;
  24471. /**
  24472. * This a counter ofr your own usage. It's not set by any SPS functions.
  24473. */
  24474. counter: number;
  24475. /**
  24476. * The SPS name. This name is also given to the underlying mesh.
  24477. */
  24478. name: string;
  24479. /**
  24480. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24481. */
  24482. mesh: Mesh;
  24483. /**
  24484. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24485. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24486. */
  24487. vars: any;
  24488. /**
  24489. * This array is populated when the SPS is set as 'pickable'.
  24490. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24491. * Each element of this array is an object `{idx: int, faceId: int}`.
  24492. * `idx` is the picked particle index in the `SPS.particles` array
  24493. * `faceId` is the picked face index counted within this particle.
  24494. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24495. */
  24496. pickedParticles: {
  24497. idx: number;
  24498. faceId: number;
  24499. }[];
  24500. /**
  24501. * This array is populated when `enableDepthSort` is set to true.
  24502. * Each element of this array is an instance of the class DepthSortedParticle.
  24503. */
  24504. depthSortedParticles: DepthSortedParticle[];
  24505. /**
  24506. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24507. * @hidden
  24508. */
  24509. _bSphereOnly: boolean;
  24510. /**
  24511. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24512. * @hidden
  24513. */
  24514. _bSphereRadiusFactor: number;
  24515. private _scene;
  24516. private _positions;
  24517. private _indices;
  24518. private _normals;
  24519. private _colors;
  24520. private _uvs;
  24521. private _indices32;
  24522. private _positions32;
  24523. private _normals32;
  24524. private _fixedNormal32;
  24525. private _colors32;
  24526. private _uvs32;
  24527. private _index;
  24528. private _updatable;
  24529. private _pickable;
  24530. private _isVisibilityBoxLocked;
  24531. private _alwaysVisible;
  24532. private _depthSort;
  24533. private _shapeCounter;
  24534. private _copy;
  24535. private _color;
  24536. private _computeParticleColor;
  24537. private _computeParticleTexture;
  24538. private _computeParticleRotation;
  24539. private _computeParticleVertex;
  24540. private _computeBoundingBox;
  24541. private _depthSortParticles;
  24542. private _camera;
  24543. private _mustUnrotateFixedNormals;
  24544. private _particlesIntersect;
  24545. private _needs32Bits;
  24546. /**
  24547. * Creates a SPS (Solid Particle System) object.
  24548. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24549. * @param scene (Scene) is the scene in which the SPS is added.
  24550. * @param options defines the options of the sps e.g.
  24551. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24552. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24553. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24554. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24555. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24556. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24557. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24558. */
  24559. constructor(name: string, scene: Scene, options?: {
  24560. updatable?: boolean;
  24561. isPickable?: boolean;
  24562. enableDepthSort?: boolean;
  24563. particleIntersection?: boolean;
  24564. boundingSphereOnly?: boolean;
  24565. bSphereRadiusFactor?: number;
  24566. });
  24567. /**
  24568. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24569. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24570. * @returns the created mesh
  24571. */
  24572. buildMesh(): Mesh;
  24573. /**
  24574. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24575. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24576. * Thus the particles generated from `digest()` have their property `position` set yet.
  24577. * @param mesh ( Mesh ) is the mesh to be digested
  24578. * @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
  24579. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24580. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24581. * @returns the current SPS
  24582. */
  24583. digest(mesh: Mesh, options?: {
  24584. facetNb?: number;
  24585. number?: number;
  24586. delta?: number;
  24587. }): SolidParticleSystem;
  24588. private _unrotateFixedNormals;
  24589. private _resetCopy;
  24590. private _meshBuilder;
  24591. private _posToShape;
  24592. private _uvsToShapeUV;
  24593. private _addParticle;
  24594. /**
  24595. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24596. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24597. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24598. * @param nb (positive integer) the number of particles to be created from this model
  24599. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24600. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24601. * @returns the number of shapes in the system
  24602. */
  24603. addShape(mesh: Mesh, nb: number, options?: {
  24604. positionFunction?: any;
  24605. vertexFunction?: any;
  24606. }): number;
  24607. private _rebuildParticle;
  24608. /**
  24609. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24610. * @returns the SPS.
  24611. */
  24612. rebuildMesh(): SolidParticleSystem;
  24613. /**
  24614. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24615. * This method calls `updateParticle()` for each particle of the SPS.
  24616. * For an animated SPS, it is usually called within the render loop.
  24617. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24618. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24619. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24620. * @returns the SPS.
  24621. */
  24622. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24623. /**
  24624. * Disposes the SPS.
  24625. */
  24626. dispose(): void;
  24627. /**
  24628. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24629. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24630. * @returns the SPS.
  24631. */
  24632. refreshVisibleSize(): SolidParticleSystem;
  24633. /**
  24634. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24635. * @param size the size (float) of the visibility box
  24636. * note : this doesn't lock the SPS mesh bounding box.
  24637. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24638. */
  24639. setVisibilityBox(size: number): void;
  24640. /**
  24641. * Gets whether the SPS as always visible or not
  24642. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24643. */
  24644. /**
  24645. * Sets the SPS as always visible or not
  24646. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24647. */
  24648. isAlwaysVisible: boolean;
  24649. /**
  24650. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24651. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24652. */
  24653. /**
  24654. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24655. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24656. */
  24657. isVisibilityBoxLocked: boolean;
  24658. /**
  24659. * Tells to `setParticles()` to compute the particle rotations or not.
  24660. * Default value : true. The SPS is faster when it's set to false.
  24661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24662. */
  24663. /**
  24664. * Gets if `setParticles()` computes the particle rotations or not.
  24665. * Default value : true. The SPS is faster when it's set to false.
  24666. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24667. */
  24668. computeParticleRotation: boolean;
  24669. /**
  24670. * Tells to `setParticles()` to compute the particle colors or not.
  24671. * Default value : true. The SPS is faster when it's set to false.
  24672. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24673. */
  24674. /**
  24675. * Gets if `setParticles()` computes the particle colors or not.
  24676. * Default value : true. The SPS is faster when it's set to false.
  24677. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24678. */
  24679. computeParticleColor: boolean;
  24680. /**
  24681. * Gets if `setParticles()` computes the particle textures or not.
  24682. * Default value : true. The SPS is faster when it's set to false.
  24683. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24684. */
  24685. computeParticleTexture: boolean;
  24686. /**
  24687. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24688. * Default value : false. The SPS is faster when it's set to false.
  24689. * Note : the particle custom vertex positions aren't stored values.
  24690. */
  24691. /**
  24692. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24693. * Default value : false. The SPS is faster when it's set to false.
  24694. * Note : the particle custom vertex positions aren't stored values.
  24695. */
  24696. computeParticleVertex: boolean;
  24697. /**
  24698. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24699. */
  24700. /**
  24701. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24702. */
  24703. computeBoundingBox: boolean;
  24704. /**
  24705. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24706. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24707. * Default : `true`
  24708. */
  24709. /**
  24710. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24711. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24712. * Default : `true`
  24713. */
  24714. depthSortParticles: boolean;
  24715. /**
  24716. * This function does nothing. It may be overwritten to set all the particle first values.
  24717. * The SPS doesn't call this function, you may have to call it by your own.
  24718. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24719. */
  24720. initParticles(): void;
  24721. /**
  24722. * This function does nothing. It may be overwritten to recycle a particle.
  24723. * The SPS doesn't call this function, you may have to call it by your own.
  24724. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24725. * @param particle The particle to recycle
  24726. * @returns the recycled particle
  24727. */
  24728. recycleParticle(particle: SolidParticle): SolidParticle;
  24729. /**
  24730. * Updates a particle : this function should be overwritten by the user.
  24731. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24732. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24733. * @example : just set a particle position or velocity and recycle conditions
  24734. * @param particle The particle to update
  24735. * @returns the updated particle
  24736. */
  24737. updateParticle(particle: SolidParticle): SolidParticle;
  24738. /**
  24739. * Updates a vertex of a particle : it can be overwritten by the user.
  24740. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24741. * @param particle the current particle
  24742. * @param vertex the current index of the current particle
  24743. * @param pt the index of the current vertex in the particle shape
  24744. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24745. * @example : just set a vertex particle position
  24746. * @returns the updated vertex
  24747. */
  24748. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24749. /**
  24750. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24751. * This does nothing and may be overwritten by the user.
  24752. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24753. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24754. * @param update the boolean update value actually passed to setParticles()
  24755. */
  24756. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24757. /**
  24758. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24759. * This will be passed three parameters.
  24760. * This does nothing and may be overwritten by the user.
  24761. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24762. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24763. * @param update the boolean update value actually passed to setParticles()
  24764. */
  24765. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24766. }
  24767. }
  24768. declare module "babylonjs/Particles/solidParticle" {
  24769. import { Nullable } from "babylonjs/types";
  24770. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24771. import { Mesh } from "babylonjs/Meshes/mesh";
  24772. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24773. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24774. /**
  24775. * Represents one particle of a solid particle system.
  24776. */
  24777. export class SolidParticle {
  24778. /**
  24779. * particle global index
  24780. */
  24781. idx: number;
  24782. /**
  24783. * The color of the particle
  24784. */
  24785. color: Nullable<Color4>;
  24786. /**
  24787. * The world space position of the particle.
  24788. */
  24789. position: Vector3;
  24790. /**
  24791. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24792. */
  24793. rotation: Vector3;
  24794. /**
  24795. * The world space rotation quaternion of the particle.
  24796. */
  24797. rotationQuaternion: Nullable<Quaternion>;
  24798. /**
  24799. * The scaling of the particle.
  24800. */
  24801. scaling: Vector3;
  24802. /**
  24803. * The uvs of the particle.
  24804. */
  24805. uvs: Vector4;
  24806. /**
  24807. * The current speed of the particle.
  24808. */
  24809. velocity: Vector3;
  24810. /**
  24811. * The pivot point in the particle local space.
  24812. */
  24813. pivot: Vector3;
  24814. /**
  24815. * Must the particle be translated from its pivot point in its local space ?
  24816. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24817. * Default : false
  24818. */
  24819. translateFromPivot: boolean;
  24820. /**
  24821. * Is the particle active or not ?
  24822. */
  24823. alive: boolean;
  24824. /**
  24825. * Is the particle visible or not ?
  24826. */
  24827. isVisible: boolean;
  24828. /**
  24829. * Index of this particle in the global "positions" array (Internal use)
  24830. * @hidden
  24831. */
  24832. _pos: number;
  24833. /**
  24834. * @hidden Index of this particle in the global "indices" array (Internal use)
  24835. */
  24836. _ind: number;
  24837. /**
  24838. * @hidden ModelShape of this particle (Internal use)
  24839. */
  24840. _model: ModelShape;
  24841. /**
  24842. * ModelShape id of this particle
  24843. */
  24844. shapeId: number;
  24845. /**
  24846. * Index of the particle in its shape id (Internal use)
  24847. */
  24848. idxInShape: number;
  24849. /**
  24850. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24851. */
  24852. _modelBoundingInfo: BoundingInfo;
  24853. /**
  24854. * @hidden Particle BoundingInfo object (Internal use)
  24855. */
  24856. _boundingInfo: BoundingInfo;
  24857. /**
  24858. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24859. */
  24860. _sps: SolidParticleSystem;
  24861. /**
  24862. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24863. */
  24864. _stillInvisible: boolean;
  24865. /**
  24866. * @hidden Last computed particle rotation matrix
  24867. */
  24868. _rotationMatrix: number[];
  24869. /**
  24870. * Parent particle Id, if any.
  24871. * Default null.
  24872. */
  24873. parentId: Nullable<number>;
  24874. /**
  24875. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24876. * The possible values are :
  24877. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24878. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24879. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24880. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24881. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24882. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24883. * */
  24884. cullingStrategy: number;
  24885. /**
  24886. * @hidden Internal global position in the SPS.
  24887. */
  24888. _globalPosition: Vector3;
  24889. /**
  24890. * Creates a Solid Particle object.
  24891. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24892. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24893. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24894. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24895. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24896. * @param shapeId (integer) is the model shape identifier in the SPS.
  24897. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24898. * @param sps defines the sps it is associated to
  24899. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24900. */
  24901. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24902. /**
  24903. * Legacy support, changed scale to scaling
  24904. */
  24905. /**
  24906. * Legacy support, changed scale to scaling
  24907. */
  24908. scale: Vector3;
  24909. /**
  24910. * Legacy support, changed quaternion to rotationQuaternion
  24911. */
  24912. /**
  24913. * Legacy support, changed quaternion to rotationQuaternion
  24914. */
  24915. quaternion: Nullable<Quaternion>;
  24916. /**
  24917. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24918. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24919. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24920. * @returns true if it intersects
  24921. */
  24922. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24923. /**
  24924. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24925. * A particle is in the frustum if its bounding box intersects the frustum
  24926. * @param frustumPlanes defines the frustum to test
  24927. * @returns true if the particle is in the frustum planes
  24928. */
  24929. isInFrustum(frustumPlanes: Plane[]): boolean;
  24930. /**
  24931. * get the rotation matrix of the particle
  24932. * @hidden
  24933. */
  24934. getRotationMatrix(m: Matrix): void;
  24935. }
  24936. /**
  24937. * Represents the shape of the model used by one particle of a solid particle system.
  24938. * SPS internal tool, don't use it manually.
  24939. */
  24940. export class ModelShape {
  24941. /**
  24942. * The shape id
  24943. * @hidden
  24944. */
  24945. shapeID: number;
  24946. /**
  24947. * flat array of model positions (internal use)
  24948. * @hidden
  24949. */
  24950. _shape: Vector3[];
  24951. /**
  24952. * flat array of model UVs (internal use)
  24953. * @hidden
  24954. */
  24955. _shapeUV: number[];
  24956. /**
  24957. * length of the shape in the model indices array (internal use)
  24958. * @hidden
  24959. */
  24960. _indicesLength: number;
  24961. /**
  24962. * Custom position function (internal use)
  24963. * @hidden
  24964. */
  24965. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24966. /**
  24967. * Custom vertex function (internal use)
  24968. * @hidden
  24969. */
  24970. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24971. /**
  24972. * 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.
  24973. * SPS internal tool, don't use it manually.
  24974. * @hidden
  24975. */
  24976. 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>);
  24977. }
  24978. /**
  24979. * Represents a Depth Sorted Particle in the solid particle system.
  24980. */
  24981. export class DepthSortedParticle {
  24982. /**
  24983. * Index of the particle in the "indices" array
  24984. */
  24985. ind: number;
  24986. /**
  24987. * Length of the particle shape in the "indices" array
  24988. */
  24989. indicesLength: number;
  24990. /**
  24991. * Squared distance from the particle to the camera
  24992. */
  24993. sqDistance: number;
  24994. }
  24995. }
  24996. declare module "babylonjs/Collisions/meshCollisionData" {
  24997. import { Collider } from "babylonjs/Collisions/collider";
  24998. import { Vector3 } from "babylonjs/Maths/math";
  24999. import { Nullable } from "babylonjs/types";
  25000. import { Observer } from "babylonjs/Misc/observable";
  25001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25002. /**
  25003. * @hidden
  25004. */
  25005. export class _MeshCollisionData {
  25006. _checkCollisions: boolean;
  25007. _collisionMask: number;
  25008. _collisionGroup: number;
  25009. _collider: Nullable<Collider>;
  25010. _oldPositionForCollisions: Vector3;
  25011. _diffPositionForCollisions: Vector3;
  25012. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25013. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25014. }
  25015. }
  25016. declare module "babylonjs/Meshes/abstractMesh" {
  25017. import { Observable } from "babylonjs/Misc/observable";
  25018. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25019. import { Camera } from "babylonjs/Cameras/camera";
  25020. import { Scene, IDisposable } from "babylonjs/scene";
  25021. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25022. import { Node } from "babylonjs/node";
  25023. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25025. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25026. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25027. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25028. import { Material } from "babylonjs/Materials/material";
  25029. import { Light } from "babylonjs/Lights/light";
  25030. import { Skeleton } from "babylonjs/Bones/skeleton";
  25031. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25032. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25033. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25034. import { Ray } from "babylonjs/Culling/ray";
  25035. import { Collider } from "babylonjs/Collisions/collider";
  25036. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25037. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25038. /** @hidden */
  25039. class _FacetDataStorage {
  25040. facetPositions: Vector3[];
  25041. facetNormals: Vector3[];
  25042. facetPartitioning: number[][];
  25043. facetNb: number;
  25044. partitioningSubdivisions: number;
  25045. partitioningBBoxRatio: number;
  25046. facetDataEnabled: boolean;
  25047. facetParameters: any;
  25048. bbSize: Vector3;
  25049. subDiv: {
  25050. max: number;
  25051. X: number;
  25052. Y: number;
  25053. Z: number;
  25054. };
  25055. facetDepthSort: boolean;
  25056. facetDepthSortEnabled: boolean;
  25057. depthSortedIndices: IndicesArray;
  25058. depthSortedFacets: {
  25059. ind: number;
  25060. sqDistance: number;
  25061. }[];
  25062. facetDepthSortFunction: (f1: {
  25063. ind: number;
  25064. sqDistance: number;
  25065. }, f2: {
  25066. ind: number;
  25067. sqDistance: number;
  25068. }) => number;
  25069. facetDepthSortFrom: Vector3;
  25070. facetDepthSortOrigin: Vector3;
  25071. invertedMatrix: Matrix;
  25072. }
  25073. /**
  25074. * @hidden
  25075. **/
  25076. class _InternalAbstractMeshDataInfo {
  25077. _hasVertexAlpha: boolean;
  25078. _useVertexColors: boolean;
  25079. _numBoneInfluencers: number;
  25080. _applyFog: boolean;
  25081. _receiveShadows: boolean;
  25082. _facetData: _FacetDataStorage;
  25083. _visibility: number;
  25084. _skeleton: Nullable<Skeleton>;
  25085. _layerMask: number;
  25086. _computeBonesUsingShaders: boolean;
  25087. _isActive: boolean;
  25088. _onlyForInstances: boolean;
  25089. _isActiveIntermediate: boolean;
  25090. _onlyForInstancesIntermediate: boolean;
  25091. }
  25092. /**
  25093. * Class used to store all common mesh properties
  25094. */
  25095. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25096. /** No occlusion */
  25097. static OCCLUSION_TYPE_NONE: number;
  25098. /** Occlusion set to optimisitic */
  25099. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25100. /** Occlusion set to strict */
  25101. static OCCLUSION_TYPE_STRICT: number;
  25102. /** Use an accurante occlusion algorithm */
  25103. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25104. /** Use a conservative occlusion algorithm */
  25105. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25106. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25107. * Test order :
  25108. * Is the bounding sphere outside the frustum ?
  25109. * If not, are the bounding box vertices outside the frustum ?
  25110. * It not, then the cullable object is in the frustum.
  25111. */
  25112. static readonly CULLINGSTRATEGY_STANDARD: number;
  25113. /** Culling strategy : Bounding Sphere Only.
  25114. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25115. * It's also less accurate than the standard because some not visible objects can still be selected.
  25116. * Test : is the bounding sphere outside the frustum ?
  25117. * If not, then the cullable object is in the frustum.
  25118. */
  25119. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25120. /** Culling strategy : Optimistic Inclusion.
  25121. * This in an inclusion test first, then the standard exclusion test.
  25122. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25123. * 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.
  25124. * Anyway, it's as accurate as the standard strategy.
  25125. * Test :
  25126. * Is the cullable object bounding sphere center in the frustum ?
  25127. * If not, apply the default culling strategy.
  25128. */
  25129. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25130. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25131. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25132. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25133. * 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.
  25134. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25135. * Test :
  25136. * Is the cullable object bounding sphere center in the frustum ?
  25137. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25138. */
  25139. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25140. /**
  25141. * No billboard
  25142. */
  25143. static readonly BILLBOARDMODE_NONE: number;
  25144. /** Billboard on X axis */
  25145. static readonly BILLBOARDMODE_X: number;
  25146. /** Billboard on Y axis */
  25147. static readonly BILLBOARDMODE_Y: number;
  25148. /** Billboard on Z axis */
  25149. static readonly BILLBOARDMODE_Z: number;
  25150. /** Billboard on all axes */
  25151. static readonly BILLBOARDMODE_ALL: number;
  25152. /** @hidden */
  25153. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25154. /**
  25155. * The culling strategy to use to check whether the mesh must be rendered or not.
  25156. * This value can be changed at any time and will be used on the next render mesh selection.
  25157. * The possible values are :
  25158. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25159. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25160. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25161. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25162. * Please read each static variable documentation to get details about the culling process.
  25163. * */
  25164. cullingStrategy: number;
  25165. /**
  25166. * Gets the number of facets in the mesh
  25167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25168. */
  25169. readonly facetNb: number;
  25170. /**
  25171. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25173. */
  25174. partitioningSubdivisions: number;
  25175. /**
  25176. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25177. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25179. */
  25180. partitioningBBoxRatio: number;
  25181. /**
  25182. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25183. * Works only for updatable meshes.
  25184. * Doesn't work with multi-materials
  25185. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25186. */
  25187. mustDepthSortFacets: boolean;
  25188. /**
  25189. * The location (Vector3) where the facet depth sort must be computed from.
  25190. * By default, the active camera position.
  25191. * Used only when facet depth sort is enabled
  25192. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25193. */
  25194. facetDepthSortFrom: Vector3;
  25195. /**
  25196. * gets a boolean indicating if facetData is enabled
  25197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25198. */
  25199. readonly isFacetDataEnabled: boolean;
  25200. /** @hidden */
  25201. _updateNonUniformScalingState(value: boolean): boolean;
  25202. /**
  25203. * An event triggered when this mesh collides with another one
  25204. */
  25205. onCollideObservable: Observable<AbstractMesh>;
  25206. /** Set a function to call when this mesh collides with another one */
  25207. onCollide: () => void;
  25208. /**
  25209. * An event triggered when the collision's position changes
  25210. */
  25211. onCollisionPositionChangeObservable: Observable<Vector3>;
  25212. /** Set a function to call when the collision's position changes */
  25213. onCollisionPositionChange: () => void;
  25214. /**
  25215. * An event triggered when material is changed
  25216. */
  25217. onMaterialChangedObservable: Observable<AbstractMesh>;
  25218. /**
  25219. * Gets or sets the orientation for POV movement & rotation
  25220. */
  25221. definedFacingForward: boolean;
  25222. /** @hidden */
  25223. _occlusionQuery: Nullable<WebGLQuery>;
  25224. /** @hidden */
  25225. _renderingGroup: Nullable<RenderingGroup>;
  25226. /**
  25227. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25228. */
  25229. /**
  25230. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25231. */
  25232. visibility: number;
  25233. /** Gets or sets the alpha index used to sort transparent meshes
  25234. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25235. */
  25236. alphaIndex: number;
  25237. /**
  25238. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25239. */
  25240. isVisible: boolean;
  25241. /**
  25242. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25243. */
  25244. isPickable: boolean;
  25245. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25246. showSubMeshesBoundingBox: boolean;
  25247. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25248. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25249. */
  25250. isBlocker: boolean;
  25251. /**
  25252. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25253. */
  25254. enablePointerMoveEvents: boolean;
  25255. /**
  25256. * Specifies the rendering group id for this mesh (0 by default)
  25257. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25258. */
  25259. renderingGroupId: number;
  25260. private _material;
  25261. /** Gets or sets current material */
  25262. material: Nullable<Material>;
  25263. /**
  25264. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25265. * @see http://doc.babylonjs.com/babylon101/shadows
  25266. */
  25267. receiveShadows: boolean;
  25268. /** Defines color to use when rendering outline */
  25269. outlineColor: Color3;
  25270. /** Define width to use when rendering outline */
  25271. outlineWidth: number;
  25272. /** Defines color to use when rendering overlay */
  25273. overlayColor: Color3;
  25274. /** Defines alpha to use when rendering overlay */
  25275. overlayAlpha: number;
  25276. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25277. hasVertexAlpha: boolean;
  25278. /** 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) */
  25279. useVertexColors: boolean;
  25280. /**
  25281. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25282. */
  25283. computeBonesUsingShaders: boolean;
  25284. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25285. numBoneInfluencers: number;
  25286. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25287. applyFog: boolean;
  25288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25289. useOctreeForRenderingSelection: boolean;
  25290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25291. useOctreeForPicking: boolean;
  25292. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25293. useOctreeForCollisions: boolean;
  25294. /**
  25295. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25296. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25297. */
  25298. layerMask: number;
  25299. /**
  25300. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25301. */
  25302. alwaysSelectAsActiveMesh: boolean;
  25303. /**
  25304. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25305. */
  25306. doNotSyncBoundingInfo: boolean;
  25307. /**
  25308. * Gets or sets the current action manager
  25309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25310. */
  25311. actionManager: Nullable<AbstractActionManager>;
  25312. private _meshCollisionData;
  25313. /**
  25314. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25316. */
  25317. ellipsoid: Vector3;
  25318. /**
  25319. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25321. */
  25322. ellipsoidOffset: Vector3;
  25323. /**
  25324. * Gets or sets a collision mask used to mask collisions (default is -1).
  25325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25326. */
  25327. collisionMask: number;
  25328. /**
  25329. * Gets or sets the current collision group mask (-1 by default).
  25330. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25331. */
  25332. collisionGroup: number;
  25333. /**
  25334. * Defines edge width used when edgesRenderer is enabled
  25335. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25336. */
  25337. edgesWidth: number;
  25338. /**
  25339. * Defines edge color used when edgesRenderer is enabled
  25340. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25341. */
  25342. edgesColor: Color4;
  25343. /** @hidden */
  25344. _edgesRenderer: Nullable<IEdgesRenderer>;
  25345. /** @hidden */
  25346. _masterMesh: Nullable<AbstractMesh>;
  25347. /** @hidden */
  25348. _boundingInfo: Nullable<BoundingInfo>;
  25349. /** @hidden */
  25350. _renderId: number;
  25351. /**
  25352. * Gets or sets the list of subMeshes
  25353. * @see http://doc.babylonjs.com/how_to/multi_materials
  25354. */
  25355. subMeshes: SubMesh[];
  25356. /** @hidden */
  25357. _intersectionsInProgress: AbstractMesh[];
  25358. /** @hidden */
  25359. _unIndexed: boolean;
  25360. /** @hidden */
  25361. _lightSources: Light[];
  25362. /** Gets the list of lights affecting that mesh */
  25363. readonly lightSources: Light[];
  25364. /** @hidden */
  25365. readonly _positions: Nullable<Vector3[]>;
  25366. /** @hidden */
  25367. _waitingData: {
  25368. lods: Nullable<any>;
  25369. actions: Nullable<any>;
  25370. freezeWorldMatrix: Nullable<boolean>;
  25371. };
  25372. /** @hidden */
  25373. _bonesTransformMatrices: Nullable<Float32Array>;
  25374. /**
  25375. * Gets or sets a skeleton to apply skining transformations
  25376. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25377. */
  25378. skeleton: Nullable<Skeleton>;
  25379. /**
  25380. * An event triggered when the mesh is rebuilt.
  25381. */
  25382. onRebuildObservable: Observable<AbstractMesh>;
  25383. /**
  25384. * Creates a new AbstractMesh
  25385. * @param name defines the name of the mesh
  25386. * @param scene defines the hosting scene
  25387. */
  25388. constructor(name: string, scene?: Nullable<Scene>);
  25389. /**
  25390. * Returns the string "AbstractMesh"
  25391. * @returns "AbstractMesh"
  25392. */
  25393. getClassName(): string;
  25394. /**
  25395. * Gets a string representation of the current mesh
  25396. * @param fullDetails defines a boolean indicating if full details must be included
  25397. * @returns a string representation of the current mesh
  25398. */
  25399. toString(fullDetails?: boolean): string;
  25400. /**
  25401. * @hidden
  25402. */
  25403. protected _getEffectiveParent(): Nullable<Node>;
  25404. /** @hidden */
  25405. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25406. /** @hidden */
  25407. _rebuild(): void;
  25408. /** @hidden */
  25409. _resyncLightSources(): void;
  25410. /** @hidden */
  25411. _resyncLighSource(light: Light): void;
  25412. /** @hidden */
  25413. _unBindEffect(): void;
  25414. /** @hidden */
  25415. _removeLightSource(light: Light): void;
  25416. private _markSubMeshesAsDirty;
  25417. /** @hidden */
  25418. _markSubMeshesAsLightDirty(): void;
  25419. /** @hidden */
  25420. _markSubMeshesAsAttributesDirty(): void;
  25421. /** @hidden */
  25422. _markSubMeshesAsMiscDirty(): void;
  25423. /**
  25424. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25425. */
  25426. scaling: Vector3;
  25427. /**
  25428. * Returns true if the mesh is blocked. Implemented by child classes
  25429. */
  25430. readonly isBlocked: boolean;
  25431. /**
  25432. * Returns the mesh itself by default. Implemented by child classes
  25433. * @param camera defines the camera to use to pick the right LOD level
  25434. * @returns the currentAbstractMesh
  25435. */
  25436. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25437. /**
  25438. * Returns 0 by default. Implemented by child classes
  25439. * @returns an integer
  25440. */
  25441. getTotalVertices(): number;
  25442. /**
  25443. * Returns a positive integer : the total number of indices in this mesh geometry.
  25444. * @returns the numner of indices or zero if the mesh has no geometry.
  25445. */
  25446. getTotalIndices(): number;
  25447. /**
  25448. * Returns null by default. Implemented by child classes
  25449. * @returns null
  25450. */
  25451. getIndices(): Nullable<IndicesArray>;
  25452. /**
  25453. * Returns the array of the requested vertex data kind. Implemented by child classes
  25454. * @param kind defines the vertex data kind to use
  25455. * @returns null
  25456. */
  25457. getVerticesData(kind: string): Nullable<FloatArray>;
  25458. /**
  25459. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25460. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25461. * Note that a new underlying VertexBuffer object is created each call.
  25462. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25463. * @param kind defines vertex data kind:
  25464. * * VertexBuffer.PositionKind
  25465. * * VertexBuffer.UVKind
  25466. * * VertexBuffer.UV2Kind
  25467. * * VertexBuffer.UV3Kind
  25468. * * VertexBuffer.UV4Kind
  25469. * * VertexBuffer.UV5Kind
  25470. * * VertexBuffer.UV6Kind
  25471. * * VertexBuffer.ColorKind
  25472. * * VertexBuffer.MatricesIndicesKind
  25473. * * VertexBuffer.MatricesIndicesExtraKind
  25474. * * VertexBuffer.MatricesWeightsKind
  25475. * * VertexBuffer.MatricesWeightsExtraKind
  25476. * @param data defines the data source
  25477. * @param updatable defines if the data must be flagged as updatable (or static)
  25478. * @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
  25479. * @returns the current mesh
  25480. */
  25481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25482. /**
  25483. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25484. * If the mesh has no geometry, it is simply returned as it is.
  25485. * @param kind defines vertex data kind:
  25486. * * VertexBuffer.PositionKind
  25487. * * VertexBuffer.UVKind
  25488. * * VertexBuffer.UV2Kind
  25489. * * VertexBuffer.UV3Kind
  25490. * * VertexBuffer.UV4Kind
  25491. * * VertexBuffer.UV5Kind
  25492. * * VertexBuffer.UV6Kind
  25493. * * VertexBuffer.ColorKind
  25494. * * VertexBuffer.MatricesIndicesKind
  25495. * * VertexBuffer.MatricesIndicesExtraKind
  25496. * * VertexBuffer.MatricesWeightsKind
  25497. * * VertexBuffer.MatricesWeightsExtraKind
  25498. * @param data defines the data source
  25499. * @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
  25500. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25501. * @returns the current mesh
  25502. */
  25503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25504. /**
  25505. * Sets the mesh indices,
  25506. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25507. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25508. * @param totalVertices Defines the total number of vertices
  25509. * @returns the current mesh
  25510. */
  25511. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25512. /**
  25513. * Gets a boolean indicating if specific vertex data is present
  25514. * @param kind defines the vertex data kind to use
  25515. * @returns true is data kind is present
  25516. */
  25517. isVerticesDataPresent(kind: string): boolean;
  25518. /**
  25519. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25520. * @returns a BoundingInfo
  25521. */
  25522. getBoundingInfo(): BoundingInfo;
  25523. /**
  25524. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25525. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25526. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25527. * @returns the current mesh
  25528. */
  25529. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25530. /**
  25531. * Overwrite the current bounding info
  25532. * @param boundingInfo defines the new bounding info
  25533. * @returns the current mesh
  25534. */
  25535. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25536. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25537. readonly useBones: boolean;
  25538. /** @hidden */
  25539. _preActivate(): void;
  25540. /** @hidden */
  25541. _preActivateForIntermediateRendering(renderId: number): void;
  25542. /** @hidden */
  25543. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25544. /** @hidden */
  25545. _postActivate(): void;
  25546. /** @hidden */
  25547. _freeze(): void;
  25548. /** @hidden */
  25549. _unFreeze(): void;
  25550. /**
  25551. * Gets the current world matrix
  25552. * @returns a Matrix
  25553. */
  25554. getWorldMatrix(): Matrix;
  25555. /** @hidden */
  25556. _getWorldMatrixDeterminant(): number;
  25557. /**
  25558. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25559. */
  25560. readonly isAnInstance: boolean;
  25561. /**
  25562. * Perform relative position change from the point of view of behind the front of the mesh.
  25563. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25564. * Supports definition of mesh facing forward or backward
  25565. * @param amountRight defines the distance on the right axis
  25566. * @param amountUp defines the distance on the up axis
  25567. * @param amountForward defines the distance on the forward axis
  25568. * @returns the current mesh
  25569. */
  25570. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25571. /**
  25572. * Calculate relative position change from the point of view of behind the front of the mesh.
  25573. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25574. * Supports definition of mesh facing forward or backward
  25575. * @param amountRight defines the distance on the right axis
  25576. * @param amountUp defines the distance on the up axis
  25577. * @param amountForward defines the distance on the forward axis
  25578. * @returns the new displacement vector
  25579. */
  25580. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25581. /**
  25582. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25583. * Supports definition of mesh facing forward or backward
  25584. * @param flipBack defines the flip
  25585. * @param twirlClockwise defines the twirl
  25586. * @param tiltRight defines the tilt
  25587. * @returns the current mesh
  25588. */
  25589. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25590. /**
  25591. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25592. * Supports definition of mesh facing forward or backward.
  25593. * @param flipBack defines the flip
  25594. * @param twirlClockwise defines the twirl
  25595. * @param tiltRight defines the tilt
  25596. * @returns the new rotation vector
  25597. */
  25598. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25599. /**
  25600. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25601. * This means the mesh underlying bounding box and sphere are recomputed.
  25602. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25603. * @returns the current mesh
  25604. */
  25605. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25606. /** @hidden */
  25607. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25608. /** @hidden */
  25609. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25610. /** @hidden */
  25611. _updateBoundingInfo(): AbstractMesh;
  25612. /** @hidden */
  25613. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25614. /** @hidden */
  25615. protected _afterComputeWorldMatrix(): void;
  25616. /** @hidden */
  25617. readonly _effectiveMesh: AbstractMesh;
  25618. /**
  25619. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25620. * A mesh is in the frustum if its bounding box intersects the frustum
  25621. * @param frustumPlanes defines the frustum to test
  25622. * @returns true if the mesh is in the frustum planes
  25623. */
  25624. isInFrustum(frustumPlanes: Plane[]): boolean;
  25625. /**
  25626. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25627. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25628. * @param frustumPlanes defines the frustum to test
  25629. * @returns true if the mesh is completely in the frustum planes
  25630. */
  25631. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25632. /**
  25633. * True if the mesh intersects another mesh or a SolidParticle object
  25634. * @param mesh defines a target mesh or SolidParticle to test
  25635. * @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)
  25636. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25637. * @returns true if there is an intersection
  25638. */
  25639. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25640. /**
  25641. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25642. * @param point defines the point to test
  25643. * @returns true if there is an intersection
  25644. */
  25645. intersectsPoint(point: Vector3): boolean;
  25646. /**
  25647. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25649. */
  25650. checkCollisions: boolean;
  25651. /**
  25652. * Gets Collider object used to compute collisions (not physics)
  25653. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25654. */
  25655. readonly collider: Nullable<Collider>;
  25656. /**
  25657. * Move the mesh using collision engine
  25658. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25659. * @param displacement defines the requested displacement vector
  25660. * @returns the current mesh
  25661. */
  25662. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25663. private _onCollisionPositionChange;
  25664. /** @hidden */
  25665. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25666. /** @hidden */
  25667. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25668. /** @hidden */
  25669. _checkCollision(collider: Collider): AbstractMesh;
  25670. /** @hidden */
  25671. _generatePointsArray(): boolean;
  25672. /**
  25673. * Checks if the passed Ray intersects with the mesh
  25674. * @param ray defines the ray to use
  25675. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25676. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25677. * @returns the picking info
  25678. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25679. */
  25680. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25681. /**
  25682. * Clones the current mesh
  25683. * @param name defines the mesh name
  25684. * @param newParent defines the new mesh parent
  25685. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25686. * @returns the new mesh
  25687. */
  25688. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25689. /**
  25690. * Disposes all the submeshes of the current meshnp
  25691. * @returns the current mesh
  25692. */
  25693. releaseSubMeshes(): AbstractMesh;
  25694. /**
  25695. * Releases resources associated with this abstract mesh.
  25696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25698. */
  25699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25700. /**
  25701. * Adds the passed mesh as a child to the current mesh
  25702. * @param mesh defines the child mesh
  25703. * @returns the current mesh
  25704. */
  25705. addChild(mesh: AbstractMesh): AbstractMesh;
  25706. /**
  25707. * Removes the passed mesh from the current mesh children list
  25708. * @param mesh defines the child mesh
  25709. * @returns the current mesh
  25710. */
  25711. removeChild(mesh: AbstractMesh): AbstractMesh;
  25712. /** @hidden */
  25713. private _initFacetData;
  25714. /**
  25715. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25716. * This method can be called within the render loop.
  25717. * 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
  25718. * @returns the current mesh
  25719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25720. */
  25721. updateFacetData(): AbstractMesh;
  25722. /**
  25723. * Returns the facetLocalNormals array.
  25724. * The normals are expressed in the mesh local spac
  25725. * @returns an array of Vector3
  25726. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25727. */
  25728. getFacetLocalNormals(): Vector3[];
  25729. /**
  25730. * Returns the facetLocalPositions array.
  25731. * The facet positions are expressed in the mesh local space
  25732. * @returns an array of Vector3
  25733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25734. */
  25735. getFacetLocalPositions(): Vector3[];
  25736. /**
  25737. * Returns the facetLocalPartioning array
  25738. * @returns an array of array of numbers
  25739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25740. */
  25741. getFacetLocalPartitioning(): number[][];
  25742. /**
  25743. * Returns the i-th facet position in the world system.
  25744. * This method allocates a new Vector3 per call
  25745. * @param i defines the facet index
  25746. * @returns a new Vector3
  25747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25748. */
  25749. getFacetPosition(i: number): Vector3;
  25750. /**
  25751. * Sets the reference Vector3 with the i-th facet position in the world system
  25752. * @param i defines the facet index
  25753. * @param ref defines the target vector
  25754. * @returns the current mesh
  25755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25756. */
  25757. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25758. /**
  25759. * Returns the i-th facet normal in the world system.
  25760. * This method allocates a new Vector3 per call
  25761. * @param i defines the facet index
  25762. * @returns a new Vector3
  25763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25764. */
  25765. getFacetNormal(i: number): Vector3;
  25766. /**
  25767. * Sets the reference Vector3 with the i-th facet normal in the world system
  25768. * @param i defines the facet index
  25769. * @param ref defines the target vector
  25770. * @returns the current mesh
  25771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25772. */
  25773. getFacetNormalToRef(i: number, ref: Vector3): this;
  25774. /**
  25775. * 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)
  25776. * @param x defines x coordinate
  25777. * @param y defines y coordinate
  25778. * @param z defines z coordinate
  25779. * @returns the array of facet indexes
  25780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25781. */
  25782. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25783. /**
  25784. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25785. * @param projected sets as the (x,y,z) world projection on the facet
  25786. * @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
  25787. * @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
  25788. * @param x defines x coordinate
  25789. * @param y defines y coordinate
  25790. * @param z defines z coordinate
  25791. * @returns the face index if found (or null instead)
  25792. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25793. */
  25794. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25795. /**
  25796. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25797. * @param projected sets as the (x,y,z) local projection on the facet
  25798. * @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
  25799. * @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
  25800. * @param x defines x coordinate
  25801. * @param y defines y coordinate
  25802. * @param z defines z coordinate
  25803. * @returns the face index if found (or null instead)
  25804. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25805. */
  25806. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25807. /**
  25808. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25809. * @returns the parameters
  25810. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25811. */
  25812. getFacetDataParameters(): any;
  25813. /**
  25814. * Disables the feature FacetData and frees the related memory
  25815. * @returns the current mesh
  25816. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25817. */
  25818. disableFacetData(): AbstractMesh;
  25819. /**
  25820. * Updates the AbstractMesh indices array
  25821. * @param indices defines the data source
  25822. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25823. * @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)
  25824. * @returns the current mesh
  25825. */
  25826. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25827. /**
  25828. * Creates new normals data for the mesh
  25829. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25830. * @returns the current mesh
  25831. */
  25832. createNormals(updatable: boolean): AbstractMesh;
  25833. /**
  25834. * Align the mesh with a normal
  25835. * @param normal defines the normal to use
  25836. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25837. * @returns the current mesh
  25838. */
  25839. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25840. /** @hidden */
  25841. _checkOcclusionQuery(): boolean;
  25842. /**
  25843. * Disables the mesh edge rendering mode
  25844. * @returns the currentAbstractMesh
  25845. */
  25846. disableEdgesRendering(): AbstractMesh;
  25847. /**
  25848. * Enables the edge rendering mode on the mesh.
  25849. * This mode makes the mesh edges visible
  25850. * @param epsilon defines the maximal distance between two angles to detect a face
  25851. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25852. * @returns the currentAbstractMesh
  25853. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25854. */
  25855. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25856. }
  25857. }
  25858. declare module "babylonjs/Actions/actionEvent" {
  25859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25860. import { Nullable } from "babylonjs/types";
  25861. import { Sprite } from "babylonjs/Sprites/sprite";
  25862. import { Scene } from "babylonjs/scene";
  25863. import { Vector2 } from "babylonjs/Maths/math";
  25864. /**
  25865. * Interface used to define ActionEvent
  25866. */
  25867. export interface IActionEvent {
  25868. /** The mesh or sprite that triggered the action */
  25869. source: any;
  25870. /** The X mouse cursor position at the time of the event */
  25871. pointerX: number;
  25872. /** The Y mouse cursor position at the time of the event */
  25873. pointerY: number;
  25874. /** The mesh that is currently pointed at (can be null) */
  25875. meshUnderPointer: Nullable<AbstractMesh>;
  25876. /** the original (browser) event that triggered the ActionEvent */
  25877. sourceEvent?: any;
  25878. /** additional data for the event */
  25879. additionalData?: any;
  25880. }
  25881. /**
  25882. * ActionEvent is the event being sent when an action is triggered.
  25883. */
  25884. export class ActionEvent implements IActionEvent {
  25885. /** The mesh or sprite that triggered the action */
  25886. source: any;
  25887. /** The X mouse cursor position at the time of the event */
  25888. pointerX: number;
  25889. /** The Y mouse cursor position at the time of the event */
  25890. pointerY: number;
  25891. /** The mesh that is currently pointed at (can be null) */
  25892. meshUnderPointer: Nullable<AbstractMesh>;
  25893. /** the original (browser) event that triggered the ActionEvent */
  25894. sourceEvent?: any;
  25895. /** additional data for the event */
  25896. additionalData?: any;
  25897. /**
  25898. * Creates a new ActionEvent
  25899. * @param source The mesh or sprite that triggered the action
  25900. * @param pointerX The X mouse cursor position at the time of the event
  25901. * @param pointerY The Y mouse cursor position at the time of the event
  25902. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25903. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25904. * @param additionalData additional data for the event
  25905. */
  25906. constructor(
  25907. /** The mesh or sprite that triggered the action */
  25908. source: any,
  25909. /** The X mouse cursor position at the time of the event */
  25910. pointerX: number,
  25911. /** The Y mouse cursor position at the time of the event */
  25912. pointerY: number,
  25913. /** The mesh that is currently pointed at (can be null) */
  25914. meshUnderPointer: Nullable<AbstractMesh>,
  25915. /** the original (browser) event that triggered the ActionEvent */
  25916. sourceEvent?: any,
  25917. /** additional data for the event */
  25918. additionalData?: any);
  25919. /**
  25920. * Helper function to auto-create an ActionEvent from a source mesh.
  25921. * @param source The source mesh that triggered the event
  25922. * @param evt The original (browser) event
  25923. * @param additionalData additional data for the event
  25924. * @returns the new ActionEvent
  25925. */
  25926. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25927. /**
  25928. * Helper function to auto-create an ActionEvent from a source sprite
  25929. * @param source The source sprite that triggered the event
  25930. * @param scene Scene associated with the sprite
  25931. * @param evt The original (browser) event
  25932. * @param additionalData additional data for the event
  25933. * @returns the new ActionEvent
  25934. */
  25935. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25936. /**
  25937. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25938. * @param scene the scene where the event occurred
  25939. * @param evt The original (browser) event
  25940. * @returns the new ActionEvent
  25941. */
  25942. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25943. /**
  25944. * Helper function to auto-create an ActionEvent from a primitive
  25945. * @param prim defines the target primitive
  25946. * @param pointerPos defines the pointer position
  25947. * @param evt The original (browser) event
  25948. * @param additionalData additional data for the event
  25949. * @returns the new ActionEvent
  25950. */
  25951. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25952. }
  25953. }
  25954. declare module "babylonjs/Actions/abstractActionManager" {
  25955. import { IDisposable } from "babylonjs/scene";
  25956. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25957. import { IAction } from "babylonjs/Actions/action";
  25958. import { Nullable } from "babylonjs/types";
  25959. /**
  25960. * Abstract class used to decouple action Manager from scene and meshes.
  25961. * Do not instantiate.
  25962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25963. */
  25964. export abstract class AbstractActionManager implements IDisposable {
  25965. /** Gets the list of active triggers */
  25966. static Triggers: {
  25967. [key: string]: number;
  25968. };
  25969. /** Gets the cursor to use when hovering items */
  25970. hoverCursor: string;
  25971. /** Gets the list of actions */
  25972. actions: IAction[];
  25973. /**
  25974. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25975. */
  25976. isRecursive: boolean;
  25977. /**
  25978. * Releases all associated resources
  25979. */
  25980. abstract dispose(): void;
  25981. /**
  25982. * Does this action manager has pointer triggers
  25983. */
  25984. abstract readonly hasPointerTriggers: boolean;
  25985. /**
  25986. * Does this action manager has pick triggers
  25987. */
  25988. abstract readonly hasPickTriggers: boolean;
  25989. /**
  25990. * Process a specific trigger
  25991. * @param trigger defines the trigger to process
  25992. * @param evt defines the event details to be processed
  25993. */
  25994. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25995. /**
  25996. * Does this action manager handles actions of any of the given triggers
  25997. * @param triggers defines the triggers to be tested
  25998. * @return a boolean indicating whether one (or more) of the triggers is handled
  25999. */
  26000. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26001. /**
  26002. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26003. * speed.
  26004. * @param triggerA defines the trigger to be tested
  26005. * @param triggerB defines the trigger to be tested
  26006. * @return a boolean indicating whether one (or more) of the triggers is handled
  26007. */
  26008. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26009. /**
  26010. * Does this action manager handles actions of a given trigger
  26011. * @param trigger defines the trigger to be tested
  26012. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26013. * @return whether the trigger is handled
  26014. */
  26015. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26016. /**
  26017. * Serialize this manager to a JSON object
  26018. * @param name defines the property name to store this manager
  26019. * @returns a JSON representation of this manager
  26020. */
  26021. abstract serialize(name: string): any;
  26022. /**
  26023. * Registers an action to this action manager
  26024. * @param action defines the action to be registered
  26025. * @return the action amended (prepared) after registration
  26026. */
  26027. abstract registerAction(action: IAction): Nullable<IAction>;
  26028. /**
  26029. * Unregisters an action to this action manager
  26030. * @param action defines the action to be unregistered
  26031. * @return a boolean indicating whether the action has been unregistered
  26032. */
  26033. abstract unregisterAction(action: IAction): Boolean;
  26034. /**
  26035. * Does exist one action manager with at least one trigger
  26036. **/
  26037. static readonly HasTriggers: boolean;
  26038. /**
  26039. * Does exist one action manager with at least one pick trigger
  26040. **/
  26041. static readonly HasPickTriggers: boolean;
  26042. /**
  26043. * Does exist one action manager that handles actions of a given trigger
  26044. * @param trigger defines the trigger to be tested
  26045. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26046. **/
  26047. static HasSpecificTrigger(trigger: number): boolean;
  26048. }
  26049. }
  26050. declare module "babylonjs/node" {
  26051. import { Scene } from "babylonjs/scene";
  26052. import { Nullable } from "babylonjs/types";
  26053. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26054. import { Engine } from "babylonjs/Engines/engine";
  26055. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26056. import { Observable } from "babylonjs/Misc/observable";
  26057. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26058. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26059. import { Animatable } from "babylonjs/Animations/animatable";
  26060. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26061. import { Animation } from "babylonjs/Animations/animation";
  26062. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26064. /**
  26065. * Defines how a node can be built from a string name.
  26066. */
  26067. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26068. /**
  26069. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26070. */
  26071. export class Node implements IBehaviorAware<Node> {
  26072. /** @hidden */
  26073. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26074. private static _NodeConstructors;
  26075. /**
  26076. * Add a new node constructor
  26077. * @param type defines the type name of the node to construct
  26078. * @param constructorFunc defines the constructor function
  26079. */
  26080. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26081. /**
  26082. * Returns a node constructor based on type name
  26083. * @param type defines the type name
  26084. * @param name defines the new node name
  26085. * @param scene defines the hosting scene
  26086. * @param options defines optional options to transmit to constructors
  26087. * @returns the new constructor or null
  26088. */
  26089. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26090. /**
  26091. * Gets or sets the name of the node
  26092. */
  26093. name: string;
  26094. /**
  26095. * Gets or sets the id of the node
  26096. */
  26097. id: string;
  26098. /**
  26099. * Gets or sets the unique id of the node
  26100. */
  26101. uniqueId: number;
  26102. /**
  26103. * Gets or sets a string used to store user defined state for the node
  26104. */
  26105. state: string;
  26106. /**
  26107. * Gets or sets an object used to store user defined information for the node
  26108. */
  26109. metadata: any;
  26110. /**
  26111. * For internal use only. Please do not use.
  26112. */
  26113. reservedDataStore: any;
  26114. /**
  26115. * List of inspectable custom properties (used by the Inspector)
  26116. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26117. */
  26118. inspectableCustomProperties: IInspectable[];
  26119. /**
  26120. * Gets or sets a boolean used to define if the node must be serialized
  26121. */
  26122. doNotSerialize: boolean;
  26123. /** @hidden */
  26124. _isDisposed: boolean;
  26125. /**
  26126. * Gets a list of Animations associated with the node
  26127. */
  26128. animations: import("babylonjs/Animations/animation").Animation[];
  26129. protected _ranges: {
  26130. [name: string]: Nullable<AnimationRange>;
  26131. };
  26132. /**
  26133. * Callback raised when the node is ready to be used
  26134. */
  26135. onReady: Nullable<(node: Node) => void>;
  26136. private _isEnabled;
  26137. private _isParentEnabled;
  26138. private _isReady;
  26139. /** @hidden */
  26140. _currentRenderId: number;
  26141. private _parentUpdateId;
  26142. /** @hidden */
  26143. _childUpdateId: number;
  26144. /** @hidden */
  26145. _waitingParentId: Nullable<string>;
  26146. /** @hidden */
  26147. _scene: Scene;
  26148. /** @hidden */
  26149. _cache: any;
  26150. private _parentNode;
  26151. private _children;
  26152. /** @hidden */
  26153. _worldMatrix: Matrix;
  26154. /** @hidden */
  26155. _worldMatrixDeterminant: number;
  26156. /** @hidden */
  26157. _worldMatrixDeterminantIsDirty: boolean;
  26158. /** @hidden */
  26159. private _sceneRootNodesIndex;
  26160. /**
  26161. * Gets a boolean indicating if the node has been disposed
  26162. * @returns true if the node was disposed
  26163. */
  26164. isDisposed(): boolean;
  26165. /**
  26166. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26167. * @see https://doc.babylonjs.com/how_to/parenting
  26168. */
  26169. parent: Nullable<Node>;
  26170. private addToSceneRootNodes;
  26171. private removeFromSceneRootNodes;
  26172. private _animationPropertiesOverride;
  26173. /**
  26174. * Gets or sets the animation properties override
  26175. */
  26176. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26177. /**
  26178. * Gets a string idenfifying the name of the class
  26179. * @returns "Node" string
  26180. */
  26181. getClassName(): string;
  26182. /** @hidden */
  26183. readonly _isNode: boolean;
  26184. /**
  26185. * An event triggered when the mesh is disposed
  26186. */
  26187. onDisposeObservable: Observable<Node>;
  26188. private _onDisposeObserver;
  26189. /**
  26190. * Sets a callback that will be raised when the node will be disposed
  26191. */
  26192. onDispose: () => void;
  26193. /**
  26194. * Creates a new Node
  26195. * @param name the name and id to be given to this node
  26196. * @param scene the scene this node will be added to
  26197. * @param addToRootNodes the node will be added to scene.rootNodes
  26198. */
  26199. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26200. /**
  26201. * Gets the scene of the node
  26202. * @returns a scene
  26203. */
  26204. getScene(): Scene;
  26205. /**
  26206. * Gets the engine of the node
  26207. * @returns a Engine
  26208. */
  26209. getEngine(): Engine;
  26210. private _behaviors;
  26211. /**
  26212. * Attach a behavior to the node
  26213. * @see http://doc.babylonjs.com/features/behaviour
  26214. * @param behavior defines the behavior to attach
  26215. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26216. * @returns the current Node
  26217. */
  26218. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26219. /**
  26220. * Remove an attached behavior
  26221. * @see http://doc.babylonjs.com/features/behaviour
  26222. * @param behavior defines the behavior to attach
  26223. * @returns the current Node
  26224. */
  26225. removeBehavior(behavior: Behavior<Node>): Node;
  26226. /**
  26227. * Gets the list of attached behaviors
  26228. * @see http://doc.babylonjs.com/features/behaviour
  26229. */
  26230. readonly behaviors: Behavior<Node>[];
  26231. /**
  26232. * Gets an attached behavior by name
  26233. * @param name defines the name of the behavior to look for
  26234. * @see http://doc.babylonjs.com/features/behaviour
  26235. * @returns null if behavior was not found else the requested behavior
  26236. */
  26237. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26238. /**
  26239. * Returns the latest update of the World matrix
  26240. * @returns a Matrix
  26241. */
  26242. getWorldMatrix(): Matrix;
  26243. /** @hidden */
  26244. _getWorldMatrixDeterminant(): number;
  26245. /**
  26246. * Returns directly the latest state of the mesh World matrix.
  26247. * A Matrix is returned.
  26248. */
  26249. readonly worldMatrixFromCache: Matrix;
  26250. /** @hidden */
  26251. _initCache(): void;
  26252. /** @hidden */
  26253. updateCache(force?: boolean): void;
  26254. /** @hidden */
  26255. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26256. /** @hidden */
  26257. _updateCache(ignoreParentClass?: boolean): void;
  26258. /** @hidden */
  26259. _isSynchronized(): boolean;
  26260. /** @hidden */
  26261. _markSyncedWithParent(): void;
  26262. /** @hidden */
  26263. isSynchronizedWithParent(): boolean;
  26264. /** @hidden */
  26265. isSynchronized(): boolean;
  26266. /**
  26267. * Is this node ready to be used/rendered
  26268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26269. * @return true if the node is ready
  26270. */
  26271. isReady(completeCheck?: boolean): boolean;
  26272. /**
  26273. * Is this node enabled?
  26274. * 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
  26275. * @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
  26276. * @return whether this node (and its parent) is enabled
  26277. */
  26278. isEnabled(checkAncestors?: boolean): boolean;
  26279. /** @hidden */
  26280. protected _syncParentEnabledState(): void;
  26281. /**
  26282. * Set the enabled state of this node
  26283. * @param value defines the new enabled state
  26284. */
  26285. setEnabled(value: boolean): void;
  26286. /**
  26287. * Is this node a descendant of the given node?
  26288. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26289. * @param ancestor defines the parent node to inspect
  26290. * @returns a boolean indicating if this node is a descendant of the given node
  26291. */
  26292. isDescendantOf(ancestor: Node): boolean;
  26293. /** @hidden */
  26294. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26295. /**
  26296. * Will return all nodes that have this node as ascendant
  26297. * @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
  26298. * @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
  26299. * @return all children nodes of all types
  26300. */
  26301. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26302. /**
  26303. * Get all child-meshes of this node
  26304. * @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)
  26305. * @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
  26306. * @returns an array of AbstractMesh
  26307. */
  26308. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26309. /**
  26310. * Get all direct children of this node
  26311. * @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
  26312. * @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)
  26313. * @returns an array of Node
  26314. */
  26315. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26316. /** @hidden */
  26317. _setReady(state: boolean): void;
  26318. /**
  26319. * Get an animation by name
  26320. * @param name defines the name of the animation to look for
  26321. * @returns null if not found else the requested animation
  26322. */
  26323. getAnimationByName(name: string): Nullable<Animation>;
  26324. /**
  26325. * Creates an animation range for this node
  26326. * @param name defines the name of the range
  26327. * @param from defines the starting key
  26328. * @param to defines the end key
  26329. */
  26330. createAnimationRange(name: string, from: number, to: number): void;
  26331. /**
  26332. * Delete a specific animation range
  26333. * @param name defines the name of the range to delete
  26334. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26335. */
  26336. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26337. /**
  26338. * Get an animation range by name
  26339. * @param name defines the name of the animation range to look for
  26340. * @returns null if not found else the requested animation range
  26341. */
  26342. getAnimationRange(name: string): Nullable<AnimationRange>;
  26343. /**
  26344. * Gets the list of all animation ranges defined on this node
  26345. * @returns an array
  26346. */
  26347. getAnimationRanges(): Nullable<AnimationRange>[];
  26348. /**
  26349. * Will start the animation sequence
  26350. * @param name defines the range frames for animation sequence
  26351. * @param loop defines if the animation should loop (false by default)
  26352. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26353. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26354. * @returns the object created for this animation. If range does not exist, it will return null
  26355. */
  26356. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26357. /**
  26358. * Serialize animation ranges into a JSON compatible object
  26359. * @returns serialization object
  26360. */
  26361. serializeAnimationRanges(): any;
  26362. /**
  26363. * Computes the world matrix of the node
  26364. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26365. * @returns the world matrix
  26366. */
  26367. computeWorldMatrix(force?: boolean): Matrix;
  26368. /**
  26369. * Releases resources associated with this node.
  26370. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26371. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26372. */
  26373. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26374. /**
  26375. * Parse animation range data from a serialization object and store them into a given node
  26376. * @param node defines where to store the animation ranges
  26377. * @param parsedNode defines the serialization object to read data from
  26378. * @param scene defines the hosting scene
  26379. */
  26380. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26381. /**
  26382. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26383. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26384. * @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
  26385. * @returns the new bounding vectors
  26386. */
  26387. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26388. min: Vector3;
  26389. max: Vector3;
  26390. };
  26391. }
  26392. }
  26393. declare module "babylonjs/Animations/animation" {
  26394. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26395. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26396. import { Nullable } from "babylonjs/types";
  26397. import { Scene } from "babylonjs/scene";
  26398. import { IAnimatable } from "babylonjs/Misc/tools";
  26399. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26400. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26401. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26402. import { Node } from "babylonjs/node";
  26403. import { Animatable } from "babylonjs/Animations/animatable";
  26404. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26405. /**
  26406. * @hidden
  26407. */
  26408. export class _IAnimationState {
  26409. key: number;
  26410. repeatCount: number;
  26411. workValue?: any;
  26412. loopMode?: number;
  26413. offsetValue?: any;
  26414. highLimitValue?: any;
  26415. }
  26416. /**
  26417. * Class used to store any kind of animation
  26418. */
  26419. export class Animation {
  26420. /**Name of the animation */
  26421. name: string;
  26422. /**Property to animate */
  26423. targetProperty: string;
  26424. /**The frames per second of the animation */
  26425. framePerSecond: number;
  26426. /**The data type of the animation */
  26427. dataType: number;
  26428. /**The loop mode of the animation */
  26429. loopMode?: number | undefined;
  26430. /**Specifies if blending should be enabled */
  26431. enableBlending?: boolean | undefined;
  26432. /**
  26433. * Use matrix interpolation instead of using direct key value when animating matrices
  26434. */
  26435. static AllowMatricesInterpolation: boolean;
  26436. /**
  26437. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26438. */
  26439. static AllowMatrixDecomposeForInterpolation: boolean;
  26440. /**
  26441. * Stores the key frames of the animation
  26442. */
  26443. private _keys;
  26444. /**
  26445. * Stores the easing function of the animation
  26446. */
  26447. private _easingFunction;
  26448. /**
  26449. * @hidden Internal use only
  26450. */
  26451. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26452. /**
  26453. * The set of event that will be linked to this animation
  26454. */
  26455. private _events;
  26456. /**
  26457. * Stores an array of target property paths
  26458. */
  26459. targetPropertyPath: string[];
  26460. /**
  26461. * Stores the blending speed of the animation
  26462. */
  26463. blendingSpeed: number;
  26464. /**
  26465. * Stores the animation ranges for the animation
  26466. */
  26467. private _ranges;
  26468. /**
  26469. * @hidden Internal use
  26470. */
  26471. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26472. /**
  26473. * Sets up an animation
  26474. * @param property The property to animate
  26475. * @param animationType The animation type to apply
  26476. * @param framePerSecond The frames per second of the animation
  26477. * @param easingFunction The easing function used in the animation
  26478. * @returns The created animation
  26479. */
  26480. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26481. /**
  26482. * Create and start an animation on a node
  26483. * @param name defines the name of the global animation that will be run on all nodes
  26484. * @param node defines the root node where the animation will take place
  26485. * @param targetProperty defines property to animate
  26486. * @param framePerSecond defines the number of frame per second yo use
  26487. * @param totalFrame defines the number of frames in total
  26488. * @param from defines the initial value
  26489. * @param to defines the final value
  26490. * @param loopMode defines which loop mode you want to use (off by default)
  26491. * @param easingFunction defines the easing function to use (linear by default)
  26492. * @param onAnimationEnd defines the callback to call when animation end
  26493. * @returns the animatable created for this animation
  26494. */
  26495. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26496. /**
  26497. * Create and start an animation on a node and its descendants
  26498. * @param name defines the name of the global animation that will be run on all nodes
  26499. * @param node defines the root node where the animation will take place
  26500. * @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
  26501. * @param targetProperty defines property to animate
  26502. * @param framePerSecond defines the number of frame per second to use
  26503. * @param totalFrame defines the number of frames in total
  26504. * @param from defines the initial value
  26505. * @param to defines the final value
  26506. * @param loopMode defines which loop mode you want to use (off by default)
  26507. * @param easingFunction defines the easing function to use (linear by default)
  26508. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26509. * @returns the list of animatables created for all nodes
  26510. * @example https://www.babylonjs-playground.com/#MH0VLI
  26511. */
  26512. 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[]>;
  26513. /**
  26514. * Creates a new animation, merges it with the existing animations and starts it
  26515. * @param name Name of the animation
  26516. * @param node Node which contains the scene that begins the animations
  26517. * @param targetProperty Specifies which property to animate
  26518. * @param framePerSecond The frames per second of the animation
  26519. * @param totalFrame The total number of frames
  26520. * @param from The frame at the beginning of the animation
  26521. * @param to The frame at the end of the animation
  26522. * @param loopMode Specifies the loop mode of the animation
  26523. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26524. * @param onAnimationEnd Callback to run once the animation is complete
  26525. * @returns Nullable animation
  26526. */
  26527. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26528. /**
  26529. * Transition property of an host to the target Value
  26530. * @param property The property to transition
  26531. * @param targetValue The target Value of the property
  26532. * @param host The object where the property to animate belongs
  26533. * @param scene Scene used to run the animation
  26534. * @param frameRate Framerate (in frame/s) to use
  26535. * @param transition The transition type we want to use
  26536. * @param duration The duration of the animation, in milliseconds
  26537. * @param onAnimationEnd Callback trigger at the end of the animation
  26538. * @returns Nullable animation
  26539. */
  26540. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26541. /**
  26542. * Return the array of runtime animations currently using this animation
  26543. */
  26544. readonly runtimeAnimations: RuntimeAnimation[];
  26545. /**
  26546. * Specifies if any of the runtime animations are currently running
  26547. */
  26548. readonly hasRunningRuntimeAnimations: boolean;
  26549. /**
  26550. * Initializes the animation
  26551. * @param name Name of the animation
  26552. * @param targetProperty Property to animate
  26553. * @param framePerSecond The frames per second of the animation
  26554. * @param dataType The data type of the animation
  26555. * @param loopMode The loop mode of the animation
  26556. * @param enableBlending Specifies if blending should be enabled
  26557. */
  26558. constructor(
  26559. /**Name of the animation */
  26560. name: string,
  26561. /**Property to animate */
  26562. targetProperty: string,
  26563. /**The frames per second of the animation */
  26564. framePerSecond: number,
  26565. /**The data type of the animation */
  26566. dataType: number,
  26567. /**The loop mode of the animation */
  26568. loopMode?: number | undefined,
  26569. /**Specifies if blending should be enabled */
  26570. enableBlending?: boolean | undefined);
  26571. /**
  26572. * Converts the animation to a string
  26573. * @param fullDetails support for multiple levels of logging within scene loading
  26574. * @returns String form of the animation
  26575. */
  26576. toString(fullDetails?: boolean): string;
  26577. /**
  26578. * Add an event to this animation
  26579. * @param event Event to add
  26580. */
  26581. addEvent(event: AnimationEvent): void;
  26582. /**
  26583. * Remove all events found at the given frame
  26584. * @param frame The frame to remove events from
  26585. */
  26586. removeEvents(frame: number): void;
  26587. /**
  26588. * Retrieves all the events from the animation
  26589. * @returns Events from the animation
  26590. */
  26591. getEvents(): AnimationEvent[];
  26592. /**
  26593. * Creates an animation range
  26594. * @param name Name of the animation range
  26595. * @param from Starting frame of the animation range
  26596. * @param to Ending frame of the animation
  26597. */
  26598. createRange(name: string, from: number, to: number): void;
  26599. /**
  26600. * Deletes an animation range by name
  26601. * @param name Name of the animation range to delete
  26602. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26603. */
  26604. deleteRange(name: string, deleteFrames?: boolean): void;
  26605. /**
  26606. * Gets the animation range by name, or null if not defined
  26607. * @param name Name of the animation range
  26608. * @returns Nullable animation range
  26609. */
  26610. getRange(name: string): Nullable<AnimationRange>;
  26611. /**
  26612. * Gets the key frames from the animation
  26613. * @returns The key frames of the animation
  26614. */
  26615. getKeys(): Array<IAnimationKey>;
  26616. /**
  26617. * Gets the highest frame rate of the animation
  26618. * @returns Highest frame rate of the animation
  26619. */
  26620. getHighestFrame(): number;
  26621. /**
  26622. * Gets the easing function of the animation
  26623. * @returns Easing function of the animation
  26624. */
  26625. getEasingFunction(): IEasingFunction;
  26626. /**
  26627. * Sets the easing function of the animation
  26628. * @param easingFunction A custom mathematical formula for animation
  26629. */
  26630. setEasingFunction(easingFunction: EasingFunction): void;
  26631. /**
  26632. * Interpolates a scalar linearly
  26633. * @param startValue Start value of the animation curve
  26634. * @param endValue End value of the animation curve
  26635. * @param gradient Scalar amount to interpolate
  26636. * @returns Interpolated scalar value
  26637. */
  26638. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26639. /**
  26640. * Interpolates a scalar cubically
  26641. * @param startValue Start value of the animation curve
  26642. * @param outTangent End tangent of the animation
  26643. * @param endValue End value of the animation curve
  26644. * @param inTangent Start tangent of the animation curve
  26645. * @param gradient Scalar amount to interpolate
  26646. * @returns Interpolated scalar value
  26647. */
  26648. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26649. /**
  26650. * Interpolates a quaternion using a spherical linear interpolation
  26651. * @param startValue Start value of the animation curve
  26652. * @param endValue End value of the animation curve
  26653. * @param gradient Scalar amount to interpolate
  26654. * @returns Interpolated quaternion value
  26655. */
  26656. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26657. /**
  26658. * Interpolates a quaternion cubically
  26659. * @param startValue Start value of the animation curve
  26660. * @param outTangent End tangent of the animation curve
  26661. * @param endValue End value of the animation curve
  26662. * @param inTangent Start tangent of the animation curve
  26663. * @param gradient Scalar amount to interpolate
  26664. * @returns Interpolated quaternion value
  26665. */
  26666. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26667. /**
  26668. * Interpolates a Vector3 linearl
  26669. * @param startValue Start value of the animation curve
  26670. * @param endValue End value of the animation curve
  26671. * @param gradient Scalar amount to interpolate
  26672. * @returns Interpolated scalar value
  26673. */
  26674. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26675. /**
  26676. * Interpolates a Vector3 cubically
  26677. * @param startValue Start value of the animation curve
  26678. * @param outTangent End tangent of the animation
  26679. * @param endValue End value of the animation curve
  26680. * @param inTangent Start tangent of the animation curve
  26681. * @param gradient Scalar amount to interpolate
  26682. * @returns InterpolatedVector3 value
  26683. */
  26684. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26685. /**
  26686. * Interpolates a Vector2 linearly
  26687. * @param startValue Start value of the animation curve
  26688. * @param endValue End value of the animation curve
  26689. * @param gradient Scalar amount to interpolate
  26690. * @returns Interpolated Vector2 value
  26691. */
  26692. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26693. /**
  26694. * Interpolates a Vector2 cubically
  26695. * @param startValue Start value of the animation curve
  26696. * @param outTangent End tangent of the animation
  26697. * @param endValue End value of the animation curve
  26698. * @param inTangent Start tangent of the animation curve
  26699. * @param gradient Scalar amount to interpolate
  26700. * @returns Interpolated Vector2 value
  26701. */
  26702. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26703. /**
  26704. * Interpolates a size linearly
  26705. * @param startValue Start value of the animation curve
  26706. * @param endValue End value of the animation curve
  26707. * @param gradient Scalar amount to interpolate
  26708. * @returns Interpolated Size value
  26709. */
  26710. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26711. /**
  26712. * Interpolates a Color3 linearly
  26713. * @param startValue Start value of the animation curve
  26714. * @param endValue End value of the animation curve
  26715. * @param gradient Scalar amount to interpolate
  26716. * @returns Interpolated Color3 value
  26717. */
  26718. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26719. /**
  26720. * @hidden Internal use only
  26721. */
  26722. _getKeyValue(value: any): any;
  26723. /**
  26724. * @hidden Internal use only
  26725. */
  26726. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26727. /**
  26728. * Defines the function to use to interpolate matrices
  26729. * @param startValue defines the start matrix
  26730. * @param endValue defines the end matrix
  26731. * @param gradient defines the gradient between both matrices
  26732. * @param result defines an optional target matrix where to store the interpolation
  26733. * @returns the interpolated matrix
  26734. */
  26735. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26736. /**
  26737. * Makes a copy of the animation
  26738. * @returns Cloned animation
  26739. */
  26740. clone(): Animation;
  26741. /**
  26742. * Sets the key frames of the animation
  26743. * @param values The animation key frames to set
  26744. */
  26745. setKeys(values: Array<IAnimationKey>): void;
  26746. /**
  26747. * Serializes the animation to an object
  26748. * @returns Serialized object
  26749. */
  26750. serialize(): any;
  26751. /**
  26752. * Float animation type
  26753. */
  26754. private static _ANIMATIONTYPE_FLOAT;
  26755. /**
  26756. * Vector3 animation type
  26757. */
  26758. private static _ANIMATIONTYPE_VECTOR3;
  26759. /**
  26760. * Quaternion animation type
  26761. */
  26762. private static _ANIMATIONTYPE_QUATERNION;
  26763. /**
  26764. * Matrix animation type
  26765. */
  26766. private static _ANIMATIONTYPE_MATRIX;
  26767. /**
  26768. * Color3 animation type
  26769. */
  26770. private static _ANIMATIONTYPE_COLOR3;
  26771. /**
  26772. * Vector2 animation type
  26773. */
  26774. private static _ANIMATIONTYPE_VECTOR2;
  26775. /**
  26776. * Size animation type
  26777. */
  26778. private static _ANIMATIONTYPE_SIZE;
  26779. /**
  26780. * Relative Loop Mode
  26781. */
  26782. private static _ANIMATIONLOOPMODE_RELATIVE;
  26783. /**
  26784. * Cycle Loop Mode
  26785. */
  26786. private static _ANIMATIONLOOPMODE_CYCLE;
  26787. /**
  26788. * Constant Loop Mode
  26789. */
  26790. private static _ANIMATIONLOOPMODE_CONSTANT;
  26791. /**
  26792. * Get the float animation type
  26793. */
  26794. static readonly ANIMATIONTYPE_FLOAT: number;
  26795. /**
  26796. * Get the Vector3 animation type
  26797. */
  26798. static readonly ANIMATIONTYPE_VECTOR3: number;
  26799. /**
  26800. * Get the Vector2 animation type
  26801. */
  26802. static readonly ANIMATIONTYPE_VECTOR2: number;
  26803. /**
  26804. * Get the Size animation type
  26805. */
  26806. static readonly ANIMATIONTYPE_SIZE: number;
  26807. /**
  26808. * Get the Quaternion animation type
  26809. */
  26810. static readonly ANIMATIONTYPE_QUATERNION: number;
  26811. /**
  26812. * Get the Matrix animation type
  26813. */
  26814. static readonly ANIMATIONTYPE_MATRIX: number;
  26815. /**
  26816. * Get the Color3 animation type
  26817. */
  26818. static readonly ANIMATIONTYPE_COLOR3: number;
  26819. /**
  26820. * Get the Relative Loop Mode
  26821. */
  26822. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26823. /**
  26824. * Get the Cycle Loop Mode
  26825. */
  26826. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26827. /**
  26828. * Get the Constant Loop Mode
  26829. */
  26830. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26831. /** @hidden */
  26832. static _UniversalLerp(left: any, right: any, amount: number): any;
  26833. /**
  26834. * Parses an animation object and creates an animation
  26835. * @param parsedAnimation Parsed animation object
  26836. * @returns Animation object
  26837. */
  26838. static Parse(parsedAnimation: any): Animation;
  26839. /**
  26840. * Appends the serialized animations from the source animations
  26841. * @param source Source containing the animations
  26842. * @param destination Target to store the animations
  26843. */
  26844. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26845. }
  26846. }
  26847. declare module "babylonjs/Materials/Textures/baseTexture" {
  26848. import { Observable } from "babylonjs/Misc/observable";
  26849. import { IAnimatable } from "babylonjs/Misc/tools";
  26850. import { Nullable } from "babylonjs/types";
  26851. import { Scene } from "babylonjs/scene";
  26852. import { Matrix, ISize } from "babylonjs/Maths/math";
  26853. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26854. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26855. /**
  26856. * Base class of all the textures in babylon.
  26857. * It groups all the common properties the materials, post process, lights... might need
  26858. * in order to make a correct use of the texture.
  26859. */
  26860. export class BaseTexture implements IAnimatable {
  26861. /**
  26862. * Default anisotropic filtering level for the application.
  26863. * It is set to 4 as a good tradeoff between perf and quality.
  26864. */
  26865. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26866. /**
  26867. * Gets or sets the unique id of the texture
  26868. */
  26869. uniqueId: number;
  26870. /**
  26871. * Define the name of the texture.
  26872. */
  26873. name: string;
  26874. /**
  26875. * Gets or sets an object used to store user defined information.
  26876. */
  26877. metadata: any;
  26878. /**
  26879. * For internal use only. Please do not use.
  26880. */
  26881. reservedDataStore: any;
  26882. private _hasAlpha;
  26883. /**
  26884. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26885. */
  26886. hasAlpha: boolean;
  26887. /**
  26888. * Defines if the alpha value should be determined via the rgb values.
  26889. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26890. */
  26891. getAlphaFromRGB: boolean;
  26892. /**
  26893. * Intensity or strength of the texture.
  26894. * It is commonly used by materials to fine tune the intensity of the texture
  26895. */
  26896. level: number;
  26897. /**
  26898. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26899. * This is part of the texture as textures usually maps to one uv set.
  26900. */
  26901. coordinatesIndex: number;
  26902. private _coordinatesMode;
  26903. /**
  26904. * How a texture is mapped.
  26905. *
  26906. * | Value | Type | Description |
  26907. * | ----- | ----------------------------------- | ----------- |
  26908. * | 0 | EXPLICIT_MODE | |
  26909. * | 1 | SPHERICAL_MODE | |
  26910. * | 2 | PLANAR_MODE | |
  26911. * | 3 | CUBIC_MODE | |
  26912. * | 4 | PROJECTION_MODE | |
  26913. * | 5 | SKYBOX_MODE | |
  26914. * | 6 | INVCUBIC_MODE | |
  26915. * | 7 | EQUIRECTANGULAR_MODE | |
  26916. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26917. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26918. */
  26919. coordinatesMode: number;
  26920. /**
  26921. * | Value | Type | Description |
  26922. * | ----- | ------------------ | ----------- |
  26923. * | 0 | CLAMP_ADDRESSMODE | |
  26924. * | 1 | WRAP_ADDRESSMODE | |
  26925. * | 2 | MIRROR_ADDRESSMODE | |
  26926. */
  26927. wrapU: number;
  26928. /**
  26929. * | Value | Type | Description |
  26930. * | ----- | ------------------ | ----------- |
  26931. * | 0 | CLAMP_ADDRESSMODE | |
  26932. * | 1 | WRAP_ADDRESSMODE | |
  26933. * | 2 | MIRROR_ADDRESSMODE | |
  26934. */
  26935. wrapV: number;
  26936. /**
  26937. * | Value | Type | Description |
  26938. * | ----- | ------------------ | ----------- |
  26939. * | 0 | CLAMP_ADDRESSMODE | |
  26940. * | 1 | WRAP_ADDRESSMODE | |
  26941. * | 2 | MIRROR_ADDRESSMODE | |
  26942. */
  26943. wrapR: number;
  26944. /**
  26945. * With compliant hardware and browser (supporting anisotropic filtering)
  26946. * this defines the level of anisotropic filtering in the texture.
  26947. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26948. */
  26949. anisotropicFilteringLevel: number;
  26950. /**
  26951. * Define if the texture is a cube texture or if false a 2d texture.
  26952. */
  26953. isCube: boolean;
  26954. /**
  26955. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26956. */
  26957. is3D: boolean;
  26958. /**
  26959. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26960. * HDR texture are usually stored in linear space.
  26961. * This only impacts the PBR and Background materials
  26962. */
  26963. gammaSpace: boolean;
  26964. /**
  26965. * Gets whether or not the texture contains RGBD data.
  26966. */
  26967. readonly isRGBD: boolean;
  26968. /**
  26969. * Is Z inverted in the texture (useful in a cube texture).
  26970. */
  26971. invertZ: boolean;
  26972. /**
  26973. * Are mip maps generated for this texture or not.
  26974. */
  26975. readonly noMipmap: boolean;
  26976. /**
  26977. * @hidden
  26978. */
  26979. lodLevelInAlpha: boolean;
  26980. /**
  26981. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26982. */
  26983. lodGenerationOffset: number;
  26984. /**
  26985. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26986. */
  26987. lodGenerationScale: number;
  26988. /**
  26989. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  26990. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  26991. * average roughness values.
  26992. */
  26993. linearSpecularLOD: boolean;
  26994. /**
  26995. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  26996. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  26997. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  26998. */
  26999. irradianceTexture: Nullable<BaseTexture>;
  27000. /**
  27001. * Define if the texture is a render target.
  27002. */
  27003. isRenderTarget: boolean;
  27004. /**
  27005. * Define the unique id of the texture in the scene.
  27006. */
  27007. readonly uid: string;
  27008. /**
  27009. * Return a string representation of the texture.
  27010. * @returns the texture as a string
  27011. */
  27012. toString(): string;
  27013. /**
  27014. * Get the class name of the texture.
  27015. * @returns "BaseTexture"
  27016. */
  27017. getClassName(): string;
  27018. /**
  27019. * Define the list of animation attached to the texture.
  27020. */
  27021. animations: import("babylonjs/Animations/animation").Animation[];
  27022. /**
  27023. * An event triggered when the texture is disposed.
  27024. */
  27025. onDisposeObservable: Observable<BaseTexture>;
  27026. private _onDisposeObserver;
  27027. /**
  27028. * Callback triggered when the texture has been disposed.
  27029. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27030. */
  27031. onDispose: () => void;
  27032. /**
  27033. * Define the current state of the loading sequence when in delayed load mode.
  27034. */
  27035. delayLoadState: number;
  27036. private _scene;
  27037. /** @hidden */
  27038. _texture: Nullable<InternalTexture>;
  27039. private _uid;
  27040. /**
  27041. * Define if the texture is preventinga material to render or not.
  27042. * If not and the texture is not ready, the engine will use a default black texture instead.
  27043. */
  27044. readonly isBlocking: boolean;
  27045. /**
  27046. * Instantiates a new BaseTexture.
  27047. * Base class of all the textures in babylon.
  27048. * It groups all the common properties the materials, post process, lights... might need
  27049. * in order to make a correct use of the texture.
  27050. * @param scene Define the scene the texture blongs to
  27051. */
  27052. constructor(scene: Nullable<Scene>);
  27053. /**
  27054. * Get the scene the texture belongs to.
  27055. * @returns the scene or null if undefined
  27056. */
  27057. getScene(): Nullable<Scene>;
  27058. /**
  27059. * Get the texture transform matrix used to offset tile the texture for istance.
  27060. * @returns the transformation matrix
  27061. */
  27062. getTextureMatrix(): Matrix;
  27063. /**
  27064. * Get the texture reflection matrix used to rotate/transform the reflection.
  27065. * @returns the reflection matrix
  27066. */
  27067. getReflectionTextureMatrix(): Matrix;
  27068. /**
  27069. * Get the underlying lower level texture from Babylon.
  27070. * @returns the insternal texture
  27071. */
  27072. getInternalTexture(): Nullable<InternalTexture>;
  27073. /**
  27074. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27075. * @returns true if ready or not blocking
  27076. */
  27077. isReadyOrNotBlocking(): boolean;
  27078. /**
  27079. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27080. * @returns true if fully ready
  27081. */
  27082. isReady(): boolean;
  27083. private _cachedSize;
  27084. /**
  27085. * Get the size of the texture.
  27086. * @returns the texture size.
  27087. */
  27088. getSize(): ISize;
  27089. /**
  27090. * Get the base size of the texture.
  27091. * It can be different from the size if the texture has been resized for POT for instance
  27092. * @returns the base size
  27093. */
  27094. getBaseSize(): ISize;
  27095. /**
  27096. * Update the sampling mode of the texture.
  27097. * Default is Trilinear mode.
  27098. *
  27099. * | Value | Type | Description |
  27100. * | ----- | ------------------ | ----------- |
  27101. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27102. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27103. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27104. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27105. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27106. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27107. * | 7 | NEAREST_LINEAR | |
  27108. * | 8 | NEAREST_NEAREST | |
  27109. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27110. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27111. * | 11 | LINEAR_LINEAR | |
  27112. * | 12 | LINEAR_NEAREST | |
  27113. *
  27114. * > _mag_: magnification filter (close to the viewer)
  27115. * > _min_: minification filter (far from the viewer)
  27116. * > _mip_: filter used between mip map levels
  27117. *@param samplingMode Define the new sampling mode of the texture
  27118. */
  27119. updateSamplingMode(samplingMode: number): void;
  27120. /**
  27121. * Scales the texture if is `canRescale()`
  27122. * @param ratio the resize factor we want to use to rescale
  27123. */
  27124. scale(ratio: number): void;
  27125. /**
  27126. * Get if the texture can rescale.
  27127. */
  27128. readonly canRescale: boolean;
  27129. /** @hidden */
  27130. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27131. /** @hidden */
  27132. _rebuild(): void;
  27133. /**
  27134. * Triggers the load sequence in delayed load mode.
  27135. */
  27136. delayLoad(): void;
  27137. /**
  27138. * Clones the texture.
  27139. * @returns the cloned texture
  27140. */
  27141. clone(): Nullable<BaseTexture>;
  27142. /**
  27143. * Get the texture underlying type (INT, FLOAT...)
  27144. */
  27145. readonly textureType: number;
  27146. /**
  27147. * Get the texture underlying format (RGB, RGBA...)
  27148. */
  27149. readonly textureFormat: number;
  27150. /**
  27151. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27152. * This will returns an RGBA array buffer containing either in values (0-255) or
  27153. * float values (0-1) depending of the underlying buffer type.
  27154. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27155. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27156. * @param buffer defines a user defined buffer to fill with data (can be null)
  27157. * @returns The Array buffer containing the pixels data.
  27158. */
  27159. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27160. /**
  27161. * Release and destroy the underlying lower level texture aka internalTexture.
  27162. */
  27163. releaseInternalTexture(): void;
  27164. /**
  27165. * Get the polynomial representation of the texture data.
  27166. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27167. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27168. */
  27169. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27170. /** @hidden */
  27171. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27172. /** @hidden */
  27173. readonly _lodTextureMid: Nullable<BaseTexture>;
  27174. /** @hidden */
  27175. readonly _lodTextureLow: Nullable<BaseTexture>;
  27176. /**
  27177. * Dispose the texture and release its associated resources.
  27178. */
  27179. dispose(): void;
  27180. /**
  27181. * Serialize the texture into a JSON representation that can be parsed later on.
  27182. * @returns the JSON representation of the texture
  27183. */
  27184. serialize(): any;
  27185. /**
  27186. * Helper function to be called back once a list of texture contains only ready textures.
  27187. * @param textures Define the list of textures to wait for
  27188. * @param callback Define the callback triggered once the entire list will be ready
  27189. */
  27190. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27191. }
  27192. }
  27193. declare module "babylonjs/Materials/uniformBuffer" {
  27194. import { Nullable, FloatArray } from "babylonjs/types";
  27195. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27196. import { Engine } from "babylonjs/Engines/engine";
  27197. import { Effect } from "babylonjs/Materials/effect";
  27198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27200. /**
  27201. * Uniform buffer objects.
  27202. *
  27203. * Handles blocks of uniform on the GPU.
  27204. *
  27205. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27206. *
  27207. * For more information, please refer to :
  27208. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27209. */
  27210. export class UniformBuffer {
  27211. private _engine;
  27212. private _buffer;
  27213. private _data;
  27214. private _bufferData;
  27215. private _dynamic?;
  27216. private _uniformLocations;
  27217. private _uniformSizes;
  27218. private _uniformLocationPointer;
  27219. private _needSync;
  27220. private _noUBO;
  27221. private _currentEffect;
  27222. private static _MAX_UNIFORM_SIZE;
  27223. private static _tempBuffer;
  27224. /**
  27225. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27226. * This is dynamic to allow compat with webgl 1 and 2.
  27227. * You will need to pass the name of the uniform as well as the value.
  27228. */
  27229. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27230. /**
  27231. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27232. * This is dynamic to allow compat with webgl 1 and 2.
  27233. * You will need to pass the name of the uniform as well as the value.
  27234. */
  27235. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27236. /**
  27237. * Lambda to Update a single float in a uniform buffer.
  27238. * This is dynamic to allow compat with webgl 1 and 2.
  27239. * You will need to pass the name of the uniform as well as the value.
  27240. */
  27241. updateFloat: (name: string, x: number) => void;
  27242. /**
  27243. * Lambda to Update a vec2 of float in a uniform buffer.
  27244. * This is dynamic to allow compat with webgl 1 and 2.
  27245. * You will need to pass the name of the uniform as well as the value.
  27246. */
  27247. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27248. /**
  27249. * Lambda to Update a vec3 of float in a uniform buffer.
  27250. * This is dynamic to allow compat with webgl 1 and 2.
  27251. * You will need to pass the name of the uniform as well as the value.
  27252. */
  27253. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27254. /**
  27255. * Lambda to Update a vec4 of float in a uniform buffer.
  27256. * This is dynamic to allow compat with webgl 1 and 2.
  27257. * You will need to pass the name of the uniform as well as the value.
  27258. */
  27259. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27260. /**
  27261. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27262. * This is dynamic to allow compat with webgl 1 and 2.
  27263. * You will need to pass the name of the uniform as well as the value.
  27264. */
  27265. updateMatrix: (name: string, mat: Matrix) => void;
  27266. /**
  27267. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27268. * This is dynamic to allow compat with webgl 1 and 2.
  27269. * You will need to pass the name of the uniform as well as the value.
  27270. */
  27271. updateVector3: (name: string, vector: Vector3) => void;
  27272. /**
  27273. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27274. * This is dynamic to allow compat with webgl 1 and 2.
  27275. * You will need to pass the name of the uniform as well as the value.
  27276. */
  27277. updateVector4: (name: string, vector: Vector4) => void;
  27278. /**
  27279. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27280. * This is dynamic to allow compat with webgl 1 and 2.
  27281. * You will need to pass the name of the uniform as well as the value.
  27282. */
  27283. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27284. /**
  27285. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27286. * This is dynamic to allow compat with webgl 1 and 2.
  27287. * You will need to pass the name of the uniform as well as the value.
  27288. */
  27289. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27290. /**
  27291. * Instantiates a new Uniform buffer objects.
  27292. *
  27293. * Handles blocks of uniform on the GPU.
  27294. *
  27295. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27296. *
  27297. * For more information, please refer to :
  27298. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27299. * @param engine Define the engine the buffer is associated with
  27300. * @param data Define the data contained in the buffer
  27301. * @param dynamic Define if the buffer is updatable
  27302. */
  27303. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27304. /**
  27305. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27306. * or just falling back on setUniformXXX calls.
  27307. */
  27308. readonly useUbo: boolean;
  27309. /**
  27310. * Indicates if the WebGL underlying uniform buffer is in sync
  27311. * with the javascript cache data.
  27312. */
  27313. readonly isSync: boolean;
  27314. /**
  27315. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27316. * Also, a dynamic UniformBuffer will disable cache verification and always
  27317. * update the underlying WebGL uniform buffer to the GPU.
  27318. * @returns if Dynamic, otherwise false
  27319. */
  27320. isDynamic(): boolean;
  27321. /**
  27322. * The data cache on JS side.
  27323. * @returns the underlying data as a float array
  27324. */
  27325. getData(): Float32Array;
  27326. /**
  27327. * The underlying WebGL Uniform buffer.
  27328. * @returns the webgl buffer
  27329. */
  27330. getBuffer(): Nullable<DataBuffer>;
  27331. /**
  27332. * std140 layout specifies how to align data within an UBO structure.
  27333. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27334. * for specs.
  27335. */
  27336. private _fillAlignment;
  27337. /**
  27338. * Adds an uniform in the buffer.
  27339. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27340. * for the layout to be correct !
  27341. * @param name Name of the uniform, as used in the uniform block in the shader.
  27342. * @param size Data size, or data directly.
  27343. */
  27344. addUniform(name: string, size: number | number[]): void;
  27345. /**
  27346. * Adds a Matrix 4x4 to the uniform buffer.
  27347. * @param name Name of the uniform, as used in the uniform block in the shader.
  27348. * @param mat A 4x4 matrix.
  27349. */
  27350. addMatrix(name: string, mat: Matrix): void;
  27351. /**
  27352. * Adds a vec2 to the uniform buffer.
  27353. * @param name Name of the uniform, as used in the uniform block in the shader.
  27354. * @param x Define the x component value of the vec2
  27355. * @param y Define the y component value of the vec2
  27356. */
  27357. addFloat2(name: string, x: number, y: number): void;
  27358. /**
  27359. * Adds a vec3 to the uniform buffer.
  27360. * @param name Name of the uniform, as used in the uniform block in the shader.
  27361. * @param x Define the x component value of the vec3
  27362. * @param y Define the y component value of the vec3
  27363. * @param z Define the z component value of the vec3
  27364. */
  27365. addFloat3(name: string, x: number, y: number, z: number): void;
  27366. /**
  27367. * Adds a vec3 to the uniform buffer.
  27368. * @param name Name of the uniform, as used in the uniform block in the shader.
  27369. * @param color Define the vec3 from a Color
  27370. */
  27371. addColor3(name: string, color: Color3): void;
  27372. /**
  27373. * Adds a vec4 to the uniform buffer.
  27374. * @param name Name of the uniform, as used in the uniform block in the shader.
  27375. * @param color Define the rgb components from a Color
  27376. * @param alpha Define the a component of the vec4
  27377. */
  27378. addColor4(name: string, color: Color3, alpha: number): void;
  27379. /**
  27380. * Adds a vec3 to the uniform buffer.
  27381. * @param name Name of the uniform, as used in the uniform block in the shader.
  27382. * @param vector Define the vec3 components from a Vector
  27383. */
  27384. addVector3(name: string, vector: Vector3): void;
  27385. /**
  27386. * Adds a Matrix 3x3 to the uniform buffer.
  27387. * @param name Name of the uniform, as used in the uniform block in the shader.
  27388. */
  27389. addMatrix3x3(name: string): void;
  27390. /**
  27391. * Adds a Matrix 2x2 to the uniform buffer.
  27392. * @param name Name of the uniform, as used in the uniform block in the shader.
  27393. */
  27394. addMatrix2x2(name: string): void;
  27395. /**
  27396. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27397. */
  27398. create(): void;
  27399. /** @hidden */
  27400. _rebuild(): void;
  27401. /**
  27402. * Updates the WebGL Uniform Buffer on the GPU.
  27403. * If the `dynamic` flag is set to true, no cache comparison is done.
  27404. * Otherwise, the buffer will be updated only if the cache differs.
  27405. */
  27406. update(): void;
  27407. /**
  27408. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27409. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27410. * @param data Define the flattened data
  27411. * @param size Define the size of the data.
  27412. */
  27413. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27414. private _updateMatrix3x3ForUniform;
  27415. private _updateMatrix3x3ForEffect;
  27416. private _updateMatrix2x2ForEffect;
  27417. private _updateMatrix2x2ForUniform;
  27418. private _updateFloatForEffect;
  27419. private _updateFloatForUniform;
  27420. private _updateFloat2ForEffect;
  27421. private _updateFloat2ForUniform;
  27422. private _updateFloat3ForEffect;
  27423. private _updateFloat3ForUniform;
  27424. private _updateFloat4ForEffect;
  27425. private _updateFloat4ForUniform;
  27426. private _updateMatrixForEffect;
  27427. private _updateMatrixForUniform;
  27428. private _updateVector3ForEffect;
  27429. private _updateVector3ForUniform;
  27430. private _updateVector4ForEffect;
  27431. private _updateVector4ForUniform;
  27432. private _updateColor3ForEffect;
  27433. private _updateColor3ForUniform;
  27434. private _updateColor4ForEffect;
  27435. private _updateColor4ForUniform;
  27436. /**
  27437. * Sets a sampler uniform on the effect.
  27438. * @param name Define the name of the sampler.
  27439. * @param texture Define the texture to set in the sampler
  27440. */
  27441. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27442. /**
  27443. * Directly updates the value of the uniform in the cache AND on the GPU.
  27444. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27445. * @param data Define the flattened data
  27446. */
  27447. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27448. /**
  27449. * Binds this uniform buffer to an effect.
  27450. * @param effect Define the effect to bind the buffer to
  27451. * @param name Name of the uniform block in the shader.
  27452. */
  27453. bindToEffect(effect: Effect, name: string): void;
  27454. /**
  27455. * Disposes the uniform buffer.
  27456. */
  27457. dispose(): void;
  27458. }
  27459. }
  27460. declare module "babylonjs/Audio/analyser" {
  27461. import { Scene } from "babylonjs/scene";
  27462. /**
  27463. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27465. */
  27466. export class Analyser {
  27467. /**
  27468. * Gets or sets the smoothing
  27469. * @ignorenaming
  27470. */
  27471. SMOOTHING: number;
  27472. /**
  27473. * Gets or sets the FFT table size
  27474. * @ignorenaming
  27475. */
  27476. FFT_SIZE: number;
  27477. /**
  27478. * Gets or sets the bar graph amplitude
  27479. * @ignorenaming
  27480. */
  27481. BARGRAPHAMPLITUDE: number;
  27482. /**
  27483. * Gets or sets the position of the debug canvas
  27484. * @ignorenaming
  27485. */
  27486. DEBUGCANVASPOS: {
  27487. x: number;
  27488. y: number;
  27489. };
  27490. /**
  27491. * Gets or sets the debug canvas size
  27492. * @ignorenaming
  27493. */
  27494. DEBUGCANVASSIZE: {
  27495. width: number;
  27496. height: number;
  27497. };
  27498. private _byteFreqs;
  27499. private _byteTime;
  27500. private _floatFreqs;
  27501. private _webAudioAnalyser;
  27502. private _debugCanvas;
  27503. private _debugCanvasContext;
  27504. private _scene;
  27505. private _registerFunc;
  27506. private _audioEngine;
  27507. /**
  27508. * Creates a new analyser
  27509. * @param scene defines hosting scene
  27510. */
  27511. constructor(scene: Scene);
  27512. /**
  27513. * Get the number of data values you will have to play with for the visualization
  27514. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27515. * @returns a number
  27516. */
  27517. getFrequencyBinCount(): number;
  27518. /**
  27519. * Gets the current frequency data as a byte array
  27520. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27521. * @returns a Uint8Array
  27522. */
  27523. getByteFrequencyData(): Uint8Array;
  27524. /**
  27525. * Gets the current waveform as a byte array
  27526. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27527. * @returns a Uint8Array
  27528. */
  27529. getByteTimeDomainData(): Uint8Array;
  27530. /**
  27531. * Gets the current frequency data as a float array
  27532. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27533. * @returns a Float32Array
  27534. */
  27535. getFloatFrequencyData(): Float32Array;
  27536. /**
  27537. * Renders the debug canvas
  27538. */
  27539. drawDebugCanvas(): void;
  27540. /**
  27541. * Stops rendering the debug canvas and removes it
  27542. */
  27543. stopDebugCanvas(): void;
  27544. /**
  27545. * Connects two audio nodes
  27546. * @param inputAudioNode defines first node to connect
  27547. * @param outputAudioNode defines second node to connect
  27548. */
  27549. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27550. /**
  27551. * Releases all associated resources
  27552. */
  27553. dispose(): void;
  27554. }
  27555. }
  27556. declare module "babylonjs/Audio/audioEngine" {
  27557. import { IDisposable } from "babylonjs/scene";
  27558. import { Analyser } from "babylonjs/Audio/analyser";
  27559. import { Nullable } from "babylonjs/types";
  27560. import { Observable } from "babylonjs/Misc/observable";
  27561. /**
  27562. * This represents an audio engine and it is responsible
  27563. * to play, synchronize and analyse sounds throughout the application.
  27564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27565. */
  27566. export interface IAudioEngine extends IDisposable {
  27567. /**
  27568. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27569. */
  27570. readonly canUseWebAudio: boolean;
  27571. /**
  27572. * Gets the current AudioContext if available.
  27573. */
  27574. readonly audioContext: Nullable<AudioContext>;
  27575. /**
  27576. * The master gain node defines the global audio volume of your audio engine.
  27577. */
  27578. readonly masterGain: GainNode;
  27579. /**
  27580. * Gets whether or not mp3 are supported by your browser.
  27581. */
  27582. readonly isMP3supported: boolean;
  27583. /**
  27584. * Gets whether or not ogg are supported by your browser.
  27585. */
  27586. readonly isOGGsupported: boolean;
  27587. /**
  27588. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27589. * @ignoreNaming
  27590. */
  27591. WarnedWebAudioUnsupported: boolean;
  27592. /**
  27593. * Defines if the audio engine relies on a custom unlocked button.
  27594. * In this case, the embedded button will not be displayed.
  27595. */
  27596. useCustomUnlockedButton: boolean;
  27597. /**
  27598. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27599. */
  27600. readonly unlocked: boolean;
  27601. /**
  27602. * Event raised when audio has been unlocked on the browser.
  27603. */
  27604. onAudioUnlockedObservable: Observable<AudioEngine>;
  27605. /**
  27606. * Event raised when audio has been locked on the browser.
  27607. */
  27608. onAudioLockedObservable: Observable<AudioEngine>;
  27609. /**
  27610. * Flags the audio engine in Locked state.
  27611. * This happens due to new browser policies preventing audio to autoplay.
  27612. */
  27613. lock(): void;
  27614. /**
  27615. * Unlocks the audio engine once a user action has been done on the dom.
  27616. * This is helpful to resume play once browser policies have been satisfied.
  27617. */
  27618. unlock(): void;
  27619. }
  27620. /**
  27621. * This represents the default audio engine used in babylon.
  27622. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27624. */
  27625. export class AudioEngine implements IAudioEngine {
  27626. private _audioContext;
  27627. private _audioContextInitialized;
  27628. private _muteButton;
  27629. private _hostElement;
  27630. /**
  27631. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27632. */
  27633. canUseWebAudio: boolean;
  27634. /**
  27635. * The master gain node defines the global audio volume of your audio engine.
  27636. */
  27637. masterGain: GainNode;
  27638. /**
  27639. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27640. * @ignoreNaming
  27641. */
  27642. WarnedWebAudioUnsupported: boolean;
  27643. /**
  27644. * Gets whether or not mp3 are supported by your browser.
  27645. */
  27646. isMP3supported: boolean;
  27647. /**
  27648. * Gets whether or not ogg are supported by your browser.
  27649. */
  27650. isOGGsupported: boolean;
  27651. /**
  27652. * Gets whether audio has been unlocked on the device.
  27653. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27654. * a user interaction has happened.
  27655. */
  27656. unlocked: boolean;
  27657. /**
  27658. * Defines if the audio engine relies on a custom unlocked button.
  27659. * In this case, the embedded button will not be displayed.
  27660. */
  27661. useCustomUnlockedButton: boolean;
  27662. /**
  27663. * Event raised when audio has been unlocked on the browser.
  27664. */
  27665. onAudioUnlockedObservable: Observable<AudioEngine>;
  27666. /**
  27667. * Event raised when audio has been locked on the browser.
  27668. */
  27669. onAudioLockedObservable: Observable<AudioEngine>;
  27670. /**
  27671. * Gets the current AudioContext if available.
  27672. */
  27673. readonly audioContext: Nullable<AudioContext>;
  27674. private _connectedAnalyser;
  27675. /**
  27676. * Instantiates a new audio engine.
  27677. *
  27678. * There should be only one per page as some browsers restrict the number
  27679. * of audio contexts you can create.
  27680. * @param hostElement defines the host element where to display the mute icon if necessary
  27681. */
  27682. constructor(hostElement?: Nullable<HTMLElement>);
  27683. /**
  27684. * Flags the audio engine in Locked state.
  27685. * This happens due to new browser policies preventing audio to autoplay.
  27686. */
  27687. lock(): void;
  27688. /**
  27689. * Unlocks the audio engine once a user action has been done on the dom.
  27690. * This is helpful to resume play once browser policies have been satisfied.
  27691. */
  27692. unlock(): void;
  27693. private _resumeAudioContext;
  27694. private _initializeAudioContext;
  27695. private _tryToRun;
  27696. private _triggerRunningState;
  27697. private _triggerSuspendedState;
  27698. private _displayMuteButton;
  27699. private _moveButtonToTopLeft;
  27700. private _onResize;
  27701. private _hideMuteButton;
  27702. /**
  27703. * Destroy and release the resources associated with the audio ccontext.
  27704. */
  27705. dispose(): void;
  27706. /**
  27707. * Gets the global volume sets on the master gain.
  27708. * @returns the global volume if set or -1 otherwise
  27709. */
  27710. getGlobalVolume(): number;
  27711. /**
  27712. * Sets the global volume of your experience (sets on the master gain).
  27713. * @param newVolume Defines the new global volume of the application
  27714. */
  27715. setGlobalVolume(newVolume: number): void;
  27716. /**
  27717. * Connect the audio engine to an audio analyser allowing some amazing
  27718. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27720. * @param analyser The analyser to connect to the engine
  27721. */
  27722. connectToAnalyser(analyser: Analyser): void;
  27723. }
  27724. }
  27725. declare module "babylonjs/Loading/loadingScreen" {
  27726. /**
  27727. * Interface used to present a loading screen while loading a scene
  27728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27729. */
  27730. export interface ILoadingScreen {
  27731. /**
  27732. * Function called to display the loading screen
  27733. */
  27734. displayLoadingUI: () => void;
  27735. /**
  27736. * Function called to hide the loading screen
  27737. */
  27738. hideLoadingUI: () => void;
  27739. /**
  27740. * Gets or sets the color to use for the background
  27741. */
  27742. loadingUIBackgroundColor: string;
  27743. /**
  27744. * Gets or sets the text to display while loading
  27745. */
  27746. loadingUIText: string;
  27747. }
  27748. /**
  27749. * Class used for the default loading screen
  27750. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27751. */
  27752. export class DefaultLoadingScreen implements ILoadingScreen {
  27753. private _renderingCanvas;
  27754. private _loadingText;
  27755. private _loadingDivBackgroundColor;
  27756. private _loadingDiv;
  27757. private _loadingTextDiv;
  27758. /** Gets or sets the logo url to use for the default loading screen */
  27759. static DefaultLogoUrl: string;
  27760. /** Gets or sets the spinner url to use for the default loading screen */
  27761. static DefaultSpinnerUrl: string;
  27762. /**
  27763. * Creates a new default loading screen
  27764. * @param _renderingCanvas defines the canvas used to render the scene
  27765. * @param _loadingText defines the default text to display
  27766. * @param _loadingDivBackgroundColor defines the default background color
  27767. */
  27768. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27769. /**
  27770. * Function called to display the loading screen
  27771. */
  27772. displayLoadingUI(): void;
  27773. /**
  27774. * Function called to hide the loading screen
  27775. */
  27776. hideLoadingUI(): void;
  27777. /**
  27778. * Gets or sets the text to display while loading
  27779. */
  27780. loadingUIText: string;
  27781. /**
  27782. * Gets or sets the color to use for the background
  27783. */
  27784. loadingUIBackgroundColor: string;
  27785. private _resizeLoadingUI;
  27786. }
  27787. }
  27788. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27789. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27790. import { Engine } from "babylonjs/Engines/engine";
  27791. import { Nullable } from "babylonjs/types";
  27792. /** @hidden */
  27793. export class WebGLPipelineContext implements IPipelineContext {
  27794. engine: Engine;
  27795. program: Nullable<WebGLProgram>;
  27796. context?: WebGLRenderingContext;
  27797. vertexShader?: WebGLShader;
  27798. fragmentShader?: WebGLShader;
  27799. isParallelCompiled: boolean;
  27800. onCompiled?: () => void;
  27801. transformFeedback?: WebGLTransformFeedback | null;
  27802. readonly isAsync: boolean;
  27803. readonly isReady: boolean;
  27804. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27805. }
  27806. }
  27807. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27808. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27809. /** @hidden */
  27810. export class WebGLDataBuffer extends DataBuffer {
  27811. private _buffer;
  27812. constructor(resource: WebGLBuffer);
  27813. readonly underlyingResource: any;
  27814. }
  27815. }
  27816. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27817. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27818. /** @hidden */
  27819. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27820. attributeProcessor(attribute: string): string;
  27821. varyingProcessor(varying: string, isFragment: boolean): string;
  27822. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27823. }
  27824. }
  27825. declare module "babylonjs/Materials/Textures/videoTexture" {
  27826. import { Observable } from "babylonjs/Misc/observable";
  27827. import { Nullable } from "babylonjs/types";
  27828. import { Scene } from "babylonjs/scene";
  27829. import { Texture } from "babylonjs/Materials/Textures/texture";
  27830. /**
  27831. * Settings for finer control over video usage
  27832. */
  27833. export interface VideoTextureSettings {
  27834. /**
  27835. * Applies `autoplay` to video, if specified
  27836. */
  27837. autoPlay?: boolean;
  27838. /**
  27839. * Applies `loop` to video, if specified
  27840. */
  27841. loop?: boolean;
  27842. /**
  27843. * Automatically updates internal texture from video at every frame in the render loop
  27844. */
  27845. autoUpdateTexture: boolean;
  27846. /**
  27847. * Image src displayed during the video loading or until the user interacts with the video.
  27848. */
  27849. poster?: string;
  27850. }
  27851. /**
  27852. * If you want to display a video in your scene, this is the special texture for that.
  27853. * This special texture works similar to other textures, with the exception of a few parameters.
  27854. * @see https://doc.babylonjs.com/how_to/video_texture
  27855. */
  27856. export class VideoTexture extends Texture {
  27857. /**
  27858. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27859. */
  27860. readonly autoUpdateTexture: boolean;
  27861. /**
  27862. * The video instance used by the texture internally
  27863. */
  27864. readonly video: HTMLVideoElement;
  27865. private _onUserActionRequestedObservable;
  27866. /**
  27867. * Event triggerd when a dom action is required by the user to play the video.
  27868. * This happens due to recent changes in browser policies preventing video to auto start.
  27869. */
  27870. readonly onUserActionRequestedObservable: Observable<Texture>;
  27871. private _generateMipMaps;
  27872. private _engine;
  27873. private _stillImageCaptured;
  27874. private _displayingPosterTexture;
  27875. private _settings;
  27876. private _createInternalTextureOnEvent;
  27877. /**
  27878. * Creates a video texture.
  27879. * If you want to display a video in your scene, this is the special texture for that.
  27880. * This special texture works similar to other textures, with the exception of a few parameters.
  27881. * @see https://doc.babylonjs.com/how_to/video_texture
  27882. * @param name optional name, will detect from video source, if not defined
  27883. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27884. * @param scene is obviously the current scene.
  27885. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27886. * @param invertY is false by default but can be used to invert video on Y axis
  27887. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27888. * @param settings allows finer control over video usage
  27889. */
  27890. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27891. private _getName;
  27892. private _getVideo;
  27893. private _createInternalTexture;
  27894. private reset;
  27895. /**
  27896. * @hidden Internal method to initiate `update`.
  27897. */
  27898. _rebuild(): void;
  27899. /**
  27900. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27901. */
  27902. update(): void;
  27903. /**
  27904. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27905. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27906. */
  27907. updateTexture(isVisible: boolean): void;
  27908. protected _updateInternalTexture: () => void;
  27909. /**
  27910. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27911. * @param url New url.
  27912. */
  27913. updateURL(url: string): void;
  27914. /**
  27915. * Dispose the texture and release its associated resources.
  27916. */
  27917. dispose(): void;
  27918. /**
  27919. * Creates a video texture straight from a stream.
  27920. * @param scene Define the scene the texture should be created in
  27921. * @param stream Define the stream the texture should be created from
  27922. * @returns The created video texture as a promise
  27923. */
  27924. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27925. /**
  27926. * Creates a video texture straight from your WebCam video feed.
  27927. * @param scene Define the scene the texture should be created in
  27928. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27929. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27930. * @returns The created video texture as a promise
  27931. */
  27932. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27933. minWidth: number;
  27934. maxWidth: number;
  27935. minHeight: number;
  27936. maxHeight: number;
  27937. deviceId: string;
  27938. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27939. /**
  27940. * Creates a video texture straight from your WebCam video feed.
  27941. * @param scene Define the scene the texture should be created in
  27942. * @param onReady Define a callback to triggered once the texture will be ready
  27943. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27944. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27945. */
  27946. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27947. minWidth: number;
  27948. maxWidth: number;
  27949. minHeight: number;
  27950. maxHeight: number;
  27951. deviceId: string;
  27952. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27953. }
  27954. }
  27955. declare module "babylonjs/Engines/engine" {
  27956. import { Observable } from "babylonjs/Misc/observable";
  27957. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27958. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27959. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27960. import { Camera } from "babylonjs/Cameras/camera";
  27961. import { Scene } from "babylonjs/scene";
  27962. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27963. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27964. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27965. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27966. import { Material } from "babylonjs/Materials/material";
  27967. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27970. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27971. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27972. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27973. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27974. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27975. import { WebRequest } from "babylonjs/Misc/webRequest";
  27976. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27977. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27978. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27979. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27980. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27982. /**
  27983. * Interface for attribute information associated with buffer instanciation
  27984. */
  27985. export class InstancingAttributeInfo {
  27986. /**
  27987. * Index/offset of the attribute in the vertex shader
  27988. */
  27989. index: number;
  27990. /**
  27991. * size of the attribute, 1, 2, 3 or 4
  27992. */
  27993. attributeSize: number;
  27994. /**
  27995. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27996. * default is FLOAT
  27997. */
  27998. attribyteType: number;
  27999. /**
  28000. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28001. */
  28002. normalized: boolean;
  28003. /**
  28004. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28005. */
  28006. offset: number;
  28007. /**
  28008. * Name of the GLSL attribute, for debugging purpose only
  28009. */
  28010. attributeName: string;
  28011. }
  28012. /**
  28013. * Define options used to create a depth texture
  28014. */
  28015. export class DepthTextureCreationOptions {
  28016. /** Specifies whether or not a stencil should be allocated in the texture */
  28017. generateStencil?: boolean;
  28018. /** Specifies whether or not bilinear filtering is enable on the texture */
  28019. bilinearFiltering?: boolean;
  28020. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28021. comparisonFunction?: number;
  28022. /** Specifies if the created texture is a cube texture */
  28023. isCube?: boolean;
  28024. }
  28025. /**
  28026. * Class used to describe the capabilities of the engine relatively to the current browser
  28027. */
  28028. export class EngineCapabilities {
  28029. /** Maximum textures units per fragment shader */
  28030. maxTexturesImageUnits: number;
  28031. /** Maximum texture units per vertex shader */
  28032. maxVertexTextureImageUnits: number;
  28033. /** Maximum textures units in the entire pipeline */
  28034. maxCombinedTexturesImageUnits: number;
  28035. /** Maximum texture size */
  28036. maxTextureSize: number;
  28037. /** Maximum cube texture size */
  28038. maxCubemapTextureSize: number;
  28039. /** Maximum render texture size */
  28040. maxRenderTextureSize: number;
  28041. /** Maximum number of vertex attributes */
  28042. maxVertexAttribs: number;
  28043. /** Maximum number of varyings */
  28044. maxVaryingVectors: number;
  28045. /** Maximum number of uniforms per vertex shader */
  28046. maxVertexUniformVectors: number;
  28047. /** Maximum number of uniforms per fragment shader */
  28048. maxFragmentUniformVectors: number;
  28049. /** Defines if standard derivates (dx/dy) are supported */
  28050. standardDerivatives: boolean;
  28051. /** Defines if s3tc texture compression is supported */
  28052. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28053. /** Defines if pvrtc texture compression is supported */
  28054. pvrtc: any;
  28055. /** Defines if etc1 texture compression is supported */
  28056. etc1: any;
  28057. /** Defines if etc2 texture compression is supported */
  28058. etc2: any;
  28059. /** Defines if astc texture compression is supported */
  28060. astc: any;
  28061. /** Defines if float textures are supported */
  28062. textureFloat: boolean;
  28063. /** Defines if vertex array objects are supported */
  28064. vertexArrayObject: boolean;
  28065. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28066. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28067. /** Gets the maximum level of anisotropy supported */
  28068. maxAnisotropy: number;
  28069. /** Defines if instancing is supported */
  28070. instancedArrays: boolean;
  28071. /** Defines if 32 bits indices are supported */
  28072. uintIndices: boolean;
  28073. /** Defines if high precision shaders are supported */
  28074. highPrecisionShaderSupported: boolean;
  28075. /** Defines if depth reading in the fragment shader is supported */
  28076. fragmentDepthSupported: boolean;
  28077. /** Defines if float texture linear filtering is supported*/
  28078. textureFloatLinearFiltering: boolean;
  28079. /** Defines if rendering to float textures is supported */
  28080. textureFloatRender: boolean;
  28081. /** Defines if half float textures are supported*/
  28082. textureHalfFloat: boolean;
  28083. /** Defines if half float texture linear filtering is supported*/
  28084. textureHalfFloatLinearFiltering: boolean;
  28085. /** Defines if rendering to half float textures is supported */
  28086. textureHalfFloatRender: boolean;
  28087. /** Defines if textureLOD shader command is supported */
  28088. textureLOD: boolean;
  28089. /** Defines if draw buffers extension is supported */
  28090. drawBuffersExtension: boolean;
  28091. /** Defines if depth textures are supported */
  28092. depthTextureExtension: boolean;
  28093. /** Defines if float color buffer are supported */
  28094. colorBufferFloat: boolean;
  28095. /** Gets disjoint timer query extension (null if not supported) */
  28096. timerQuery: EXT_disjoint_timer_query;
  28097. /** Defines if timestamp can be used with timer query */
  28098. canUseTimestampForTimerQuery: boolean;
  28099. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28100. multiview: any;
  28101. /** Function used to let the system compiles shaders in background */
  28102. parallelShaderCompile: {
  28103. COMPLETION_STATUS_KHR: number;
  28104. };
  28105. }
  28106. /** Interface defining initialization parameters for Engine class */
  28107. export interface EngineOptions extends WebGLContextAttributes {
  28108. /**
  28109. * Defines if the engine should no exceed a specified device ratio
  28110. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28111. */
  28112. limitDeviceRatio?: number;
  28113. /**
  28114. * Defines if webvr should be enabled automatically
  28115. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28116. */
  28117. autoEnableWebVR?: boolean;
  28118. /**
  28119. * Defines if webgl2 should be turned off even if supported
  28120. * @see http://doc.babylonjs.com/features/webgl2
  28121. */
  28122. disableWebGL2Support?: boolean;
  28123. /**
  28124. * Defines if webaudio should be initialized as well
  28125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28126. */
  28127. audioEngine?: boolean;
  28128. /**
  28129. * Defines if animations should run using a deterministic lock step
  28130. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28131. */
  28132. deterministicLockstep?: boolean;
  28133. /** Defines the maximum steps to use with deterministic lock step mode */
  28134. lockstepMaxSteps?: number;
  28135. /**
  28136. * Defines that engine should ignore context lost events
  28137. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28138. */
  28139. doNotHandleContextLost?: boolean;
  28140. /**
  28141. * Defines that engine should ignore modifying touch action attribute and style
  28142. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28143. */
  28144. doNotHandleTouchAction?: boolean;
  28145. /**
  28146. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28147. */
  28148. useHighPrecisionFloats?: boolean;
  28149. }
  28150. /**
  28151. * Defines the interface used by display changed events
  28152. */
  28153. export interface IDisplayChangedEventArgs {
  28154. /** Gets the vrDisplay object (if any) */
  28155. vrDisplay: Nullable<any>;
  28156. /** Gets a boolean indicating if webVR is supported */
  28157. vrSupported: boolean;
  28158. }
  28159. /**
  28160. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28161. */
  28162. export class Engine {
  28163. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28164. static ExceptionList: ({
  28165. key: string;
  28166. capture: string;
  28167. captureConstraint: number;
  28168. targets: string[];
  28169. } | {
  28170. key: string;
  28171. capture: null;
  28172. captureConstraint: null;
  28173. targets: string[];
  28174. })[];
  28175. /** Gets the list of created engines */
  28176. static readonly Instances: Engine[];
  28177. /**
  28178. * Gets the latest created engine
  28179. */
  28180. static readonly LastCreatedEngine: Nullable<Engine>;
  28181. /**
  28182. * Gets the latest created scene
  28183. */
  28184. static readonly LastCreatedScene: Nullable<Scene>;
  28185. /**
  28186. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28187. * @param flag defines which part of the materials must be marked as dirty
  28188. * @param predicate defines a predicate used to filter which materials should be affected
  28189. */
  28190. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28191. /** @hidden */
  28192. static _TextureLoaders: IInternalTextureLoader[];
  28193. /** Defines that alpha blending is disabled */
  28194. static readonly ALPHA_DISABLE: number;
  28195. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28196. static readonly ALPHA_ADD: number;
  28197. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28198. static readonly ALPHA_COMBINE: number;
  28199. /** Defines that alpha blending to DEST - SRC * DEST */
  28200. static readonly ALPHA_SUBTRACT: number;
  28201. /** Defines that alpha blending to SRC * DEST */
  28202. static readonly ALPHA_MULTIPLY: number;
  28203. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28204. static readonly ALPHA_MAXIMIZED: number;
  28205. /** Defines that alpha blending to SRC + DEST */
  28206. static readonly ALPHA_ONEONE: number;
  28207. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28208. static readonly ALPHA_PREMULTIPLIED: number;
  28209. /**
  28210. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28211. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28212. */
  28213. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28214. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28215. static readonly ALPHA_INTERPOLATE: number;
  28216. /**
  28217. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28218. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28219. */
  28220. static readonly ALPHA_SCREENMODE: number;
  28221. /** Defines that the ressource is not delayed*/
  28222. static readonly DELAYLOADSTATE_NONE: number;
  28223. /** Defines that the ressource was successfully delay loaded */
  28224. static readonly DELAYLOADSTATE_LOADED: number;
  28225. /** Defines that the ressource is currently delay loading */
  28226. static readonly DELAYLOADSTATE_LOADING: number;
  28227. /** Defines that the ressource is delayed and has not started loading */
  28228. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28229. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28230. static readonly NEVER: number;
  28231. /** 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 */
  28232. static readonly ALWAYS: number;
  28233. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28234. static readonly LESS: number;
  28235. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28236. static readonly EQUAL: number;
  28237. /** 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 */
  28238. static readonly LEQUAL: number;
  28239. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28240. static readonly GREATER: number;
  28241. /** 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 */
  28242. static readonly GEQUAL: number;
  28243. /** 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 */
  28244. static readonly NOTEQUAL: number;
  28245. /** Passed to stencilOperation to specify that stencil value must be kept */
  28246. static readonly KEEP: number;
  28247. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28248. static readonly REPLACE: number;
  28249. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28250. static readonly INCR: number;
  28251. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28252. static readonly DECR: number;
  28253. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28254. static readonly INVERT: number;
  28255. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28256. static readonly INCR_WRAP: number;
  28257. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28258. static readonly DECR_WRAP: number;
  28259. /** Texture is not repeating outside of 0..1 UVs */
  28260. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28261. /** Texture is repeating outside of 0..1 UVs */
  28262. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28263. /** Texture is repeating and mirrored */
  28264. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28265. /** ALPHA */
  28266. static readonly TEXTUREFORMAT_ALPHA: number;
  28267. /** LUMINANCE */
  28268. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28269. /** LUMINANCE_ALPHA */
  28270. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28271. /** RGB */
  28272. static readonly TEXTUREFORMAT_RGB: number;
  28273. /** RGBA */
  28274. static readonly TEXTUREFORMAT_RGBA: number;
  28275. /** RED */
  28276. static readonly TEXTUREFORMAT_RED: number;
  28277. /** RED (2nd reference) */
  28278. static readonly TEXTUREFORMAT_R: number;
  28279. /** RG */
  28280. static readonly TEXTUREFORMAT_RG: number;
  28281. /** RED_INTEGER */
  28282. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28283. /** RED_INTEGER (2nd reference) */
  28284. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28285. /** RG_INTEGER */
  28286. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28287. /** RGB_INTEGER */
  28288. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28289. /** RGBA_INTEGER */
  28290. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28291. /** UNSIGNED_BYTE */
  28292. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28293. /** UNSIGNED_BYTE (2nd reference) */
  28294. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28295. /** FLOAT */
  28296. static readonly TEXTURETYPE_FLOAT: number;
  28297. /** HALF_FLOAT */
  28298. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28299. /** BYTE */
  28300. static readonly TEXTURETYPE_BYTE: number;
  28301. /** SHORT */
  28302. static readonly TEXTURETYPE_SHORT: number;
  28303. /** UNSIGNED_SHORT */
  28304. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28305. /** INT */
  28306. static readonly TEXTURETYPE_INT: number;
  28307. /** UNSIGNED_INT */
  28308. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28309. /** UNSIGNED_SHORT_4_4_4_4 */
  28310. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28311. /** UNSIGNED_SHORT_5_5_5_1 */
  28312. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28313. /** UNSIGNED_SHORT_5_6_5 */
  28314. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28315. /** UNSIGNED_INT_2_10_10_10_REV */
  28316. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28317. /** UNSIGNED_INT_24_8 */
  28318. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28319. /** UNSIGNED_INT_10F_11F_11F_REV */
  28320. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28321. /** UNSIGNED_INT_5_9_9_9_REV */
  28322. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28323. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28324. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28325. /** nearest is mag = nearest and min = nearest and mip = linear */
  28326. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28327. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28328. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28329. /** Trilinear is mag = linear and min = linear and mip = linear */
  28330. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28331. /** nearest is mag = nearest and min = nearest and mip = linear */
  28332. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28333. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28334. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28335. /** Trilinear is mag = linear and min = linear and mip = linear */
  28336. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28337. /** mag = nearest and min = nearest and mip = nearest */
  28338. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28339. /** mag = nearest and min = linear and mip = nearest */
  28340. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28341. /** mag = nearest and min = linear and mip = linear */
  28342. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28343. /** mag = nearest and min = linear and mip = none */
  28344. static readonly TEXTURE_NEAREST_LINEAR: number;
  28345. /** mag = nearest and min = nearest and mip = none */
  28346. static readonly TEXTURE_NEAREST_NEAREST: number;
  28347. /** mag = linear and min = nearest and mip = nearest */
  28348. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28349. /** mag = linear and min = nearest and mip = linear */
  28350. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28351. /** mag = linear and min = linear and mip = none */
  28352. static readonly TEXTURE_LINEAR_LINEAR: number;
  28353. /** mag = linear and min = nearest and mip = none */
  28354. static readonly TEXTURE_LINEAR_NEAREST: number;
  28355. /** Explicit coordinates mode */
  28356. static readonly TEXTURE_EXPLICIT_MODE: number;
  28357. /** Spherical coordinates mode */
  28358. static readonly TEXTURE_SPHERICAL_MODE: number;
  28359. /** Planar coordinates mode */
  28360. static readonly TEXTURE_PLANAR_MODE: number;
  28361. /** Cubic coordinates mode */
  28362. static readonly TEXTURE_CUBIC_MODE: number;
  28363. /** Projection coordinates mode */
  28364. static readonly TEXTURE_PROJECTION_MODE: number;
  28365. /** Skybox coordinates mode */
  28366. static readonly TEXTURE_SKYBOX_MODE: number;
  28367. /** Inverse Cubic coordinates mode */
  28368. static readonly TEXTURE_INVCUBIC_MODE: number;
  28369. /** Equirectangular coordinates mode */
  28370. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28371. /** Equirectangular Fixed coordinates mode */
  28372. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28373. /** Equirectangular Fixed Mirrored coordinates mode */
  28374. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28375. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28376. static readonly SCALEMODE_FLOOR: number;
  28377. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28378. static readonly SCALEMODE_NEAREST: number;
  28379. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28380. static readonly SCALEMODE_CEILING: number;
  28381. /**
  28382. * Returns the current npm package of the sdk
  28383. */
  28384. static readonly NpmPackage: string;
  28385. /**
  28386. * Returns the current version of the framework
  28387. */
  28388. static readonly Version: string;
  28389. /**
  28390. * Returns a string describing the current engine
  28391. */
  28392. readonly description: string;
  28393. /**
  28394. * Gets or sets the epsilon value used by collision engine
  28395. */
  28396. static CollisionsEpsilon: number;
  28397. /**
  28398. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28399. */
  28400. static ShadersRepository: string;
  28401. /**
  28402. * Method called to create the default loading screen.
  28403. * This can be overriden in your own app.
  28404. * @param canvas The rendering canvas element
  28405. * @returns The loading screen
  28406. */
  28407. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28408. /**
  28409. * Method called to create the default rescale post process on each engine.
  28410. */
  28411. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28412. /** @hidden */
  28413. _shaderProcessor: IShaderProcessor;
  28414. /**
  28415. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28416. */
  28417. forcePOTTextures: boolean;
  28418. /**
  28419. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28420. */
  28421. isFullscreen: boolean;
  28422. /**
  28423. * Gets a boolean indicating if the pointer is currently locked
  28424. */
  28425. isPointerLock: boolean;
  28426. /**
  28427. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28428. */
  28429. cullBackFaces: boolean;
  28430. /**
  28431. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28432. */
  28433. renderEvenInBackground: boolean;
  28434. /**
  28435. * Gets or sets a boolean indicating that cache can be kept between frames
  28436. */
  28437. preventCacheWipeBetweenFrames: boolean;
  28438. /**
  28439. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28440. **/
  28441. enableOfflineSupport: boolean;
  28442. /**
  28443. * 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)
  28444. **/
  28445. disableManifestCheck: boolean;
  28446. /**
  28447. * Gets the list of created scenes
  28448. */
  28449. scenes: Scene[];
  28450. /**
  28451. * Event raised when a new scene is created
  28452. */
  28453. onNewSceneAddedObservable: Observable<Scene>;
  28454. /**
  28455. * Gets the list of created postprocesses
  28456. */
  28457. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28458. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28459. validateShaderPrograms: boolean;
  28460. /**
  28461. * Observable event triggered each time the rendering canvas is resized
  28462. */
  28463. onResizeObservable: Observable<Engine>;
  28464. /**
  28465. * Observable event triggered each time the canvas loses focus
  28466. */
  28467. onCanvasBlurObservable: Observable<Engine>;
  28468. /**
  28469. * Observable event triggered each time the canvas gains focus
  28470. */
  28471. onCanvasFocusObservable: Observable<Engine>;
  28472. /**
  28473. * Observable event triggered each time the canvas receives pointerout event
  28474. */
  28475. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28476. /**
  28477. * Observable event triggered before each texture is initialized
  28478. */
  28479. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28480. /**
  28481. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28482. */
  28483. disableUniformBuffers: boolean;
  28484. /** @hidden */
  28485. _uniformBuffers: UniformBuffer[];
  28486. /**
  28487. * Gets a boolean indicating that the engine supports uniform buffers
  28488. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28489. */
  28490. readonly supportsUniformBuffers: boolean;
  28491. /**
  28492. * Observable raised when the engine begins a new frame
  28493. */
  28494. onBeginFrameObservable: Observable<Engine>;
  28495. /**
  28496. * If set, will be used to request the next animation frame for the render loop
  28497. */
  28498. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28499. /**
  28500. * Observable raised when the engine ends the current frame
  28501. */
  28502. onEndFrameObservable: Observable<Engine>;
  28503. /**
  28504. * Observable raised when the engine is about to compile a shader
  28505. */
  28506. onBeforeShaderCompilationObservable: Observable<Engine>;
  28507. /**
  28508. * Observable raised when the engine has jsut compiled a shader
  28509. */
  28510. onAfterShaderCompilationObservable: Observable<Engine>;
  28511. /** @hidden */
  28512. _gl: WebGLRenderingContext;
  28513. private _renderingCanvas;
  28514. private _windowIsBackground;
  28515. private _webGLVersion;
  28516. protected _highPrecisionShadersAllowed: boolean;
  28517. /** @hidden */
  28518. readonly _shouldUseHighPrecisionShader: boolean;
  28519. /**
  28520. * Gets a boolean indicating that only power of 2 textures are supported
  28521. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28522. */
  28523. readonly needPOTTextures: boolean;
  28524. /** @hidden */
  28525. _badOS: boolean;
  28526. /** @hidden */
  28527. _badDesktopOS: boolean;
  28528. /**
  28529. * Gets the audio engine
  28530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28531. * @ignorenaming
  28532. */
  28533. static audioEngine: IAudioEngine;
  28534. /**
  28535. * Default AudioEngine factory responsible of creating the Audio Engine.
  28536. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28537. */
  28538. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28539. /**
  28540. * Default offline support factory responsible of creating a tool used to store data locally.
  28541. * By default, this will create a Database object if the workload has been embedded.
  28542. */
  28543. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28544. private _onFocus;
  28545. private _onBlur;
  28546. private _onCanvasPointerOut;
  28547. private _onCanvasBlur;
  28548. private _onCanvasFocus;
  28549. private _onFullscreenChange;
  28550. private _onPointerLockChange;
  28551. private _hardwareScalingLevel;
  28552. /** @hidden */
  28553. _caps: EngineCapabilities;
  28554. private _pointerLockRequested;
  28555. private _isStencilEnable;
  28556. private _colorWrite;
  28557. private _loadingScreen;
  28558. /** @hidden */
  28559. _drawCalls: PerfCounter;
  28560. private _glVersion;
  28561. private _glRenderer;
  28562. private _glVendor;
  28563. private _videoTextureSupported;
  28564. private _renderingQueueLaunched;
  28565. private _activeRenderLoops;
  28566. private _deterministicLockstep;
  28567. private _lockstepMaxSteps;
  28568. /**
  28569. * Observable signaled when a context lost event is raised
  28570. */
  28571. onContextLostObservable: Observable<Engine>;
  28572. /**
  28573. * Observable signaled when a context restored event is raised
  28574. */
  28575. onContextRestoredObservable: Observable<Engine>;
  28576. private _onContextLost;
  28577. private _onContextRestored;
  28578. private _contextWasLost;
  28579. /** @hidden */
  28580. _doNotHandleContextLost: boolean;
  28581. /**
  28582. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28583. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28584. */
  28585. doNotHandleContextLost: boolean;
  28586. private _performanceMonitor;
  28587. private _fps;
  28588. private _deltaTime;
  28589. /**
  28590. * Turn this value on if you want to pause FPS computation when in background
  28591. */
  28592. disablePerformanceMonitorInBackground: boolean;
  28593. /**
  28594. * Gets the performance monitor attached to this engine
  28595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28596. */
  28597. readonly performanceMonitor: PerformanceMonitor;
  28598. /**
  28599. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28600. */
  28601. disableVertexArrayObjects: boolean;
  28602. /** @hidden */
  28603. protected _depthCullingState: _DepthCullingState;
  28604. /** @hidden */
  28605. protected _stencilState: _StencilState;
  28606. /** @hidden */
  28607. protected _alphaState: _AlphaState;
  28608. /** @hidden */
  28609. protected _alphaMode: number;
  28610. /** @hidden */
  28611. _internalTexturesCache: InternalTexture[];
  28612. /** @hidden */
  28613. protected _activeChannel: number;
  28614. private _currentTextureChannel;
  28615. /** @hidden */
  28616. protected _boundTexturesCache: {
  28617. [key: string]: Nullable<InternalTexture>;
  28618. };
  28619. /** @hidden */
  28620. protected _currentEffect: Nullable<Effect>;
  28621. /** @hidden */
  28622. protected _currentProgram: Nullable<WebGLProgram>;
  28623. private _compiledEffects;
  28624. private _vertexAttribArraysEnabled;
  28625. /** @hidden */
  28626. protected _cachedViewport: Nullable<Viewport>;
  28627. private _cachedVertexArrayObject;
  28628. /** @hidden */
  28629. protected _cachedVertexBuffers: any;
  28630. /** @hidden */
  28631. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28632. /** @hidden */
  28633. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28634. /** @hidden */
  28635. _currentRenderTarget: Nullable<InternalTexture>;
  28636. private _uintIndicesCurrentlySet;
  28637. private _currentBoundBuffer;
  28638. /** @hidden */
  28639. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28640. private _currentBufferPointers;
  28641. private _currentInstanceLocations;
  28642. private _currentInstanceBuffers;
  28643. private _textureUnits;
  28644. /** @hidden */
  28645. _workingCanvas: Nullable<HTMLCanvasElement>;
  28646. /** @hidden */
  28647. _workingContext: Nullable<CanvasRenderingContext2D>;
  28648. private _rescalePostProcess;
  28649. private _dummyFramebuffer;
  28650. private _externalData;
  28651. /** @hidden */
  28652. _bindedRenderFunction: any;
  28653. private _vaoRecordInProgress;
  28654. private _mustWipeVertexAttributes;
  28655. private _emptyTexture;
  28656. private _emptyCubeTexture;
  28657. private _emptyTexture3D;
  28658. /** @hidden */
  28659. _frameHandler: number;
  28660. private _nextFreeTextureSlots;
  28661. private _maxSimultaneousTextures;
  28662. private _activeRequests;
  28663. private _texturesSupported;
  28664. /** @hidden */
  28665. _textureFormatInUse: Nullable<string>;
  28666. /**
  28667. * Gets the list of texture formats supported
  28668. */
  28669. readonly texturesSupported: Array<string>;
  28670. /**
  28671. * Gets the list of texture formats in use
  28672. */
  28673. readonly textureFormatInUse: Nullable<string>;
  28674. /**
  28675. * Gets the current viewport
  28676. */
  28677. readonly currentViewport: Nullable<Viewport>;
  28678. /**
  28679. * Gets the default empty texture
  28680. */
  28681. readonly emptyTexture: InternalTexture;
  28682. /**
  28683. * Gets the default empty 3D texture
  28684. */
  28685. readonly emptyTexture3D: InternalTexture;
  28686. /**
  28687. * Gets the default empty cube texture
  28688. */
  28689. readonly emptyCubeTexture: InternalTexture;
  28690. /**
  28691. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28692. */
  28693. readonly premultipliedAlpha: boolean;
  28694. /**
  28695. * Creates a new engine
  28696. * @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
  28697. * @param antialias defines enable antialiasing (default: false)
  28698. * @param options defines further options to be sent to the getContext() function
  28699. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28700. */
  28701. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28702. /**
  28703. * Initializes a webVR display and starts listening to display change events
  28704. * The onVRDisplayChangedObservable will be notified upon these changes
  28705. * @returns The onVRDisplayChangedObservable
  28706. */
  28707. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28708. /** @hidden */
  28709. _prepareVRComponent(): void;
  28710. /** @hidden */
  28711. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28712. /** @hidden */
  28713. _submitVRFrame(): void;
  28714. /**
  28715. * Call this function to leave webVR mode
  28716. * Will do nothing if webVR is not supported or if there is no webVR device
  28717. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28718. */
  28719. disableVR(): void;
  28720. /**
  28721. * Gets a boolean indicating that the system is in VR mode and is presenting
  28722. * @returns true if VR mode is engaged
  28723. */
  28724. isVRPresenting(): boolean;
  28725. /** @hidden */
  28726. _requestVRFrame(): void;
  28727. private _disableTouchAction;
  28728. private _rebuildInternalTextures;
  28729. private _rebuildEffects;
  28730. /**
  28731. * Gets a boolean indicating if all created effects are ready
  28732. * @returns true if all effects are ready
  28733. */
  28734. areAllEffectsReady(): boolean;
  28735. private _rebuildBuffers;
  28736. private _initGLContext;
  28737. /**
  28738. * Gets version of the current webGL context
  28739. */
  28740. readonly webGLVersion: number;
  28741. /**
  28742. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28743. */
  28744. readonly isStencilEnable: boolean;
  28745. /** @hidden */
  28746. _prepareWorkingCanvas(): void;
  28747. /**
  28748. * Reset the texture cache to empty state
  28749. */
  28750. resetTextureCache(): void;
  28751. /**
  28752. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28754. * @returns true if engine is in deterministic lock step mode
  28755. */
  28756. isDeterministicLockStep(): boolean;
  28757. /**
  28758. * Gets the max steps when engine is running in deterministic lock step
  28759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28760. * @returns the max steps
  28761. */
  28762. getLockstepMaxSteps(): number;
  28763. /**
  28764. * Gets an object containing information about the current webGL context
  28765. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28766. */
  28767. getGlInfo(): {
  28768. vendor: string;
  28769. renderer: string;
  28770. version: string;
  28771. };
  28772. /**
  28773. * Gets current aspect ratio
  28774. * @param camera defines the camera to use to get the aspect ratio
  28775. * @param useScreen defines if screen size must be used (or the current render target if any)
  28776. * @returns a number defining the aspect ratio
  28777. */
  28778. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28779. /**
  28780. * Gets current screen aspect ratio
  28781. * @returns a number defining the aspect ratio
  28782. */
  28783. getScreenAspectRatio(): number;
  28784. /**
  28785. * Gets the current render width
  28786. * @param useScreen defines if screen size must be used (or the current render target if any)
  28787. * @returns a number defining the current render width
  28788. */
  28789. getRenderWidth(useScreen?: boolean): number;
  28790. /**
  28791. * Gets the current render height
  28792. * @param useScreen defines if screen size must be used (or the current render target if any)
  28793. * @returns a number defining the current render height
  28794. */
  28795. getRenderHeight(useScreen?: boolean): number;
  28796. /**
  28797. * Gets the HTML canvas attached with the current webGL context
  28798. * @returns a HTML canvas
  28799. */
  28800. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28801. /**
  28802. * Gets the client rect of the HTML canvas attached with the current webGL context
  28803. * @returns a client rectanglee
  28804. */
  28805. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28806. /**
  28807. * Defines the hardware scaling level.
  28808. * By default the hardware scaling level is computed from the window device ratio.
  28809. * 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.
  28810. * @param level defines the level to use
  28811. */
  28812. setHardwareScalingLevel(level: number): void;
  28813. /**
  28814. * Gets the current hardware scaling level.
  28815. * By default the hardware scaling level is computed from the window device ratio.
  28816. * 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.
  28817. * @returns a number indicating the current hardware scaling level
  28818. */
  28819. getHardwareScalingLevel(): number;
  28820. /**
  28821. * Gets the list of loaded textures
  28822. * @returns an array containing all loaded textures
  28823. */
  28824. getLoadedTexturesCache(): InternalTexture[];
  28825. /**
  28826. * Gets the object containing all engine capabilities
  28827. * @returns the EngineCapabilities object
  28828. */
  28829. getCaps(): EngineCapabilities;
  28830. /**
  28831. * Gets the current depth function
  28832. * @returns a number defining the depth function
  28833. */
  28834. getDepthFunction(): Nullable<number>;
  28835. /**
  28836. * Sets the current depth function
  28837. * @param depthFunc defines the function to use
  28838. */
  28839. setDepthFunction(depthFunc: number): void;
  28840. /**
  28841. * Sets the current depth function to GREATER
  28842. */
  28843. setDepthFunctionToGreater(): void;
  28844. /**
  28845. * Sets the current depth function to GEQUAL
  28846. */
  28847. setDepthFunctionToGreaterOrEqual(): void;
  28848. /**
  28849. * Sets the current depth function to LESS
  28850. */
  28851. setDepthFunctionToLess(): void;
  28852. private _cachedStencilBuffer;
  28853. private _cachedStencilFunction;
  28854. private _cachedStencilMask;
  28855. private _cachedStencilOperationPass;
  28856. private _cachedStencilOperationFail;
  28857. private _cachedStencilOperationDepthFail;
  28858. private _cachedStencilReference;
  28859. /**
  28860. * Caches the the state of the stencil buffer
  28861. */
  28862. cacheStencilState(): void;
  28863. /**
  28864. * Restores the state of the stencil buffer
  28865. */
  28866. restoreStencilState(): void;
  28867. /**
  28868. * Sets the current depth function to LEQUAL
  28869. */
  28870. setDepthFunctionToLessOrEqual(): void;
  28871. /**
  28872. * Gets a boolean indicating if stencil buffer is enabled
  28873. * @returns the current stencil buffer state
  28874. */
  28875. getStencilBuffer(): boolean;
  28876. /**
  28877. * Enable or disable the stencil buffer
  28878. * @param enable defines if the stencil buffer must be enabled or disabled
  28879. */
  28880. setStencilBuffer(enable: boolean): void;
  28881. /**
  28882. * Gets the current stencil mask
  28883. * @returns a number defining the new stencil mask to use
  28884. */
  28885. getStencilMask(): number;
  28886. /**
  28887. * Sets the current stencil mask
  28888. * @param mask defines the new stencil mask to use
  28889. */
  28890. setStencilMask(mask: number): void;
  28891. /**
  28892. * Gets the current stencil function
  28893. * @returns a number defining the stencil function to use
  28894. */
  28895. getStencilFunction(): number;
  28896. /**
  28897. * Gets the current stencil reference value
  28898. * @returns a number defining the stencil reference value to use
  28899. */
  28900. getStencilFunctionReference(): number;
  28901. /**
  28902. * Gets the current stencil mask
  28903. * @returns a number defining the stencil mask to use
  28904. */
  28905. getStencilFunctionMask(): number;
  28906. /**
  28907. * Sets the current stencil function
  28908. * @param stencilFunc defines the new stencil function to use
  28909. */
  28910. setStencilFunction(stencilFunc: number): void;
  28911. /**
  28912. * Sets the current stencil reference
  28913. * @param reference defines the new stencil reference to use
  28914. */
  28915. setStencilFunctionReference(reference: number): void;
  28916. /**
  28917. * Sets the current stencil mask
  28918. * @param mask defines the new stencil mask to use
  28919. */
  28920. setStencilFunctionMask(mask: number): void;
  28921. /**
  28922. * Gets the current stencil operation when stencil fails
  28923. * @returns a number defining stencil operation to use when stencil fails
  28924. */
  28925. getStencilOperationFail(): number;
  28926. /**
  28927. * Gets the current stencil operation when depth fails
  28928. * @returns a number defining stencil operation to use when depth fails
  28929. */
  28930. getStencilOperationDepthFail(): number;
  28931. /**
  28932. * Gets the current stencil operation when stencil passes
  28933. * @returns a number defining stencil operation to use when stencil passes
  28934. */
  28935. getStencilOperationPass(): number;
  28936. /**
  28937. * Sets the stencil operation to use when stencil fails
  28938. * @param operation defines the stencil operation to use when stencil fails
  28939. */
  28940. setStencilOperationFail(operation: number): void;
  28941. /**
  28942. * Sets the stencil operation to use when depth fails
  28943. * @param operation defines the stencil operation to use when depth fails
  28944. */
  28945. setStencilOperationDepthFail(operation: number): void;
  28946. /**
  28947. * Sets the stencil operation to use when stencil passes
  28948. * @param operation defines the stencil operation to use when stencil passes
  28949. */
  28950. setStencilOperationPass(operation: number): void;
  28951. /**
  28952. * Sets a boolean indicating if the dithering state is enabled or disabled
  28953. * @param value defines the dithering state
  28954. */
  28955. setDitheringState(value: boolean): void;
  28956. /**
  28957. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28958. * @param value defines the rasterizer state
  28959. */
  28960. setRasterizerState(value: boolean): void;
  28961. /**
  28962. * stop executing a render loop function and remove it from the execution array
  28963. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28964. */
  28965. stopRenderLoop(renderFunction?: () => void): void;
  28966. /** @hidden */
  28967. _renderLoop(): void;
  28968. /**
  28969. * Register and execute a render loop. The engine can have more than one render function
  28970. * @param renderFunction defines the function to continuously execute
  28971. */
  28972. runRenderLoop(renderFunction: () => void): void;
  28973. /**
  28974. * Toggle full screen mode
  28975. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28976. */
  28977. switchFullscreen(requestPointerLock: boolean): void;
  28978. /**
  28979. * Enters full screen mode
  28980. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28981. */
  28982. enterFullscreen(requestPointerLock: boolean): void;
  28983. /**
  28984. * Exits full screen mode
  28985. */
  28986. exitFullscreen(): void;
  28987. /**
  28988. * Enters Pointerlock mode
  28989. */
  28990. enterPointerlock(): void;
  28991. /**
  28992. * Exits Pointerlock mode
  28993. */
  28994. exitPointerlock(): void;
  28995. /**
  28996. * Clear the current render buffer or the current render target (if any is set up)
  28997. * @param color defines the color to use
  28998. * @param backBuffer defines if the back buffer must be cleared
  28999. * @param depth defines if the depth buffer must be cleared
  29000. * @param stencil defines if the stencil buffer must be cleared
  29001. */
  29002. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29003. /**
  29004. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29005. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29006. * @param y defines the y-coordinate of the corner of the clear rectangle
  29007. * @param width defines the width of the clear rectangle
  29008. * @param height defines the height of the clear rectangle
  29009. * @param clearColor defines the clear color
  29010. */
  29011. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29012. /**
  29013. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29014. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29015. * @param y defines the y-coordinate of the corner of the clear rectangle
  29016. * @param width defines the width of the clear rectangle
  29017. * @param height defines the height of the clear rectangle
  29018. */
  29019. enableScissor(x: number, y: number, width: number, height: number): void;
  29020. /**
  29021. * Disable previously set scissor test rectangle
  29022. */
  29023. disableScissor(): void;
  29024. private _viewportCached;
  29025. /** @hidden */
  29026. _viewport(x: number, y: number, width: number, height: number): void;
  29027. /**
  29028. * Set the WebGL's viewport
  29029. * @param viewport defines the viewport element to be used
  29030. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29031. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29032. */
  29033. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29034. /**
  29035. * Directly set the WebGL Viewport
  29036. * @param x defines the x coordinate of the viewport (in screen space)
  29037. * @param y defines the y coordinate of the viewport (in screen space)
  29038. * @param width defines the width of the viewport (in screen space)
  29039. * @param height defines the height of the viewport (in screen space)
  29040. * @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
  29041. */
  29042. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29043. /**
  29044. * Begin a new frame
  29045. */
  29046. beginFrame(): void;
  29047. /**
  29048. * Enf the current frame
  29049. */
  29050. endFrame(): void;
  29051. /**
  29052. * Resize the view according to the canvas' size
  29053. */
  29054. resize(): void;
  29055. /**
  29056. * Force a specific size of the canvas
  29057. * @param width defines the new canvas' width
  29058. * @param height defines the new canvas' height
  29059. */
  29060. setSize(width: number, height: number): void;
  29061. /**
  29062. * Binds the frame buffer to the specified texture.
  29063. * @param texture The texture to render to or null for the default canvas
  29064. * @param faceIndex The face of the texture to render to in case of cube texture
  29065. * @param requiredWidth The width of the target to render to
  29066. * @param requiredHeight The height of the target to render to
  29067. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29068. * @param depthStencilTexture The depth stencil texture to use to render
  29069. * @param lodLevel defines le lod level to bind to the frame buffer
  29070. */
  29071. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29072. /** @hidden */
  29073. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29074. /**
  29075. * Unbind the current render target texture from the webGL context
  29076. * @param texture defines the render target texture to unbind
  29077. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29078. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29079. */
  29080. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29081. /**
  29082. * Force the mipmap generation for the given render target texture
  29083. * @param texture defines the render target texture to use
  29084. */
  29085. generateMipMapsForCubemap(texture: InternalTexture): void;
  29086. /**
  29087. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29088. */
  29089. flushFramebuffer(): void;
  29090. /**
  29091. * Unbind the current render target and bind the default framebuffer
  29092. */
  29093. restoreDefaultFramebuffer(): void;
  29094. /**
  29095. * Create an uniform buffer
  29096. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29097. * @param elements defines the content of the uniform buffer
  29098. * @returns the webGL uniform buffer
  29099. */
  29100. createUniformBuffer(elements: FloatArray): DataBuffer;
  29101. /**
  29102. * Create a dynamic uniform buffer
  29103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29104. * @param elements defines the content of the uniform buffer
  29105. * @returns the webGL uniform buffer
  29106. */
  29107. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29108. /**
  29109. * Update an existing uniform buffer
  29110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29111. * @param uniformBuffer defines the target uniform buffer
  29112. * @param elements defines the content to update
  29113. * @param offset defines the offset in the uniform buffer where update should start
  29114. * @param count defines the size of the data to update
  29115. */
  29116. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29117. private _resetVertexBufferBinding;
  29118. /**
  29119. * Creates a vertex buffer
  29120. * @param data the data for the vertex buffer
  29121. * @returns the new WebGL static buffer
  29122. */
  29123. createVertexBuffer(data: DataArray): DataBuffer;
  29124. /**
  29125. * Creates a dynamic vertex buffer
  29126. * @param data the data for the dynamic vertex buffer
  29127. * @returns the new WebGL dynamic buffer
  29128. */
  29129. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29130. /**
  29131. * Update a dynamic index buffer
  29132. * @param indexBuffer defines the target index buffer
  29133. * @param indices defines the data to update
  29134. * @param offset defines the offset in the target index buffer where update should start
  29135. */
  29136. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29137. /**
  29138. * Updates a dynamic vertex buffer.
  29139. * @param vertexBuffer the vertex buffer to update
  29140. * @param data the data used to update the vertex buffer
  29141. * @param byteOffset the byte offset of the data
  29142. * @param byteLength the byte length of the data
  29143. */
  29144. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29145. private _resetIndexBufferBinding;
  29146. /**
  29147. * Creates a new index buffer
  29148. * @param indices defines the content of the index buffer
  29149. * @param updatable defines if the index buffer must be updatable
  29150. * @returns a new webGL buffer
  29151. */
  29152. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29153. /**
  29154. * Bind a webGL buffer to the webGL context
  29155. * @param buffer defines the buffer to bind
  29156. */
  29157. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29158. /**
  29159. * Bind an uniform buffer to the current webGL context
  29160. * @param buffer defines the buffer to bind
  29161. */
  29162. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29163. /**
  29164. * Bind a buffer to the current webGL context at a given location
  29165. * @param buffer defines the buffer to bind
  29166. * @param location defines the index where to bind the buffer
  29167. */
  29168. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29169. /**
  29170. * Bind a specific block at a given index in a specific shader program
  29171. * @param pipelineContext defines the pipeline context to use
  29172. * @param blockName defines the block name
  29173. * @param index defines the index where to bind the block
  29174. */
  29175. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29176. private bindIndexBuffer;
  29177. private bindBuffer;
  29178. /**
  29179. * update the bound buffer with the given data
  29180. * @param data defines the data to update
  29181. */
  29182. updateArrayBuffer(data: Float32Array): void;
  29183. private _vertexAttribPointer;
  29184. private _bindIndexBufferWithCache;
  29185. private _bindVertexBuffersAttributes;
  29186. /**
  29187. * Records a vertex array object
  29188. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29189. * @param vertexBuffers defines the list of vertex buffers to store
  29190. * @param indexBuffer defines the index buffer to store
  29191. * @param effect defines the effect to store
  29192. * @returns the new vertex array object
  29193. */
  29194. recordVertexArrayObject(vertexBuffers: {
  29195. [key: string]: VertexBuffer;
  29196. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29197. /**
  29198. * Bind a specific vertex array object
  29199. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29200. * @param vertexArrayObject defines the vertex array object to bind
  29201. * @param indexBuffer defines the index buffer to bind
  29202. */
  29203. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29204. /**
  29205. * Bind webGl buffers directly to the webGL context
  29206. * @param vertexBuffer defines the vertex buffer to bind
  29207. * @param indexBuffer defines the index buffer to bind
  29208. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29209. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29210. * @param effect defines the effect associated with the vertex buffer
  29211. */
  29212. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29213. private _unbindVertexArrayObject;
  29214. /**
  29215. * Bind a list of vertex buffers to the webGL context
  29216. * @param vertexBuffers defines the list of vertex buffers to bind
  29217. * @param indexBuffer defines the index buffer to bind
  29218. * @param effect defines the effect associated with the vertex buffers
  29219. */
  29220. bindBuffers(vertexBuffers: {
  29221. [key: string]: Nullable<VertexBuffer>;
  29222. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29223. /**
  29224. * Unbind all instance attributes
  29225. */
  29226. unbindInstanceAttributes(): void;
  29227. /**
  29228. * Release and free the memory of a vertex array object
  29229. * @param vao defines the vertex array object to delete
  29230. */
  29231. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29232. /** @hidden */
  29233. _releaseBuffer(buffer: DataBuffer): boolean;
  29234. /**
  29235. * Creates a webGL buffer to use with instanciation
  29236. * @param capacity defines the size of the buffer
  29237. * @returns the webGL buffer
  29238. */
  29239. createInstancesBuffer(capacity: number): DataBuffer;
  29240. /**
  29241. * Delete a webGL buffer used with instanciation
  29242. * @param buffer defines the webGL buffer to delete
  29243. */
  29244. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29245. /**
  29246. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29247. * @param instancesBuffer defines the webGL buffer to update and bind
  29248. * @param data defines the data to store in the buffer
  29249. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29250. */
  29251. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29252. /**
  29253. * Apply all cached states (depth, culling, stencil and alpha)
  29254. */
  29255. applyStates(): void;
  29256. /**
  29257. * Send a draw order
  29258. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29259. * @param indexStart defines the starting index
  29260. * @param indexCount defines the number of index to draw
  29261. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29262. */
  29263. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29264. /**
  29265. * Draw a list of points
  29266. * @param verticesStart defines the index of first vertex to draw
  29267. * @param verticesCount defines the count of vertices to draw
  29268. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29269. */
  29270. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29271. /**
  29272. * Draw a list of unindexed primitives
  29273. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29274. * @param verticesStart defines the index of first vertex to draw
  29275. * @param verticesCount defines the count of vertices to draw
  29276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29277. */
  29278. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29279. /**
  29280. * Draw a list of indexed primitives
  29281. * @param fillMode defines the primitive to use
  29282. * @param indexStart defines the starting index
  29283. * @param indexCount defines the number of index to draw
  29284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29285. */
  29286. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29287. /**
  29288. * Draw a list of unindexed primitives
  29289. * @param fillMode defines the primitive to use
  29290. * @param verticesStart defines the index of first vertex to draw
  29291. * @param verticesCount defines the count of vertices to draw
  29292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29293. */
  29294. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29295. private _drawMode;
  29296. /** @hidden */
  29297. _releaseEffect(effect: Effect): void;
  29298. /** @hidden */
  29299. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29300. /**
  29301. * Create a new effect (used to store vertex/fragment shaders)
  29302. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29303. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29304. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29305. * @param samplers defines an array of string used to represent textures
  29306. * @param defines defines the string containing the defines to use to compile the shaders
  29307. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29308. * @param onCompiled defines a function to call when the effect creation is successful
  29309. * @param onError defines a function to call when the effect creation has failed
  29310. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29311. * @returns the new Effect
  29312. */
  29313. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  29314. private _compileShader;
  29315. private _compileRawShader;
  29316. /**
  29317. * Directly creates a webGL program
  29318. * @param pipelineContext defines the pipeline context to attach to
  29319. * @param vertexCode defines the vertex shader code to use
  29320. * @param fragmentCode defines the fragment shader code to use
  29321. * @param context defines the webGL context to use (if not set, the current one will be used)
  29322. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29323. * @returns the new webGL program
  29324. */
  29325. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29326. /**
  29327. * Creates a webGL program
  29328. * @param pipelineContext defines the pipeline context to attach to
  29329. * @param vertexCode defines the vertex shader code to use
  29330. * @param fragmentCode defines the fragment shader code to use
  29331. * @param defines defines the string containing the defines to use to compile the shaders
  29332. * @param context defines the webGL context to use (if not set, the current one will be used)
  29333. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29334. * @returns the new webGL program
  29335. */
  29336. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29337. /**
  29338. * Creates a new pipeline context
  29339. * @returns the new pipeline
  29340. */
  29341. createPipelineContext(): WebGLPipelineContext;
  29342. private _createShaderProgram;
  29343. private _finalizePipelineContext;
  29344. /** @hidden */
  29345. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29346. /** @hidden */
  29347. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29348. /** @hidden */
  29349. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29350. /**
  29351. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29352. * @param pipelineContext defines the pipeline context to use
  29353. * @param uniformsNames defines the list of uniform names
  29354. * @returns an array of webGL uniform locations
  29355. */
  29356. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29357. /**
  29358. * Gets the lsit of active attributes for a given webGL program
  29359. * @param pipelineContext defines the pipeline context to use
  29360. * @param attributesNames defines the list of attribute names to get
  29361. * @returns an array of indices indicating the offset of each attribute
  29362. */
  29363. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29364. /**
  29365. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29366. * @param effect defines the effect to activate
  29367. */
  29368. enableEffect(effect: Nullable<Effect>): void;
  29369. /**
  29370. * Set the value of an uniform to an array of int32
  29371. * @param uniform defines the webGL uniform location where to store the value
  29372. * @param array defines the array of int32 to store
  29373. */
  29374. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29375. /**
  29376. * Set the value of an uniform to an array of int32 (stored as vec2)
  29377. * @param uniform defines the webGL uniform location where to store the value
  29378. * @param array defines the array of int32 to store
  29379. */
  29380. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29381. /**
  29382. * Set the value of an uniform to an array of int32 (stored as vec3)
  29383. * @param uniform defines the webGL uniform location where to store the value
  29384. * @param array defines the array of int32 to store
  29385. */
  29386. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29387. /**
  29388. * Set the value of an uniform to an array of int32 (stored as vec4)
  29389. * @param uniform defines the webGL uniform location where to store the value
  29390. * @param array defines the array of int32 to store
  29391. */
  29392. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29393. /**
  29394. * Set the value of an uniform to an array of float32
  29395. * @param uniform defines the webGL uniform location where to store the value
  29396. * @param array defines the array of float32 to store
  29397. */
  29398. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29399. /**
  29400. * Set the value of an uniform to an array of float32 (stored as vec2)
  29401. * @param uniform defines the webGL uniform location where to store the value
  29402. * @param array defines the array of float32 to store
  29403. */
  29404. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29405. /**
  29406. * Set the value of an uniform to an array of float32 (stored as vec3)
  29407. * @param uniform defines the webGL uniform location where to store the value
  29408. * @param array defines the array of float32 to store
  29409. */
  29410. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29411. /**
  29412. * Set the value of an uniform to an array of float32 (stored as vec4)
  29413. * @param uniform defines the webGL uniform location where to store the value
  29414. * @param array defines the array of float32 to store
  29415. */
  29416. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29417. /**
  29418. * Set the value of an uniform to an array of number
  29419. * @param uniform defines the webGL uniform location where to store the value
  29420. * @param array defines the array of number to store
  29421. */
  29422. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29423. /**
  29424. * Set the value of an uniform to an array of number (stored as vec2)
  29425. * @param uniform defines the webGL uniform location where to store the value
  29426. * @param array defines the array of number to store
  29427. */
  29428. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29429. /**
  29430. * Set the value of an uniform to an array of number (stored as vec3)
  29431. * @param uniform defines the webGL uniform location where to store the value
  29432. * @param array defines the array of number to store
  29433. */
  29434. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29435. /**
  29436. * Set the value of an uniform to an array of number (stored as vec4)
  29437. * @param uniform defines the webGL uniform location where to store the value
  29438. * @param array defines the array of number to store
  29439. */
  29440. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29441. /**
  29442. * Set the value of an uniform to an array of float32 (stored as matrices)
  29443. * @param uniform defines the webGL uniform location where to store the value
  29444. * @param matrices defines the array of float32 to store
  29445. */
  29446. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29447. /**
  29448. * Set the value of an uniform to a matrix
  29449. * @param uniform defines the webGL uniform location where to store the value
  29450. * @param matrix defines the matrix to store
  29451. */
  29452. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29453. /**
  29454. * Set the value of an uniform to a matrix (3x3)
  29455. * @param uniform defines the webGL uniform location where to store the value
  29456. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29457. */
  29458. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29459. /**
  29460. * Set the value of an uniform to a matrix (2x2)
  29461. * @param uniform defines the webGL uniform location where to store the value
  29462. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29463. */
  29464. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29465. /**
  29466. * Set the value of an uniform to a number (int)
  29467. * @param uniform defines the webGL uniform location where to store the value
  29468. * @param value defines the int number to store
  29469. */
  29470. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29471. /**
  29472. * Set the value of an uniform to a number (float)
  29473. * @param uniform defines the webGL uniform location where to store the value
  29474. * @param value defines the float number to store
  29475. */
  29476. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29477. /**
  29478. * Set the value of an uniform to a vec2
  29479. * @param uniform defines the webGL uniform location where to store the value
  29480. * @param x defines the 1st component of the value
  29481. * @param y defines the 2nd component of the value
  29482. */
  29483. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29484. /**
  29485. * Set the value of an uniform to a vec3
  29486. * @param uniform defines the webGL uniform location where to store the value
  29487. * @param x defines the 1st component of the value
  29488. * @param y defines the 2nd component of the value
  29489. * @param z defines the 3rd component of the value
  29490. */
  29491. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29492. /**
  29493. * Set the value of an uniform to a boolean
  29494. * @param uniform defines the webGL uniform location where to store the value
  29495. * @param bool defines the boolean to store
  29496. */
  29497. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29498. /**
  29499. * Set the value of an uniform to a vec4
  29500. * @param uniform defines the webGL uniform location where to store the value
  29501. * @param x defines the 1st component of the value
  29502. * @param y defines the 2nd component of the value
  29503. * @param z defines the 3rd component of the value
  29504. * @param w defines the 4th component of the value
  29505. */
  29506. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29507. /**
  29508. * Set the value of an uniform to a Color3
  29509. * @param uniform defines the webGL uniform location where to store the value
  29510. * @param color3 defines the color to store
  29511. */
  29512. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29513. /**
  29514. * Set the value of an uniform to a Color3 and an alpha value
  29515. * @param uniform defines the webGL uniform location where to store the value
  29516. * @param color3 defines the color to store
  29517. * @param alpha defines the alpha component to store
  29518. */
  29519. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29520. /**
  29521. * Sets a Color4 on a uniform variable
  29522. * @param uniform defines the uniform location
  29523. * @param color4 defines the value to be set
  29524. */
  29525. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29526. /**
  29527. * Set various states to the webGL context
  29528. * @param culling defines backface culling state
  29529. * @param zOffset defines the value to apply to zOffset (0 by default)
  29530. * @param force defines if states must be applied even if cache is up to date
  29531. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29532. */
  29533. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29534. /**
  29535. * Set the z offset to apply to current rendering
  29536. * @param value defines the offset to apply
  29537. */
  29538. setZOffset(value: number): void;
  29539. /**
  29540. * Gets the current value of the zOffset
  29541. * @returns the current zOffset state
  29542. */
  29543. getZOffset(): number;
  29544. /**
  29545. * Enable or disable depth buffering
  29546. * @param enable defines the state to set
  29547. */
  29548. setDepthBuffer(enable: boolean): void;
  29549. /**
  29550. * Gets a boolean indicating if depth writing is enabled
  29551. * @returns the current depth writing state
  29552. */
  29553. getDepthWrite(): boolean;
  29554. /**
  29555. * Enable or disable depth writing
  29556. * @param enable defines the state to set
  29557. */
  29558. setDepthWrite(enable: boolean): void;
  29559. /**
  29560. * Enable or disable color writing
  29561. * @param enable defines the state to set
  29562. */
  29563. setColorWrite(enable: boolean): void;
  29564. /**
  29565. * Gets a boolean indicating if color writing is enabled
  29566. * @returns the current color writing state
  29567. */
  29568. getColorWrite(): boolean;
  29569. /**
  29570. * Sets alpha constants used by some alpha blending modes
  29571. * @param r defines the red component
  29572. * @param g defines the green component
  29573. * @param b defines the blue component
  29574. * @param a defines the alpha component
  29575. */
  29576. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29577. /**
  29578. * Sets the current alpha mode
  29579. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29580. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29581. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29582. */
  29583. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29584. /**
  29585. * Gets the current alpha mode
  29586. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29587. * @returns the current alpha mode
  29588. */
  29589. getAlphaMode(): number;
  29590. /**
  29591. * Clears the list of texture accessible through engine.
  29592. * This can help preventing texture load conflict due to name collision.
  29593. */
  29594. clearInternalTexturesCache(): void;
  29595. /**
  29596. * Force the entire cache to be cleared
  29597. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29598. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29599. */
  29600. wipeCaches(bruteForce?: boolean): void;
  29601. /**
  29602. * Set the compressed texture format to use, based on the formats you have, and the formats
  29603. * supported by the hardware / browser.
  29604. *
  29605. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29606. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29607. * to API arguments needed to compressed textures. This puts the burden on the container
  29608. * generator to house the arcane code for determining these for current & future formats.
  29609. *
  29610. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29611. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29612. *
  29613. * Note: The result of this call is not taken into account when a texture is base64.
  29614. *
  29615. * @param formatsAvailable defines the list of those format families you have created
  29616. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29617. *
  29618. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29619. * @returns The extension selected.
  29620. */
  29621. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29622. /** @hidden */
  29623. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29624. min: number;
  29625. mag: number;
  29626. };
  29627. /** @hidden */
  29628. _createTexture(): WebGLTexture;
  29629. /**
  29630. * Usually called from Texture.ts.
  29631. * Passed information to create a WebGLTexture
  29632. * @param urlArg defines a value which contains one of the following:
  29633. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29634. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29635. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29636. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29637. * @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)
  29638. * @param scene needed for loading to the correct scene
  29639. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29640. * @param onLoad optional callback to be called upon successful completion
  29641. * @param onError optional callback to be called upon failure
  29642. * @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
  29643. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29644. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29645. * @param forcedExtension defines the extension to use to pick the right loader
  29646. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29647. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29648. */
  29649. 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;
  29650. private _rescaleTexture;
  29651. private _unpackFlipYCached;
  29652. /**
  29653. * In case you are sharing the context with other applications, it might
  29654. * be interested to not cache the unpack flip y state to ensure a consistent
  29655. * value would be set.
  29656. */
  29657. enableUnpackFlipYCached: boolean;
  29658. /** @hidden */
  29659. _unpackFlipY(value: boolean): void;
  29660. /** @hidden */
  29661. _getUnpackAlignement(): number;
  29662. /**
  29663. * Creates a dynamic texture
  29664. * @param width defines the width of the texture
  29665. * @param height defines the height of the texture
  29666. * @param generateMipMaps defines if the engine should generate the mip levels
  29667. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29668. * @returns the dynamic texture inside an InternalTexture
  29669. */
  29670. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29671. /**
  29672. * Update the sampling mode of a given texture
  29673. * @param samplingMode defines the required sampling mode
  29674. * @param texture defines the texture to update
  29675. */
  29676. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29677. /**
  29678. * Update the content of a dynamic texture
  29679. * @param texture defines the texture to update
  29680. * @param canvas defines the canvas containing the source
  29681. * @param invertY defines if data must be stored with Y axis inverted
  29682. * @param premulAlpha defines if alpha is stored as premultiplied
  29683. * @param format defines the format of the data
  29684. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29685. */
  29686. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29687. /**
  29688. * Update a video texture
  29689. * @param texture defines the texture to update
  29690. * @param video defines the video element to use
  29691. * @param invertY defines if data must be stored with Y axis inverted
  29692. */
  29693. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29694. /**
  29695. * Updates a depth texture Comparison Mode and Function.
  29696. * If the comparison Function is equal to 0, the mode will be set to none.
  29697. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29698. * @param texture The texture to set the comparison function for
  29699. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29700. */
  29701. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29702. /** @hidden */
  29703. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29704. width: number;
  29705. height: number;
  29706. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29707. /**
  29708. * Creates a depth stencil texture.
  29709. * This is only available in WebGL 2 or with the depth texture extension available.
  29710. * @param size The size of face edge in the texture.
  29711. * @param options The options defining the texture.
  29712. * @returns The texture
  29713. */
  29714. createDepthStencilTexture(size: number | {
  29715. width: number;
  29716. height: number;
  29717. }, options: DepthTextureCreationOptions): InternalTexture;
  29718. /**
  29719. * Creates a depth stencil texture.
  29720. * This is only available in WebGL 2 or with the depth texture extension available.
  29721. * @param size The size of face edge in the texture.
  29722. * @param options The options defining the texture.
  29723. * @returns The texture
  29724. */
  29725. private _createDepthStencilTexture;
  29726. /**
  29727. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29728. * @param renderTarget The render target to set the frame buffer for
  29729. */
  29730. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29731. /**
  29732. * Creates a new render target texture
  29733. * @param size defines the size of the texture
  29734. * @param options defines the options used to create the texture
  29735. * @returns a new render target texture stored in an InternalTexture
  29736. */
  29737. createRenderTargetTexture(size: number | {
  29738. width: number;
  29739. height: number;
  29740. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29741. /** @hidden */
  29742. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29743. /**
  29744. * Updates the sample count of a render target texture
  29745. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29746. * @param texture defines the texture to update
  29747. * @param samples defines the sample count to set
  29748. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29749. */
  29750. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29751. /** @hidden */
  29752. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29753. /** @hidden */
  29754. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29755. /** @hidden */
  29756. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29757. /** @hidden */
  29758. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29759. /**
  29760. * @hidden
  29761. */
  29762. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29763. private _prepareWebGLTextureContinuation;
  29764. private _prepareWebGLTexture;
  29765. /** @hidden */
  29766. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29767. /** @hidden */
  29768. _releaseFramebufferObjects(texture: InternalTexture): void;
  29769. /** @hidden */
  29770. _releaseTexture(texture: InternalTexture): void;
  29771. private setProgram;
  29772. private _boundUniforms;
  29773. /**
  29774. * Binds an effect to the webGL context
  29775. * @param effect defines the effect to bind
  29776. */
  29777. bindSamplers(effect: Effect): void;
  29778. private _activateCurrentTexture;
  29779. /** @hidden */
  29780. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29781. /** @hidden */
  29782. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29783. /**
  29784. * Sets a texture to the webGL context from a postprocess
  29785. * @param channel defines the channel to use
  29786. * @param postProcess defines the source postprocess
  29787. */
  29788. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29789. /**
  29790. * Binds the output of the passed in post process to the texture channel specified
  29791. * @param channel The channel the texture should be bound to
  29792. * @param postProcess The post process which's output should be bound
  29793. */
  29794. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29795. /**
  29796. * Unbind all textures from the webGL context
  29797. */
  29798. unbindAllTextures(): void;
  29799. /**
  29800. * Sets a texture to the according uniform.
  29801. * @param channel The texture channel
  29802. * @param uniform The uniform to set
  29803. * @param texture The texture to apply
  29804. */
  29805. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29806. /**
  29807. * Sets a depth stencil texture from a render target to the according uniform.
  29808. * @param channel The texture channel
  29809. * @param uniform The uniform to set
  29810. * @param texture The render target texture containing the depth stencil texture to apply
  29811. */
  29812. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29813. private _bindSamplerUniformToChannel;
  29814. private _getTextureWrapMode;
  29815. private _setTexture;
  29816. /**
  29817. * Sets an array of texture to the webGL context
  29818. * @param channel defines the channel where the texture array must be set
  29819. * @param uniform defines the associated uniform location
  29820. * @param textures defines the array of textures to bind
  29821. */
  29822. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29823. /** @hidden */
  29824. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29825. private _setTextureParameterFloat;
  29826. private _setTextureParameterInteger;
  29827. /**
  29828. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29829. * @param x defines the x coordinate of the rectangle where pixels must be read
  29830. * @param y defines the y coordinate of the rectangle where pixels must be read
  29831. * @param width defines the width of the rectangle where pixels must be read
  29832. * @param height defines the height of the rectangle where pixels must be read
  29833. * @returns a Uint8Array containing RGBA colors
  29834. */
  29835. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29836. /**
  29837. * Add an externaly attached data from its key.
  29838. * This method call will fail and return false, if such key already exists.
  29839. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29840. * @param key the unique key that identifies the data
  29841. * @param data the data object to associate to the key for this Engine instance
  29842. * @return true if no such key were already present and the data was added successfully, false otherwise
  29843. */
  29844. addExternalData<T>(key: string, data: T): boolean;
  29845. /**
  29846. * Get an externaly attached data from its key
  29847. * @param key the unique key that identifies the data
  29848. * @return the associated data, if present (can be null), or undefined if not present
  29849. */
  29850. getExternalData<T>(key: string): T;
  29851. /**
  29852. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29853. * @param key the unique key that identifies the data
  29854. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29855. * @return the associated data, can be null if the factory returned null.
  29856. */
  29857. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29858. /**
  29859. * Remove an externaly attached data from the Engine instance
  29860. * @param key the unique key that identifies the data
  29861. * @return true if the data was successfully removed, false if it doesn't exist
  29862. */
  29863. removeExternalData(key: string): boolean;
  29864. /**
  29865. * Unbind all vertex attributes from the webGL context
  29866. */
  29867. unbindAllAttributes(): void;
  29868. /**
  29869. * 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
  29870. */
  29871. releaseEffects(): void;
  29872. /**
  29873. * Dispose and release all associated resources
  29874. */
  29875. dispose(): void;
  29876. /**
  29877. * Display the loading screen
  29878. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29879. */
  29880. displayLoadingUI(): void;
  29881. /**
  29882. * Hide the loading screen
  29883. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29884. */
  29885. hideLoadingUI(): void;
  29886. /**
  29887. * Gets the current loading screen object
  29888. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29889. */
  29890. /**
  29891. * Sets the current loading screen object
  29892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29893. */
  29894. loadingScreen: ILoadingScreen;
  29895. /**
  29896. * Sets the current loading screen text
  29897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29898. */
  29899. loadingUIText: string;
  29900. /**
  29901. * Sets the current loading screen background color
  29902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29903. */
  29904. loadingUIBackgroundColor: string;
  29905. /**
  29906. * Attach a new callback raised when context lost event is fired
  29907. * @param callback defines the callback to call
  29908. */
  29909. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29910. /**
  29911. * Attach a new callback raised when context restored event is fired
  29912. * @param callback defines the callback to call
  29913. */
  29914. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29915. /**
  29916. * Gets the source code of the vertex shader associated with a specific webGL program
  29917. * @param program defines the program to use
  29918. * @returns a string containing the source code of the vertex shader associated with the program
  29919. */
  29920. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29921. /**
  29922. * Gets the source code of the fragment shader associated with a specific webGL program
  29923. * @param program defines the program to use
  29924. * @returns a string containing the source code of the fragment shader associated with the program
  29925. */
  29926. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29927. /**
  29928. * Get the current error code of the webGL context
  29929. * @returns the error code
  29930. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29931. */
  29932. getError(): number;
  29933. /**
  29934. * Gets the current framerate
  29935. * @returns a number representing the framerate
  29936. */
  29937. getFps(): number;
  29938. /**
  29939. * Gets the time spent between current and previous frame
  29940. * @returns a number representing the delta time in ms
  29941. */
  29942. getDeltaTime(): number;
  29943. private _measureFps;
  29944. /** @hidden */
  29945. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29946. private _canRenderToFloatFramebuffer;
  29947. private _canRenderToHalfFloatFramebuffer;
  29948. private _canRenderToFramebuffer;
  29949. /** @hidden */
  29950. _getWebGLTextureType(type: number): number;
  29951. /** @hidden */
  29952. _getInternalFormat(format: number): number;
  29953. /** @hidden */
  29954. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29955. /** @hidden */
  29956. _getRGBAMultiSampleBufferFormat(type: number): number;
  29957. /** @hidden */
  29958. _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;
  29959. /** @hidden */
  29960. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29961. /**
  29962. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29963. * @returns true if the engine can be created
  29964. * @ignorenaming
  29965. */
  29966. static isSupported(): boolean;
  29967. }
  29968. }
  29969. declare module "babylonjs/Materials/effect" {
  29970. import { Observable } from "babylonjs/Misc/observable";
  29971. import { Nullable } from "babylonjs/types";
  29972. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29973. import { IDisposable } from "babylonjs/scene";
  29974. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29975. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29976. import { Engine } from "babylonjs/Engines/engine";
  29977. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29979. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29980. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29982. /**
  29983. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29984. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29985. */
  29986. export class EffectFallbacks {
  29987. private _defines;
  29988. private _currentRank;
  29989. private _maxRank;
  29990. private _mesh;
  29991. /**
  29992. * Removes the fallback from the bound mesh.
  29993. */
  29994. unBindMesh(): void;
  29995. /**
  29996. * Adds a fallback on the specified property.
  29997. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29998. * @param define The name of the define in the shader
  29999. */
  30000. addFallback(rank: number, define: string): void;
  30001. /**
  30002. * Sets the mesh to use CPU skinning when needing to fallback.
  30003. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30004. * @param mesh The mesh to use the fallbacks.
  30005. */
  30006. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30007. /**
  30008. * Checks to see if more fallbacks are still availible.
  30009. */
  30010. readonly isMoreFallbacks: boolean;
  30011. /**
  30012. * Removes the defines that should be removed when falling back.
  30013. * @param currentDefines defines the current define statements for the shader.
  30014. * @param effect defines the current effect we try to compile
  30015. * @returns The resulting defines with defines of the current rank removed.
  30016. */
  30017. reduce(currentDefines: string, effect: Effect): string;
  30018. }
  30019. /**
  30020. * Options to be used when creating an effect.
  30021. */
  30022. export class EffectCreationOptions {
  30023. /**
  30024. * Atrributes that will be used in the shader.
  30025. */
  30026. attributes: string[];
  30027. /**
  30028. * Uniform varible names that will be set in the shader.
  30029. */
  30030. uniformsNames: string[];
  30031. /**
  30032. * Uniform buffer varible names that will be set in the shader.
  30033. */
  30034. uniformBuffersNames: string[];
  30035. /**
  30036. * Sampler texture variable names that will be set in the shader.
  30037. */
  30038. samplers: string[];
  30039. /**
  30040. * Define statements that will be set in the shader.
  30041. */
  30042. defines: any;
  30043. /**
  30044. * Possible fallbacks for this effect to improve performance when needed.
  30045. */
  30046. fallbacks: Nullable<EffectFallbacks>;
  30047. /**
  30048. * Callback that will be called when the shader is compiled.
  30049. */
  30050. onCompiled: Nullable<(effect: Effect) => void>;
  30051. /**
  30052. * Callback that will be called if an error occurs during shader compilation.
  30053. */
  30054. onError: Nullable<(effect: Effect, errors: string) => void>;
  30055. /**
  30056. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30057. */
  30058. indexParameters: any;
  30059. /**
  30060. * Max number of lights that can be used in the shader.
  30061. */
  30062. maxSimultaneousLights: number;
  30063. /**
  30064. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30065. */
  30066. transformFeedbackVaryings: Nullable<string[]>;
  30067. }
  30068. /**
  30069. * Effect containing vertex and fragment shader that can be executed on an object.
  30070. */
  30071. export class Effect implements IDisposable {
  30072. /**
  30073. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30074. */
  30075. static ShadersRepository: string;
  30076. /**
  30077. * Name of the effect.
  30078. */
  30079. name: any;
  30080. /**
  30081. * String container all the define statements that should be set on the shader.
  30082. */
  30083. defines: string;
  30084. /**
  30085. * Callback that will be called when the shader is compiled.
  30086. */
  30087. onCompiled: Nullable<(effect: Effect) => void>;
  30088. /**
  30089. * Callback that will be called if an error occurs during shader compilation.
  30090. */
  30091. onError: Nullable<(effect: Effect, errors: string) => void>;
  30092. /**
  30093. * Callback that will be called when effect is bound.
  30094. */
  30095. onBind: Nullable<(effect: Effect) => void>;
  30096. /**
  30097. * Unique ID of the effect.
  30098. */
  30099. uniqueId: number;
  30100. /**
  30101. * Observable that will be called when the shader is compiled.
  30102. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30103. */
  30104. onCompileObservable: Observable<Effect>;
  30105. /**
  30106. * Observable that will be called if an error occurs during shader compilation.
  30107. */
  30108. onErrorObservable: Observable<Effect>;
  30109. /** @hidden */
  30110. _onBindObservable: Nullable<Observable<Effect>>;
  30111. /**
  30112. * Observable that will be called when effect is bound.
  30113. */
  30114. readonly onBindObservable: Observable<Effect>;
  30115. /** @hidden */
  30116. _bonesComputationForcedToCPU: boolean;
  30117. private static _uniqueIdSeed;
  30118. private _engine;
  30119. private _uniformBuffersNames;
  30120. private _uniformsNames;
  30121. private _samplerList;
  30122. private _samplers;
  30123. private _isReady;
  30124. private _compilationError;
  30125. private _attributesNames;
  30126. private _attributes;
  30127. private _uniforms;
  30128. /**
  30129. * Key for the effect.
  30130. * @hidden
  30131. */
  30132. _key: string;
  30133. private _indexParameters;
  30134. private _fallbacks;
  30135. private _vertexSourceCode;
  30136. private _fragmentSourceCode;
  30137. private _vertexSourceCodeOverride;
  30138. private _fragmentSourceCodeOverride;
  30139. private _transformFeedbackVaryings;
  30140. /**
  30141. * Compiled shader to webGL program.
  30142. * @hidden
  30143. */
  30144. _pipelineContext: Nullable<IPipelineContext>;
  30145. private _valueCache;
  30146. private static _baseCache;
  30147. /**
  30148. * Instantiates an effect.
  30149. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30150. * @param baseName Name of the effect.
  30151. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30152. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30153. * @param samplers List of sampler variables that will be passed to the shader.
  30154. * @param engine Engine to be used to render the effect
  30155. * @param defines Define statements to be added to the shader.
  30156. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30157. * @param onCompiled Callback that will be called when the shader is compiled.
  30158. * @param onError Callback that will be called if an error occurs during shader compilation.
  30159. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30160. */
  30161. 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);
  30162. private _useFinalCode;
  30163. /**
  30164. * Unique key for this effect
  30165. */
  30166. readonly key: string;
  30167. /**
  30168. * If the effect has been compiled and prepared.
  30169. * @returns if the effect is compiled and prepared.
  30170. */
  30171. isReady(): boolean;
  30172. /**
  30173. * The engine the effect was initialized with.
  30174. * @returns the engine.
  30175. */
  30176. getEngine(): Engine;
  30177. /**
  30178. * The pipeline context for this effect
  30179. * @returns the associated pipeline context
  30180. */
  30181. getPipelineContext(): Nullable<IPipelineContext>;
  30182. /**
  30183. * The set of names of attribute variables for the shader.
  30184. * @returns An array of attribute names.
  30185. */
  30186. getAttributesNames(): string[];
  30187. /**
  30188. * Returns the attribute at the given index.
  30189. * @param index The index of the attribute.
  30190. * @returns The location of the attribute.
  30191. */
  30192. getAttributeLocation(index: number): number;
  30193. /**
  30194. * Returns the attribute based on the name of the variable.
  30195. * @param name of the attribute to look up.
  30196. * @returns the attribute location.
  30197. */
  30198. getAttributeLocationByName(name: string): number;
  30199. /**
  30200. * The number of attributes.
  30201. * @returns the numnber of attributes.
  30202. */
  30203. getAttributesCount(): number;
  30204. /**
  30205. * Gets the index of a uniform variable.
  30206. * @param uniformName of the uniform to look up.
  30207. * @returns the index.
  30208. */
  30209. getUniformIndex(uniformName: string): number;
  30210. /**
  30211. * Returns the attribute based on the name of the variable.
  30212. * @param uniformName of the uniform to look up.
  30213. * @returns the location of the uniform.
  30214. */
  30215. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30216. /**
  30217. * Returns an array of sampler variable names
  30218. * @returns The array of sampler variable neames.
  30219. */
  30220. getSamplers(): string[];
  30221. /**
  30222. * The error from the last compilation.
  30223. * @returns the error string.
  30224. */
  30225. getCompilationError(): string;
  30226. /**
  30227. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30228. * @param func The callback to be used.
  30229. */
  30230. executeWhenCompiled(func: (effect: Effect) => void): void;
  30231. private _checkIsReady;
  30232. /** @hidden */
  30233. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30234. /** @hidden */
  30235. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30236. /** @hidden */
  30237. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30238. /**
  30239. * Recompiles the webGL program
  30240. * @param vertexSourceCode The source code for the vertex shader.
  30241. * @param fragmentSourceCode The source code for the fragment shader.
  30242. * @param onCompiled Callback called when completed.
  30243. * @param onError Callback called on error.
  30244. * @hidden
  30245. */
  30246. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30247. /**
  30248. * Prepares the effect
  30249. * @hidden
  30250. */
  30251. _prepareEffect(): void;
  30252. /**
  30253. * Checks if the effect is supported. (Must be called after compilation)
  30254. */
  30255. readonly isSupported: boolean;
  30256. /**
  30257. * Binds a texture to the engine to be used as output of the shader.
  30258. * @param channel Name of the output variable.
  30259. * @param texture Texture to bind.
  30260. * @hidden
  30261. */
  30262. _bindTexture(channel: string, texture: InternalTexture): void;
  30263. /**
  30264. * Sets a texture on the engine to be used in the shader.
  30265. * @param channel Name of the sampler variable.
  30266. * @param texture Texture to set.
  30267. */
  30268. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30269. /**
  30270. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30271. * @param channel Name of the sampler variable.
  30272. * @param texture Texture to set.
  30273. */
  30274. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30275. /**
  30276. * Sets an array of textures on the engine to be used in the shader.
  30277. * @param channel Name of the variable.
  30278. * @param textures Textures to set.
  30279. */
  30280. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30281. /**
  30282. * 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)
  30283. * @param channel Name of the sampler variable.
  30284. * @param postProcess Post process to get the input texture from.
  30285. */
  30286. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30287. /**
  30288. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30289. * 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)
  30290. * @param channel Name of the sampler variable.
  30291. * @param postProcess Post process to get the output texture from.
  30292. */
  30293. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30294. /** @hidden */
  30295. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30296. /** @hidden */
  30297. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30298. /** @hidden */
  30299. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30300. /** @hidden */
  30301. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30302. /**
  30303. * Binds a buffer to a uniform.
  30304. * @param buffer Buffer to bind.
  30305. * @param name Name of the uniform variable to bind to.
  30306. */
  30307. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30308. /**
  30309. * Binds block to a uniform.
  30310. * @param blockName Name of the block to bind.
  30311. * @param index Index to bind.
  30312. */
  30313. bindUniformBlock(blockName: string, index: number): void;
  30314. /**
  30315. * Sets an interger value on a uniform variable.
  30316. * @param uniformName Name of the variable.
  30317. * @param value Value to be set.
  30318. * @returns this effect.
  30319. */
  30320. setInt(uniformName: string, value: number): Effect;
  30321. /**
  30322. * Sets an int array on a uniform variable.
  30323. * @param uniformName Name of the variable.
  30324. * @param array array to be set.
  30325. * @returns this effect.
  30326. */
  30327. setIntArray(uniformName: string, array: Int32Array): Effect;
  30328. /**
  30329. * 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)
  30330. * @param uniformName Name of the variable.
  30331. * @param array array to be set.
  30332. * @returns this effect.
  30333. */
  30334. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30335. /**
  30336. * 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)
  30337. * @param uniformName Name of the variable.
  30338. * @param array array to be set.
  30339. * @returns this effect.
  30340. */
  30341. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30342. /**
  30343. * 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)
  30344. * @param uniformName Name of the variable.
  30345. * @param array array to be set.
  30346. * @returns this effect.
  30347. */
  30348. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30349. /**
  30350. * Sets an float array on a uniform variable.
  30351. * @param uniformName Name of the variable.
  30352. * @param array array to be set.
  30353. * @returns this effect.
  30354. */
  30355. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30356. /**
  30357. * 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)
  30358. * @param uniformName Name of the variable.
  30359. * @param array array to be set.
  30360. * @returns this effect.
  30361. */
  30362. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30363. /**
  30364. * 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)
  30365. * @param uniformName Name of the variable.
  30366. * @param array array to be set.
  30367. * @returns this effect.
  30368. */
  30369. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30370. /**
  30371. * 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)
  30372. * @param uniformName Name of the variable.
  30373. * @param array array to be set.
  30374. * @returns this effect.
  30375. */
  30376. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30377. /**
  30378. * Sets an array on a uniform variable.
  30379. * @param uniformName Name of the variable.
  30380. * @param array array to be set.
  30381. * @returns this effect.
  30382. */
  30383. setArray(uniformName: string, array: number[]): Effect;
  30384. /**
  30385. * 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)
  30386. * @param uniformName Name of the variable.
  30387. * @param array array to be set.
  30388. * @returns this effect.
  30389. */
  30390. setArray2(uniformName: string, array: number[]): Effect;
  30391. /**
  30392. * 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)
  30393. * @param uniformName Name of the variable.
  30394. * @param array array to be set.
  30395. * @returns this effect.
  30396. */
  30397. setArray3(uniformName: string, array: number[]): Effect;
  30398. /**
  30399. * 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)
  30400. * @param uniformName Name of the variable.
  30401. * @param array array to be set.
  30402. * @returns this effect.
  30403. */
  30404. setArray4(uniformName: string, array: number[]): Effect;
  30405. /**
  30406. * Sets matrices on a uniform variable.
  30407. * @param uniformName Name of the variable.
  30408. * @param matrices matrices to be set.
  30409. * @returns this effect.
  30410. */
  30411. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30412. /**
  30413. * Sets matrix on a uniform variable.
  30414. * @param uniformName Name of the variable.
  30415. * @param matrix matrix to be set.
  30416. * @returns this effect.
  30417. */
  30418. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30419. /**
  30420. * 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)
  30421. * @param uniformName Name of the variable.
  30422. * @param matrix matrix to be set.
  30423. * @returns this effect.
  30424. */
  30425. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30426. /**
  30427. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30428. * @param uniformName Name of the variable.
  30429. * @param matrix matrix to be set.
  30430. * @returns this effect.
  30431. */
  30432. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30433. /**
  30434. * Sets a float on a uniform variable.
  30435. * @param uniformName Name of the variable.
  30436. * @param value value to be set.
  30437. * @returns this effect.
  30438. */
  30439. setFloat(uniformName: string, value: number): Effect;
  30440. /**
  30441. * Sets a boolean on a uniform variable.
  30442. * @param uniformName Name of the variable.
  30443. * @param bool value to be set.
  30444. * @returns this effect.
  30445. */
  30446. setBool(uniformName: string, bool: boolean): Effect;
  30447. /**
  30448. * Sets a Vector2 on a uniform variable.
  30449. * @param uniformName Name of the variable.
  30450. * @param vector2 vector2 to be set.
  30451. * @returns this effect.
  30452. */
  30453. setVector2(uniformName: string, vector2: Vector2): Effect;
  30454. /**
  30455. * Sets a float2 on a uniform variable.
  30456. * @param uniformName Name of the variable.
  30457. * @param x First float in float2.
  30458. * @param y Second float in float2.
  30459. * @returns this effect.
  30460. */
  30461. setFloat2(uniformName: string, x: number, y: number): Effect;
  30462. /**
  30463. * Sets a Vector3 on a uniform variable.
  30464. * @param uniformName Name of the variable.
  30465. * @param vector3 Value to be set.
  30466. * @returns this effect.
  30467. */
  30468. setVector3(uniformName: string, vector3: Vector3): Effect;
  30469. /**
  30470. * Sets a float3 on a uniform variable.
  30471. * @param uniformName Name of the variable.
  30472. * @param x First float in float3.
  30473. * @param y Second float in float3.
  30474. * @param z Third float in float3.
  30475. * @returns this effect.
  30476. */
  30477. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30478. /**
  30479. * Sets a Vector4 on a uniform variable.
  30480. * @param uniformName Name of the variable.
  30481. * @param vector4 Value to be set.
  30482. * @returns this effect.
  30483. */
  30484. setVector4(uniformName: string, vector4: Vector4): Effect;
  30485. /**
  30486. * Sets a float4 on a uniform variable.
  30487. * @param uniformName Name of the variable.
  30488. * @param x First float in float4.
  30489. * @param y Second float in float4.
  30490. * @param z Third float in float4.
  30491. * @param w Fourth float in float4.
  30492. * @returns this effect.
  30493. */
  30494. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30495. /**
  30496. * Sets a Color3 on a uniform variable.
  30497. * @param uniformName Name of the variable.
  30498. * @param color3 Value to be set.
  30499. * @returns this effect.
  30500. */
  30501. setColor3(uniformName: string, color3: Color3): Effect;
  30502. /**
  30503. * Sets a Color4 on a uniform variable.
  30504. * @param uniformName Name of the variable.
  30505. * @param color3 Value to be set.
  30506. * @param alpha Alpha value to be set.
  30507. * @returns this effect.
  30508. */
  30509. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30510. /**
  30511. * Sets a Color4 on a uniform variable
  30512. * @param uniformName defines the name of the variable
  30513. * @param color4 defines the value to be set
  30514. * @returns this effect.
  30515. */
  30516. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30517. /** Release all associated resources */
  30518. dispose(): void;
  30519. /**
  30520. * This function will add a new shader to the shader store
  30521. * @param name the name of the shader
  30522. * @param pixelShader optional pixel shader content
  30523. * @param vertexShader optional vertex shader content
  30524. */
  30525. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30526. /**
  30527. * Store of each shader (The can be looked up using effect.key)
  30528. */
  30529. static ShadersStore: {
  30530. [key: string]: string;
  30531. };
  30532. /**
  30533. * Store of each included file for a shader (The can be looked up using effect.key)
  30534. */
  30535. static IncludesShadersStore: {
  30536. [key: string]: string;
  30537. };
  30538. /**
  30539. * Resets the cache of effects.
  30540. */
  30541. static ResetCache(): void;
  30542. }
  30543. }
  30544. declare module "babylonjs/Materials/colorCurves" {
  30545. import { Effect } from "babylonjs/Materials/effect";
  30546. /**
  30547. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30548. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30549. * 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;
  30550. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30551. */
  30552. export class ColorCurves {
  30553. private _dirty;
  30554. private _tempColor;
  30555. private _globalCurve;
  30556. private _highlightsCurve;
  30557. private _midtonesCurve;
  30558. private _shadowsCurve;
  30559. private _positiveCurve;
  30560. private _negativeCurve;
  30561. private _globalHue;
  30562. private _globalDensity;
  30563. private _globalSaturation;
  30564. private _globalExposure;
  30565. /**
  30566. * Gets the global Hue value.
  30567. * 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).
  30568. */
  30569. /**
  30570. * Sets the global Hue value.
  30571. * 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).
  30572. */
  30573. globalHue: number;
  30574. /**
  30575. * Gets the global Density value.
  30576. * 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.
  30577. * Values less than zero provide a filter of opposite hue.
  30578. */
  30579. /**
  30580. * Sets the global Density value.
  30581. * 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.
  30582. * Values less than zero provide a filter of opposite hue.
  30583. */
  30584. globalDensity: number;
  30585. /**
  30586. * Gets the global Saturation value.
  30587. * 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.
  30588. */
  30589. /**
  30590. * Sets the global Saturation value.
  30591. * 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.
  30592. */
  30593. globalSaturation: number;
  30594. /**
  30595. * Gets the global Exposure value.
  30596. * 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.
  30597. */
  30598. /**
  30599. * Sets the global Exposure value.
  30600. * 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.
  30601. */
  30602. globalExposure: number;
  30603. private _highlightsHue;
  30604. private _highlightsDensity;
  30605. private _highlightsSaturation;
  30606. private _highlightsExposure;
  30607. /**
  30608. * Gets the highlights Hue value.
  30609. * 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).
  30610. */
  30611. /**
  30612. * Sets the highlights Hue value.
  30613. * 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).
  30614. */
  30615. highlightsHue: number;
  30616. /**
  30617. * Gets the highlights Density value.
  30618. * 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.
  30619. * Values less than zero provide a filter of opposite hue.
  30620. */
  30621. /**
  30622. * Sets the highlights Density value.
  30623. * 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.
  30624. * Values less than zero provide a filter of opposite hue.
  30625. */
  30626. highlightsDensity: number;
  30627. /**
  30628. * Gets the highlights Saturation value.
  30629. * 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.
  30630. */
  30631. /**
  30632. * Sets the highlights Saturation value.
  30633. * 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.
  30634. */
  30635. highlightsSaturation: number;
  30636. /**
  30637. * Gets the highlights Exposure value.
  30638. * 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.
  30639. */
  30640. /**
  30641. * Sets the highlights Exposure value.
  30642. * 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.
  30643. */
  30644. highlightsExposure: number;
  30645. private _midtonesHue;
  30646. private _midtonesDensity;
  30647. private _midtonesSaturation;
  30648. private _midtonesExposure;
  30649. /**
  30650. * Gets the midtones Hue value.
  30651. * 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).
  30652. */
  30653. /**
  30654. * Sets the midtones Hue value.
  30655. * 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).
  30656. */
  30657. midtonesHue: number;
  30658. /**
  30659. * Gets the midtones Density value.
  30660. * 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.
  30661. * Values less than zero provide a filter of opposite hue.
  30662. */
  30663. /**
  30664. * Sets the midtones Density value.
  30665. * 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.
  30666. * Values less than zero provide a filter of opposite hue.
  30667. */
  30668. midtonesDensity: number;
  30669. /**
  30670. * Gets the midtones Saturation value.
  30671. * 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.
  30672. */
  30673. /**
  30674. * Sets the midtones Saturation value.
  30675. * 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.
  30676. */
  30677. midtonesSaturation: number;
  30678. /**
  30679. * Gets the midtones Exposure value.
  30680. * 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.
  30681. */
  30682. /**
  30683. * Sets the midtones Exposure value.
  30684. * 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.
  30685. */
  30686. midtonesExposure: number;
  30687. private _shadowsHue;
  30688. private _shadowsDensity;
  30689. private _shadowsSaturation;
  30690. private _shadowsExposure;
  30691. /**
  30692. * Gets the shadows Hue value.
  30693. * 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).
  30694. */
  30695. /**
  30696. * Sets the shadows Hue value.
  30697. * 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).
  30698. */
  30699. shadowsHue: number;
  30700. /**
  30701. * Gets the shadows Density value.
  30702. * 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.
  30703. * Values less than zero provide a filter of opposite hue.
  30704. */
  30705. /**
  30706. * Sets the shadows Density value.
  30707. * 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.
  30708. * Values less than zero provide a filter of opposite hue.
  30709. */
  30710. shadowsDensity: number;
  30711. /**
  30712. * Gets the shadows Saturation value.
  30713. * 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.
  30714. */
  30715. /**
  30716. * Sets the shadows Saturation value.
  30717. * 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.
  30718. */
  30719. shadowsSaturation: number;
  30720. /**
  30721. * Gets the shadows Exposure value.
  30722. * 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.
  30723. */
  30724. /**
  30725. * Sets the shadows Exposure value.
  30726. * 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.
  30727. */
  30728. shadowsExposure: number;
  30729. /**
  30730. * Returns the class name
  30731. * @returns The class name
  30732. */
  30733. getClassName(): string;
  30734. /**
  30735. * Binds the color curves to the shader.
  30736. * @param colorCurves The color curve to bind
  30737. * @param effect The effect to bind to
  30738. * @param positiveUniform The positive uniform shader parameter
  30739. * @param neutralUniform The neutral uniform shader parameter
  30740. * @param negativeUniform The negative uniform shader parameter
  30741. */
  30742. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30743. /**
  30744. * Prepare the list of uniforms associated with the ColorCurves effects.
  30745. * @param uniformsList The list of uniforms used in the effect
  30746. */
  30747. static PrepareUniforms(uniformsList: string[]): void;
  30748. /**
  30749. * Returns color grading data based on a hue, density, saturation and exposure value.
  30750. * @param filterHue The hue of the color filter.
  30751. * @param filterDensity The density of the color filter.
  30752. * @param saturation The saturation.
  30753. * @param exposure The exposure.
  30754. * @param result The result data container.
  30755. */
  30756. private getColorGradingDataToRef;
  30757. /**
  30758. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30759. * @param value The input slider value in range [-100,100].
  30760. * @returns Adjusted value.
  30761. */
  30762. private static applyColorGradingSliderNonlinear;
  30763. /**
  30764. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30765. * @param hue The hue (H) input.
  30766. * @param saturation The saturation (S) input.
  30767. * @param brightness The brightness (B) input.
  30768. * @result An RGBA color represented as Vector4.
  30769. */
  30770. private static fromHSBToRef;
  30771. /**
  30772. * Returns a value clamped between min and max
  30773. * @param value The value to clamp
  30774. * @param min The minimum of value
  30775. * @param max The maximum of value
  30776. * @returns The clamped value.
  30777. */
  30778. private static clamp;
  30779. /**
  30780. * Clones the current color curve instance.
  30781. * @return The cloned curves
  30782. */
  30783. clone(): ColorCurves;
  30784. /**
  30785. * Serializes the current color curve instance to a json representation.
  30786. * @return a JSON representation
  30787. */
  30788. serialize(): any;
  30789. /**
  30790. * Parses the color curve from a json representation.
  30791. * @param source the JSON source to parse
  30792. * @return The parsed curves
  30793. */
  30794. static Parse(source: any): ColorCurves;
  30795. }
  30796. }
  30797. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30798. import { Observable } from "babylonjs/Misc/observable";
  30799. import { Nullable } from "babylonjs/types";
  30800. import { Color4 } from "babylonjs/Maths/math";
  30801. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30802. import { Effect } from "babylonjs/Materials/effect";
  30803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30804. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30805. /**
  30806. * Interface to follow in your material defines to integrate easily the
  30807. * Image proccessing functions.
  30808. * @hidden
  30809. */
  30810. export interface IImageProcessingConfigurationDefines {
  30811. IMAGEPROCESSING: boolean;
  30812. VIGNETTE: boolean;
  30813. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30814. VIGNETTEBLENDMODEOPAQUE: boolean;
  30815. TONEMAPPING: boolean;
  30816. TONEMAPPING_ACES: boolean;
  30817. CONTRAST: boolean;
  30818. EXPOSURE: boolean;
  30819. COLORCURVES: boolean;
  30820. COLORGRADING: boolean;
  30821. COLORGRADING3D: boolean;
  30822. SAMPLER3DGREENDEPTH: boolean;
  30823. SAMPLER3DBGRMAP: boolean;
  30824. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30825. }
  30826. /**
  30827. * @hidden
  30828. */
  30829. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30830. IMAGEPROCESSING: boolean;
  30831. VIGNETTE: boolean;
  30832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30833. VIGNETTEBLENDMODEOPAQUE: boolean;
  30834. TONEMAPPING: boolean;
  30835. TONEMAPPING_ACES: boolean;
  30836. CONTRAST: boolean;
  30837. COLORCURVES: boolean;
  30838. COLORGRADING: boolean;
  30839. COLORGRADING3D: boolean;
  30840. SAMPLER3DGREENDEPTH: boolean;
  30841. SAMPLER3DBGRMAP: boolean;
  30842. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30843. EXPOSURE: boolean;
  30844. constructor();
  30845. }
  30846. /**
  30847. * This groups together the common properties used for image processing either in direct forward pass
  30848. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30849. * or not.
  30850. */
  30851. export class ImageProcessingConfiguration {
  30852. /**
  30853. * Default tone mapping applied in BabylonJS.
  30854. */
  30855. static readonly TONEMAPPING_STANDARD: number;
  30856. /**
  30857. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30858. * to other engines rendering to increase portability.
  30859. */
  30860. static readonly TONEMAPPING_ACES: number;
  30861. /**
  30862. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30863. */
  30864. colorCurves: Nullable<ColorCurves>;
  30865. private _colorCurvesEnabled;
  30866. /**
  30867. * Gets wether the color curves effect is enabled.
  30868. */
  30869. /**
  30870. * Sets wether the color curves effect is enabled.
  30871. */
  30872. colorCurvesEnabled: boolean;
  30873. private _colorGradingTexture;
  30874. /**
  30875. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30876. */
  30877. /**
  30878. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30879. */
  30880. colorGradingTexture: Nullable<BaseTexture>;
  30881. private _colorGradingEnabled;
  30882. /**
  30883. * Gets wether the color grading effect is enabled.
  30884. */
  30885. /**
  30886. * Sets wether the color grading effect is enabled.
  30887. */
  30888. colorGradingEnabled: boolean;
  30889. private _colorGradingWithGreenDepth;
  30890. /**
  30891. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30892. */
  30893. /**
  30894. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30895. */
  30896. colorGradingWithGreenDepth: boolean;
  30897. private _colorGradingBGR;
  30898. /**
  30899. * Gets wether the color grading texture contains BGR values.
  30900. */
  30901. /**
  30902. * Sets wether the color grading texture contains BGR values.
  30903. */
  30904. colorGradingBGR: boolean;
  30905. /** @hidden */
  30906. _exposure: number;
  30907. /**
  30908. * Gets the Exposure used in the effect.
  30909. */
  30910. /**
  30911. * Sets the Exposure used in the effect.
  30912. */
  30913. exposure: number;
  30914. private _toneMappingEnabled;
  30915. /**
  30916. * Gets wether the tone mapping effect is enabled.
  30917. */
  30918. /**
  30919. * Sets wether the tone mapping effect is enabled.
  30920. */
  30921. toneMappingEnabled: boolean;
  30922. private _toneMappingType;
  30923. /**
  30924. * Gets the type of tone mapping effect.
  30925. */
  30926. /**
  30927. * Sets the type of tone mapping effect used in BabylonJS.
  30928. */
  30929. toneMappingType: number;
  30930. protected _contrast: number;
  30931. /**
  30932. * Gets the contrast used in the effect.
  30933. */
  30934. /**
  30935. * Sets the contrast used in the effect.
  30936. */
  30937. contrast: number;
  30938. /**
  30939. * Vignette stretch size.
  30940. */
  30941. vignetteStretch: number;
  30942. /**
  30943. * Vignette centre X Offset.
  30944. */
  30945. vignetteCentreX: number;
  30946. /**
  30947. * Vignette centre Y Offset.
  30948. */
  30949. vignetteCentreY: number;
  30950. /**
  30951. * Vignette weight or intensity of the vignette effect.
  30952. */
  30953. vignetteWeight: number;
  30954. /**
  30955. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30956. * if vignetteEnabled is set to true.
  30957. */
  30958. vignetteColor: Color4;
  30959. /**
  30960. * Camera field of view used by the Vignette effect.
  30961. */
  30962. vignetteCameraFov: number;
  30963. private _vignetteBlendMode;
  30964. /**
  30965. * Gets the vignette blend mode allowing different kind of effect.
  30966. */
  30967. /**
  30968. * Sets the vignette blend mode allowing different kind of effect.
  30969. */
  30970. vignetteBlendMode: number;
  30971. private _vignetteEnabled;
  30972. /**
  30973. * Gets wether the vignette effect is enabled.
  30974. */
  30975. /**
  30976. * Sets wether the vignette effect is enabled.
  30977. */
  30978. vignetteEnabled: boolean;
  30979. private _applyByPostProcess;
  30980. /**
  30981. * Gets wether the image processing is applied through a post process or not.
  30982. */
  30983. /**
  30984. * Sets wether the image processing is applied through a post process or not.
  30985. */
  30986. applyByPostProcess: boolean;
  30987. private _isEnabled;
  30988. /**
  30989. * Gets wether the image processing is enabled or not.
  30990. */
  30991. /**
  30992. * Sets wether the image processing is enabled or not.
  30993. */
  30994. isEnabled: boolean;
  30995. /**
  30996. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30997. */
  30998. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30999. /**
  31000. * Method called each time the image processing information changes requires to recompile the effect.
  31001. */
  31002. protected _updateParameters(): void;
  31003. /**
  31004. * Gets the current class name.
  31005. * @return "ImageProcessingConfiguration"
  31006. */
  31007. getClassName(): string;
  31008. /**
  31009. * Prepare the list of uniforms associated with the Image Processing effects.
  31010. * @param uniforms The list of uniforms used in the effect
  31011. * @param defines the list of defines currently in use
  31012. */
  31013. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31014. /**
  31015. * Prepare the list of samplers associated with the Image Processing effects.
  31016. * @param samplersList The list of uniforms used in the effect
  31017. * @param defines the list of defines currently in use
  31018. */
  31019. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31020. /**
  31021. * Prepare the list of defines associated to the shader.
  31022. * @param defines the list of defines to complete
  31023. * @param forPostProcess Define if we are currently in post process mode or not
  31024. */
  31025. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31026. /**
  31027. * Returns true if all the image processing information are ready.
  31028. * @returns True if ready, otherwise, false
  31029. */
  31030. isReady(): boolean;
  31031. /**
  31032. * Binds the image processing to the shader.
  31033. * @param effect The effect to bind to
  31034. * @param aspectRatio Define the current aspect ratio of the effect
  31035. */
  31036. bind(effect: Effect, aspectRatio?: number): void;
  31037. /**
  31038. * Clones the current image processing instance.
  31039. * @return The cloned image processing
  31040. */
  31041. clone(): ImageProcessingConfiguration;
  31042. /**
  31043. * Serializes the current image processing instance to a json representation.
  31044. * @return a JSON representation
  31045. */
  31046. serialize(): any;
  31047. /**
  31048. * Parses the image processing from a json representation.
  31049. * @param source the JSON source to parse
  31050. * @return The parsed image processing
  31051. */
  31052. static Parse(source: any): ImageProcessingConfiguration;
  31053. private static _VIGNETTEMODE_MULTIPLY;
  31054. private static _VIGNETTEMODE_OPAQUE;
  31055. /**
  31056. * Used to apply the vignette as a mix with the pixel color.
  31057. */
  31058. static readonly VIGNETTEMODE_MULTIPLY: number;
  31059. /**
  31060. * Used to apply the vignette as a replacement of the pixel color.
  31061. */
  31062. static readonly VIGNETTEMODE_OPAQUE: number;
  31063. }
  31064. }
  31065. declare module "babylonjs/Materials/fresnelParameters" {
  31066. import { Color3 } from "babylonjs/Maths/math";
  31067. /**
  31068. * This represents all the required information to add a fresnel effect on a material:
  31069. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31070. */
  31071. export class FresnelParameters {
  31072. private _isEnabled;
  31073. /**
  31074. * Define if the fresnel effect is enable or not.
  31075. */
  31076. isEnabled: boolean;
  31077. /**
  31078. * Define the color used on edges (grazing angle)
  31079. */
  31080. leftColor: Color3;
  31081. /**
  31082. * Define the color used on center
  31083. */
  31084. rightColor: Color3;
  31085. /**
  31086. * Define bias applied to computed fresnel term
  31087. */
  31088. bias: number;
  31089. /**
  31090. * Defined the power exponent applied to fresnel term
  31091. */
  31092. power: number;
  31093. /**
  31094. * Clones the current fresnel and its valuues
  31095. * @returns a clone fresnel configuration
  31096. */
  31097. clone(): FresnelParameters;
  31098. /**
  31099. * Serializes the current fresnel parameters to a JSON representation.
  31100. * @return the JSON serialization
  31101. */
  31102. serialize(): any;
  31103. /**
  31104. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31105. * @param parsedFresnelParameters Define the JSON representation
  31106. * @returns the parsed parameters
  31107. */
  31108. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31109. }
  31110. }
  31111. declare module "babylonjs/Misc/decorators" {
  31112. import { Nullable } from "babylonjs/types";
  31113. import { Scene } from "babylonjs/scene";
  31114. import { IAnimatable } from "babylonjs/Misc/tools";
  31115. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31116. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31117. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31118. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31119. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31120. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31121. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31122. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31123. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31124. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31125. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31126. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31127. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31128. /**
  31129. * Decorator used to define property that can be serialized as reference to a camera
  31130. * @param sourceName defines the name of the property to decorate
  31131. */
  31132. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31133. /**
  31134. * Class used to help serialization objects
  31135. */
  31136. export class SerializationHelper {
  31137. /** @hidden */
  31138. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31139. /** @hidden */
  31140. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31141. /** @hidden */
  31142. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31143. /** @hidden */
  31144. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31145. /**
  31146. * Appends the serialized animations from the source animations
  31147. * @param source Source containing the animations
  31148. * @param destination Target to store the animations
  31149. */
  31150. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31151. /**
  31152. * Static function used to serialized a specific entity
  31153. * @param entity defines the entity to serialize
  31154. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31155. * @returns a JSON compatible object representing the serialization of the entity
  31156. */
  31157. static Serialize<T>(entity: T, serializationObject?: any): any;
  31158. /**
  31159. * Creates a new entity from a serialization data object
  31160. * @param creationFunction defines a function used to instanciated the new entity
  31161. * @param source defines the source serialization data
  31162. * @param scene defines the hosting scene
  31163. * @param rootUrl defines the root url for resources
  31164. * @returns a new entity
  31165. */
  31166. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31167. /**
  31168. * Clones an object
  31169. * @param creationFunction defines the function used to instanciate the new object
  31170. * @param source defines the source object
  31171. * @returns the cloned object
  31172. */
  31173. static Clone<T>(creationFunction: () => T, source: T): T;
  31174. /**
  31175. * Instanciates a new object based on a source one (some data will be shared between both object)
  31176. * @param creationFunction defines the function used to instanciate the new object
  31177. * @param source defines the source object
  31178. * @returns the new object
  31179. */
  31180. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31181. }
  31182. }
  31183. declare module "babylonjs/Cameras/camera" {
  31184. import { SmartArray } from "babylonjs/Misc/smartArray";
  31185. import { Observable } from "babylonjs/Misc/observable";
  31186. import { Nullable } from "babylonjs/types";
  31187. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31188. import { Scene } from "babylonjs/scene";
  31189. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31190. import { Node } from "babylonjs/node";
  31191. import { Mesh } from "babylonjs/Meshes/mesh";
  31192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31193. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31194. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31195. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31197. import { Ray } from "babylonjs/Culling/ray";
  31198. /**
  31199. * This is the base class of all the camera used in the application.
  31200. * @see http://doc.babylonjs.com/features/cameras
  31201. */
  31202. export class Camera extends Node {
  31203. /** @hidden */
  31204. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31205. /**
  31206. * This is the default projection mode used by the cameras.
  31207. * It helps recreating a feeling of perspective and better appreciate depth.
  31208. * This is the best way to simulate real life cameras.
  31209. */
  31210. static readonly PERSPECTIVE_CAMERA: number;
  31211. /**
  31212. * This helps creating camera with an orthographic mode.
  31213. * 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.
  31214. */
  31215. static readonly ORTHOGRAPHIC_CAMERA: number;
  31216. /**
  31217. * This is the default FOV mode for perspective cameras.
  31218. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31219. */
  31220. static readonly FOVMODE_VERTICAL_FIXED: number;
  31221. /**
  31222. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31223. */
  31224. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31225. /**
  31226. * This specifies ther is no need for a camera rig.
  31227. * Basically only one eye is rendered corresponding to the camera.
  31228. */
  31229. static readonly RIG_MODE_NONE: number;
  31230. /**
  31231. * Simulates a camera Rig with one blue eye and one red eye.
  31232. * This can be use with 3d blue and red glasses.
  31233. */
  31234. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31235. /**
  31236. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31237. */
  31238. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31239. /**
  31240. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31241. */
  31242. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31243. /**
  31244. * Defines that both eyes of the camera will be rendered over under each other.
  31245. */
  31246. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31247. /**
  31248. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31249. */
  31250. static readonly RIG_MODE_VR: number;
  31251. /**
  31252. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31253. */
  31254. static readonly RIG_MODE_WEBVR: number;
  31255. /**
  31256. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31257. */
  31258. static readonly RIG_MODE_CUSTOM: number;
  31259. /**
  31260. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31261. */
  31262. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31263. /**
  31264. * Define the input manager associated with the camera.
  31265. */
  31266. inputs: CameraInputsManager<Camera>;
  31267. /** @hidden */
  31268. _position: Vector3;
  31269. /**
  31270. * Define the current local position of the camera in the scene
  31271. */
  31272. position: Vector3;
  31273. /**
  31274. * The vector the camera should consider as up.
  31275. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31276. */
  31277. upVector: Vector3;
  31278. /**
  31279. * Define the current limit on the left side for an orthographic camera
  31280. * In scene unit
  31281. */
  31282. orthoLeft: Nullable<number>;
  31283. /**
  31284. * Define the current limit on the right side for an orthographic camera
  31285. * In scene unit
  31286. */
  31287. orthoRight: Nullable<number>;
  31288. /**
  31289. * Define the current limit on the bottom side for an orthographic camera
  31290. * In scene unit
  31291. */
  31292. orthoBottom: Nullable<number>;
  31293. /**
  31294. * Define the current limit on the top side for an orthographic camera
  31295. * In scene unit
  31296. */
  31297. orthoTop: Nullable<number>;
  31298. /**
  31299. * Field Of View is set in Radians. (default is 0.8)
  31300. */
  31301. fov: number;
  31302. /**
  31303. * Define the minimum distance the camera can see from.
  31304. * This is important to note that the depth buffer are not infinite and the closer it starts
  31305. * the more your scene might encounter depth fighting issue.
  31306. */
  31307. minZ: number;
  31308. /**
  31309. * Define the maximum distance the camera can see to.
  31310. * This is important to note that the depth buffer are not infinite and the further it end
  31311. * the more your scene might encounter depth fighting issue.
  31312. */
  31313. maxZ: number;
  31314. /**
  31315. * Define the default inertia of the camera.
  31316. * This helps giving a smooth feeling to the camera movement.
  31317. */
  31318. inertia: number;
  31319. /**
  31320. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31321. */
  31322. mode: number;
  31323. /**
  31324. * Define wether the camera is intermediate.
  31325. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31326. */
  31327. isIntermediate: boolean;
  31328. /**
  31329. * Define the viewport of the camera.
  31330. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31331. */
  31332. viewport: Viewport;
  31333. /**
  31334. * Restricts the camera to viewing objects with the same layerMask.
  31335. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31336. */
  31337. layerMask: number;
  31338. /**
  31339. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31340. */
  31341. fovMode: number;
  31342. /**
  31343. * Rig mode of the camera.
  31344. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31345. * This is normally controlled byt the camera themselves as internal use.
  31346. */
  31347. cameraRigMode: number;
  31348. /**
  31349. * Defines the distance between both "eyes" in case of a RIG
  31350. */
  31351. interaxialDistance: number;
  31352. /**
  31353. * Defines if stereoscopic rendering is done side by side or over under.
  31354. */
  31355. isStereoscopicSideBySide: boolean;
  31356. /**
  31357. * 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
  31358. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31359. * else in the scene.
  31360. */
  31361. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31362. /**
  31363. * When set, the camera will render to this render target instead of the default canvas
  31364. */
  31365. outputRenderTarget: Nullable<RenderTargetTexture>;
  31366. /**
  31367. * Observable triggered when the camera view matrix has changed.
  31368. */
  31369. onViewMatrixChangedObservable: Observable<Camera>;
  31370. /**
  31371. * Observable triggered when the camera Projection matrix has changed.
  31372. */
  31373. onProjectionMatrixChangedObservable: Observable<Camera>;
  31374. /**
  31375. * Observable triggered when the inputs have been processed.
  31376. */
  31377. onAfterCheckInputsObservable: Observable<Camera>;
  31378. /**
  31379. * Observable triggered when reset has been called and applied to the camera.
  31380. */
  31381. onRestoreStateObservable: Observable<Camera>;
  31382. /** @hidden */
  31383. _cameraRigParams: any;
  31384. /** @hidden */
  31385. _rigCameras: Camera[];
  31386. /** @hidden */
  31387. _rigPostProcess: Nullable<PostProcess>;
  31388. protected _webvrViewMatrix: Matrix;
  31389. /** @hidden */
  31390. _skipRendering: boolean;
  31391. /** @hidden */
  31392. _projectionMatrix: Matrix;
  31393. /** @hidden */
  31394. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31395. /** @hidden */
  31396. _activeMeshes: SmartArray<AbstractMesh>;
  31397. protected _globalPosition: Vector3;
  31398. /** @hidden */
  31399. _computedViewMatrix: Matrix;
  31400. private _doNotComputeProjectionMatrix;
  31401. private _transformMatrix;
  31402. private _frustumPlanes;
  31403. private _refreshFrustumPlanes;
  31404. private _storedFov;
  31405. private _stateStored;
  31406. /**
  31407. * Instantiates a new camera object.
  31408. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31409. * @see http://doc.babylonjs.com/features/cameras
  31410. * @param name Defines the name of the camera in the scene
  31411. * @param position Defines the position of the camera
  31412. * @param scene Defines the scene the camera belongs too
  31413. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31414. */
  31415. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31416. /**
  31417. * Store current camera state (fov, position, etc..)
  31418. * @returns the camera
  31419. */
  31420. storeState(): Camera;
  31421. /**
  31422. * Restores the camera state values if it has been stored. You must call storeState() first
  31423. */
  31424. protected _restoreStateValues(): boolean;
  31425. /**
  31426. * Restored camera state. You must call storeState() first.
  31427. * @returns true if restored and false otherwise
  31428. */
  31429. restoreState(): boolean;
  31430. /**
  31431. * Gets the class name of the camera.
  31432. * @returns the class name
  31433. */
  31434. getClassName(): string;
  31435. /** @hidden */
  31436. readonly _isCamera: boolean;
  31437. /**
  31438. * Gets a string representation of the camera useful for debug purpose.
  31439. * @param fullDetails Defines that a more verboe level of logging is required
  31440. * @returns the string representation
  31441. */
  31442. toString(fullDetails?: boolean): string;
  31443. /**
  31444. * Gets the current world space position of the camera.
  31445. */
  31446. readonly globalPosition: Vector3;
  31447. /**
  31448. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31449. * @returns the active meshe list
  31450. */
  31451. getActiveMeshes(): SmartArray<AbstractMesh>;
  31452. /**
  31453. * Check wether a mesh is part of the current active mesh list of the camera
  31454. * @param mesh Defines the mesh to check
  31455. * @returns true if active, false otherwise
  31456. */
  31457. isActiveMesh(mesh: Mesh): boolean;
  31458. /**
  31459. * Is this camera ready to be used/rendered
  31460. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31461. * @return true if the camera is ready
  31462. */
  31463. isReady(completeCheck?: boolean): boolean;
  31464. /** @hidden */
  31465. _initCache(): void;
  31466. /** @hidden */
  31467. _updateCache(ignoreParentClass?: boolean): void;
  31468. /** @hidden */
  31469. _isSynchronized(): boolean;
  31470. /** @hidden */
  31471. _isSynchronizedViewMatrix(): boolean;
  31472. /** @hidden */
  31473. _isSynchronizedProjectionMatrix(): boolean;
  31474. /**
  31475. * Attach the input controls to a specific dom element to get the input from.
  31476. * @param element Defines the element the controls should be listened from
  31477. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31478. */
  31479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31480. /**
  31481. * Detach the current controls from the specified dom element.
  31482. * @param element Defines the element to stop listening the inputs from
  31483. */
  31484. detachControl(element: HTMLElement): void;
  31485. /**
  31486. * Update the camera state according to the different inputs gathered during the frame.
  31487. */
  31488. update(): void;
  31489. /** @hidden */
  31490. _checkInputs(): void;
  31491. /** @hidden */
  31492. readonly rigCameras: Camera[];
  31493. /**
  31494. * Gets the post process used by the rig cameras
  31495. */
  31496. readonly rigPostProcess: Nullable<PostProcess>;
  31497. /**
  31498. * Internal, gets the first post proces.
  31499. * @returns the first post process to be run on this camera.
  31500. */
  31501. _getFirstPostProcess(): Nullable<PostProcess>;
  31502. private _cascadePostProcessesToRigCams;
  31503. /**
  31504. * Attach a post process to the camera.
  31505. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31506. * @param postProcess The post process to attach to the camera
  31507. * @param insertAt The position of the post process in case several of them are in use in the scene
  31508. * @returns the position the post process has been inserted at
  31509. */
  31510. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31511. /**
  31512. * Detach a post process to the camera.
  31513. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31514. * @param postProcess The post process to detach from the camera
  31515. */
  31516. detachPostProcess(postProcess: PostProcess): void;
  31517. /**
  31518. * Gets the current world matrix of the camera
  31519. */
  31520. getWorldMatrix(): Matrix;
  31521. /** @hidden */
  31522. _getViewMatrix(): Matrix;
  31523. /**
  31524. * Gets the current view matrix of the camera.
  31525. * @param force forces the camera to recompute the matrix without looking at the cached state
  31526. * @returns the view matrix
  31527. */
  31528. getViewMatrix(force?: boolean): Matrix;
  31529. /**
  31530. * Freeze the projection matrix.
  31531. * It will prevent the cache check of the camera projection compute and can speed up perf
  31532. * if no parameter of the camera are meant to change
  31533. * @param projection Defines manually a projection if necessary
  31534. */
  31535. freezeProjectionMatrix(projection?: Matrix): void;
  31536. /**
  31537. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31538. */
  31539. unfreezeProjectionMatrix(): void;
  31540. /**
  31541. * Gets the current projection matrix of the camera.
  31542. * @param force forces the camera to recompute the matrix without looking at the cached state
  31543. * @returns the projection matrix
  31544. */
  31545. getProjectionMatrix(force?: boolean): Matrix;
  31546. /**
  31547. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31548. * @returns a Matrix
  31549. */
  31550. getTransformationMatrix(): Matrix;
  31551. private _updateFrustumPlanes;
  31552. /**
  31553. * Checks if a cullable object (mesh...) is in the camera frustum
  31554. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31555. * @param target The object to check
  31556. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31557. * @returns true if the object is in frustum otherwise false
  31558. */
  31559. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31560. /**
  31561. * Checks if a cullable object (mesh...) is in the camera frustum
  31562. * Unlike isInFrustum this cheks the full bounding box
  31563. * @param target The object to check
  31564. * @returns true if the object is in frustum otherwise false
  31565. */
  31566. isCompletelyInFrustum(target: ICullable): boolean;
  31567. /**
  31568. * Gets a ray in the forward direction from the camera.
  31569. * @param length Defines the length of the ray to create
  31570. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31571. * @param origin Defines the start point of the ray which defaults to the camera position
  31572. * @returns the forward ray
  31573. */
  31574. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31575. /**
  31576. * Releases resources associated with this node.
  31577. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31578. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31579. */
  31580. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31581. /** @hidden */
  31582. _isLeftCamera: boolean;
  31583. /**
  31584. * Gets the left camera of a rig setup in case of Rigged Camera
  31585. */
  31586. readonly isLeftCamera: boolean;
  31587. /** @hidden */
  31588. _isRightCamera: boolean;
  31589. /**
  31590. * Gets the right camera of a rig setup in case of Rigged Camera
  31591. */
  31592. readonly isRightCamera: boolean;
  31593. /**
  31594. * Gets the left camera of a rig setup in case of Rigged Camera
  31595. */
  31596. readonly leftCamera: Nullable<FreeCamera>;
  31597. /**
  31598. * Gets the right camera of a rig setup in case of Rigged Camera
  31599. */
  31600. readonly rightCamera: Nullable<FreeCamera>;
  31601. /**
  31602. * Gets the left camera target of a rig setup in case of Rigged Camera
  31603. * @returns the target position
  31604. */
  31605. getLeftTarget(): Nullable<Vector3>;
  31606. /**
  31607. * Gets the right camera target of a rig setup in case of Rigged Camera
  31608. * @returns the target position
  31609. */
  31610. getRightTarget(): Nullable<Vector3>;
  31611. /**
  31612. * @hidden
  31613. */
  31614. setCameraRigMode(mode: number, rigParams: any): void;
  31615. /** @hidden */
  31616. static _setStereoscopicRigMode(camera: Camera): void;
  31617. /** @hidden */
  31618. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31619. /** @hidden */
  31620. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31621. /** @hidden */
  31622. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31623. /** @hidden */
  31624. _getVRProjectionMatrix(): Matrix;
  31625. protected _updateCameraRotationMatrix(): void;
  31626. protected _updateWebVRCameraRotationMatrix(): void;
  31627. /**
  31628. * This function MUST be overwritten by the different WebVR cameras available.
  31629. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31630. * @hidden
  31631. */
  31632. _getWebVRProjectionMatrix(): Matrix;
  31633. /**
  31634. * This function MUST be overwritten by the different WebVR cameras available.
  31635. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31636. * @hidden
  31637. */
  31638. _getWebVRViewMatrix(): Matrix;
  31639. /** @hidden */
  31640. setCameraRigParameter(name: string, value: any): void;
  31641. /**
  31642. * needs to be overridden by children so sub has required properties to be copied
  31643. * @hidden
  31644. */
  31645. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31646. /**
  31647. * May need to be overridden by children
  31648. * @hidden
  31649. */
  31650. _updateRigCameras(): void;
  31651. /** @hidden */
  31652. _setupInputs(): void;
  31653. /**
  31654. * Serialiaze the camera setup to a json represention
  31655. * @returns the JSON representation
  31656. */
  31657. serialize(): any;
  31658. /**
  31659. * Clones the current camera.
  31660. * @param name The cloned camera name
  31661. * @returns the cloned camera
  31662. */
  31663. clone(name: string): Camera;
  31664. /**
  31665. * Gets the direction of the camera relative to a given local axis.
  31666. * @param localAxis Defines the reference axis to provide a relative direction.
  31667. * @return the direction
  31668. */
  31669. getDirection(localAxis: Vector3): Vector3;
  31670. /**
  31671. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31672. * @param localAxis Defines the reference axis to provide a relative direction.
  31673. * @param result Defines the vector to store the result in
  31674. */
  31675. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31676. /**
  31677. * Gets a camera constructor for a given camera type
  31678. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31679. * @param name The name of the camera the result will be able to instantiate
  31680. * @param scene The scene the result will construct the camera in
  31681. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31682. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31683. * @returns a factory method to construc the camera
  31684. */
  31685. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31686. /**
  31687. * Compute the world matrix of the camera.
  31688. * @returns the camera workd matrix
  31689. */
  31690. computeWorldMatrix(): Matrix;
  31691. /**
  31692. * Parse a JSON and creates the camera from the parsed information
  31693. * @param parsedCamera The JSON to parse
  31694. * @param scene The scene to instantiate the camera in
  31695. * @returns the newly constructed camera
  31696. */
  31697. static Parse(parsedCamera: any, scene: Scene): Camera;
  31698. }
  31699. }
  31700. declare module "babylonjs/Misc/tools" {
  31701. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31702. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31703. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31704. import { Observable } from "babylonjs/Misc/observable";
  31705. import { DomManagement } from "babylonjs/Misc/domManagement";
  31706. import { WebRequest } from "babylonjs/Misc/webRequest";
  31707. import { Camera } from "babylonjs/Cameras/camera";
  31708. import { Engine } from "babylonjs/Engines/engine";
  31709. import { Animation } from "babylonjs/Animations/animation";
  31710. /**
  31711. * Interface for any object that can request an animation frame
  31712. */
  31713. export interface ICustomAnimationFrameRequester {
  31714. /**
  31715. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31716. */
  31717. renderFunction?: Function;
  31718. /**
  31719. * Called to request the next frame to render to
  31720. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31721. */
  31722. requestAnimationFrame: Function;
  31723. /**
  31724. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31725. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31726. */
  31727. requestID?: number;
  31728. }
  31729. /**
  31730. * Interface containing an array of animations
  31731. */
  31732. export interface IAnimatable {
  31733. /**
  31734. * Array of animations
  31735. */
  31736. animations: Nullable<Array<Animation>>;
  31737. }
  31738. /** Interface used by value gradients (color, factor, ...) */
  31739. export interface IValueGradient {
  31740. /**
  31741. * Gets or sets the gradient value (between 0 and 1)
  31742. */
  31743. gradient: number;
  31744. }
  31745. /** Class used to store color4 gradient */
  31746. export class ColorGradient implements IValueGradient {
  31747. /**
  31748. * Gets or sets the gradient value (between 0 and 1)
  31749. */
  31750. gradient: number;
  31751. /**
  31752. * Gets or sets first associated color
  31753. */
  31754. color1: Color4;
  31755. /**
  31756. * Gets or sets second associated color
  31757. */
  31758. color2?: Color4;
  31759. /**
  31760. * Will get a color picked randomly between color1 and color2.
  31761. * If color2 is undefined then color1 will be used
  31762. * @param result defines the target Color4 to store the result in
  31763. */
  31764. getColorToRef(result: Color4): void;
  31765. }
  31766. /** Class used to store color 3 gradient */
  31767. export class Color3Gradient implements IValueGradient {
  31768. /**
  31769. * Gets or sets the gradient value (between 0 and 1)
  31770. */
  31771. gradient: number;
  31772. /**
  31773. * Gets or sets the associated color
  31774. */
  31775. color: Color3;
  31776. }
  31777. /** Class used to store factor gradient */
  31778. export class FactorGradient implements IValueGradient {
  31779. /**
  31780. * Gets or sets the gradient value (between 0 and 1)
  31781. */
  31782. gradient: number;
  31783. /**
  31784. * Gets or sets first associated factor
  31785. */
  31786. factor1: number;
  31787. /**
  31788. * Gets or sets second associated factor
  31789. */
  31790. factor2?: number;
  31791. /**
  31792. * Will get a number picked randomly between factor1 and factor2.
  31793. * If factor2 is undefined then factor1 will be used
  31794. * @returns the picked number
  31795. */
  31796. getFactor(): number;
  31797. }
  31798. /**
  31799. * @ignore
  31800. * Application error to support additional information when loading a file
  31801. */
  31802. export class LoadFileError extends Error {
  31803. /** defines the optional web request */
  31804. request?: WebRequest | undefined;
  31805. private static _setPrototypeOf;
  31806. /**
  31807. * Creates a new LoadFileError
  31808. * @param message defines the message of the error
  31809. * @param request defines the optional web request
  31810. */
  31811. constructor(message: string,
  31812. /** defines the optional web request */
  31813. request?: WebRequest | undefined);
  31814. }
  31815. /**
  31816. * Class used to define a retry strategy when error happens while loading assets
  31817. */
  31818. export class RetryStrategy {
  31819. /**
  31820. * Function used to defines an exponential back off strategy
  31821. * @param maxRetries defines the maximum number of retries (3 by default)
  31822. * @param baseInterval defines the interval between retries
  31823. * @returns the strategy function to use
  31824. */
  31825. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31826. }
  31827. /**
  31828. * File request interface
  31829. */
  31830. export interface IFileRequest {
  31831. /**
  31832. * Raised when the request is complete (success or error).
  31833. */
  31834. onCompleteObservable: Observable<IFileRequest>;
  31835. /**
  31836. * Aborts the request for a file.
  31837. */
  31838. abort: () => void;
  31839. }
  31840. /**
  31841. * Class containing a set of static utilities functions
  31842. */
  31843. export class Tools {
  31844. /**
  31845. * Gets or sets the base URL to use to load assets
  31846. */
  31847. static BaseUrl: string;
  31848. /**
  31849. * Enable/Disable Custom HTTP Request Headers globally.
  31850. * default = false
  31851. * @see CustomRequestHeaders
  31852. */
  31853. static UseCustomRequestHeaders: boolean;
  31854. /**
  31855. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31856. * i.e. when loading files, where the server/service expects an Authorization header
  31857. */
  31858. static CustomRequestHeaders: {
  31859. [key: string]: string;
  31860. };
  31861. /**
  31862. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31863. */
  31864. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31865. /**
  31866. * Default behaviour for cors in the application.
  31867. * It can be a string if the expected behavior is identical in the entire app.
  31868. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31869. */
  31870. static CorsBehavior: string | ((url: string | string[]) => string);
  31871. /**
  31872. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31873. * @ignorenaming
  31874. */
  31875. static UseFallbackTexture: boolean;
  31876. /**
  31877. * Use this object to register external classes like custom textures or material
  31878. * to allow the laoders to instantiate them
  31879. */
  31880. static RegisteredExternalClasses: {
  31881. [key: string]: Object;
  31882. };
  31883. /**
  31884. * Texture content used if a texture cannot loaded
  31885. * @ignorenaming
  31886. */
  31887. static fallbackTexture: string;
  31888. /**
  31889. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31890. * @param u defines the coordinate on X axis
  31891. * @param v defines the coordinate on Y axis
  31892. * @param width defines the width of the source data
  31893. * @param height defines the height of the source data
  31894. * @param pixels defines the source byte array
  31895. * @param color defines the output color
  31896. */
  31897. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31898. /**
  31899. * Interpolates between a and b via alpha
  31900. * @param a The lower value (returned when alpha = 0)
  31901. * @param b The upper value (returned when alpha = 1)
  31902. * @param alpha The interpolation-factor
  31903. * @return The mixed value
  31904. */
  31905. static Mix(a: number, b: number, alpha: number): number;
  31906. /**
  31907. * Tries to instantiate a new object from a given class name
  31908. * @param className defines the class name to instantiate
  31909. * @returns the new object or null if the system was not able to do the instantiation
  31910. */
  31911. static Instantiate(className: string): any;
  31912. /**
  31913. * Provides a slice function that will work even on IE
  31914. * @param data defines the array to slice
  31915. * @param start defines the start of the data (optional)
  31916. * @param end defines the end of the data (optional)
  31917. * @returns the new sliced array
  31918. */
  31919. static Slice<T>(data: T, start?: number, end?: number): T;
  31920. /**
  31921. * Polyfill for setImmediate
  31922. * @param action defines the action to execute after the current execution block
  31923. */
  31924. static SetImmediate(action: () => void): void;
  31925. /**
  31926. * Function indicating if a number is an exponent of 2
  31927. * @param value defines the value to test
  31928. * @returns true if the value is an exponent of 2
  31929. */
  31930. static IsExponentOfTwo(value: number): boolean;
  31931. private static _tmpFloatArray;
  31932. /**
  31933. * Returns the nearest 32-bit single precision float representation of a Number
  31934. * @param value A Number. If the parameter is of a different type, it will get converted
  31935. * to a number or to NaN if it cannot be converted
  31936. * @returns number
  31937. */
  31938. static FloatRound(value: number): number;
  31939. /**
  31940. * Find the next highest power of two.
  31941. * @param x Number to start search from.
  31942. * @return Next highest power of two.
  31943. */
  31944. static CeilingPOT(x: number): number;
  31945. /**
  31946. * Find the next lowest power of two.
  31947. * @param x Number to start search from.
  31948. * @return Next lowest power of two.
  31949. */
  31950. static FloorPOT(x: number): number;
  31951. /**
  31952. * Find the nearest power of two.
  31953. * @param x Number to start search from.
  31954. * @return Next nearest power of two.
  31955. */
  31956. static NearestPOT(x: number): number;
  31957. /**
  31958. * Get the closest exponent of two
  31959. * @param value defines the value to approximate
  31960. * @param max defines the maximum value to return
  31961. * @param mode defines how to define the closest value
  31962. * @returns closest exponent of two of the given value
  31963. */
  31964. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31965. /**
  31966. * Extracts the filename from a path
  31967. * @param path defines the path to use
  31968. * @returns the filename
  31969. */
  31970. static GetFilename(path: string): string;
  31971. /**
  31972. * Extracts the "folder" part of a path (everything before the filename).
  31973. * @param uri The URI to extract the info from
  31974. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31975. * @returns The "folder" part of the path
  31976. */
  31977. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31978. /**
  31979. * Extracts text content from a DOM element hierarchy
  31980. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31981. */
  31982. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31983. /**
  31984. * Convert an angle in radians to degrees
  31985. * @param angle defines the angle to convert
  31986. * @returns the angle in degrees
  31987. */
  31988. static ToDegrees(angle: number): number;
  31989. /**
  31990. * Convert an angle in degrees to radians
  31991. * @param angle defines the angle to convert
  31992. * @returns the angle in radians
  31993. */
  31994. static ToRadians(angle: number): number;
  31995. /**
  31996. * Encode a buffer to a base64 string
  31997. * @param buffer defines the buffer to encode
  31998. * @returns the encoded string
  31999. */
  32000. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32001. /**
  32002. * Extracts minimum and maximum values from a list of indexed positions
  32003. * @param positions defines the positions to use
  32004. * @param indices defines the indices to the positions
  32005. * @param indexStart defines the start index
  32006. * @param indexCount defines the end index
  32007. * @param bias defines bias value to add to the result
  32008. * @return minimum and maximum values
  32009. */
  32010. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32011. minimum: Vector3;
  32012. maximum: Vector3;
  32013. };
  32014. /**
  32015. * Extracts minimum and maximum values from a list of positions
  32016. * @param positions defines the positions to use
  32017. * @param start defines the start index in the positions array
  32018. * @param count defines the number of positions to handle
  32019. * @param bias defines bias value to add to the result
  32020. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32021. * @return minimum and maximum values
  32022. */
  32023. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32024. minimum: Vector3;
  32025. maximum: Vector3;
  32026. };
  32027. /**
  32028. * Returns an array if obj is not an array
  32029. * @param obj defines the object to evaluate as an array
  32030. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32031. * @returns either obj directly if obj is an array or a new array containing obj
  32032. */
  32033. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32034. /**
  32035. * Gets the pointer prefix to use
  32036. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32037. */
  32038. static GetPointerPrefix(): string;
  32039. /**
  32040. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32041. * @param func - the function to be called
  32042. * @param requester - the object that will request the next frame. Falls back to window.
  32043. * @returns frame number
  32044. */
  32045. static QueueNewFrame(func: () => void, requester?: any): number;
  32046. /**
  32047. * Ask the browser to promote the current element to fullscreen rendering mode
  32048. * @param element defines the DOM element to promote
  32049. */
  32050. static RequestFullscreen(element: HTMLElement): void;
  32051. /**
  32052. * Asks the browser to exit fullscreen mode
  32053. */
  32054. static ExitFullscreen(): void;
  32055. /**
  32056. * Ask the browser to promote the current element to pointerlock mode
  32057. * @param element defines the DOM element to promote
  32058. */
  32059. static RequestPointerlock(element: HTMLElement): void;
  32060. /**
  32061. * Asks the browser to exit pointerlock mode
  32062. */
  32063. static ExitPointerlock(): void;
  32064. /**
  32065. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32066. * @param url define the url we are trying
  32067. * @param element define the dom element where to configure the cors policy
  32068. */
  32069. static SetCorsBehavior(url: string | string[], element: {
  32070. crossOrigin: string | null;
  32071. }): void;
  32072. /**
  32073. * Removes unwanted characters from an url
  32074. * @param url defines the url to clean
  32075. * @returns the cleaned url
  32076. */
  32077. static CleanUrl(url: string): string;
  32078. /**
  32079. * Gets or sets a function used to pre-process url before using them to load assets
  32080. */
  32081. static PreprocessUrl: (url: string) => string;
  32082. /**
  32083. * Loads an image as an HTMLImageElement.
  32084. * @param input url string, ArrayBuffer, or Blob to load
  32085. * @param onLoad callback called when the image successfully loads
  32086. * @param onError callback called when the image fails to load
  32087. * @param offlineProvider offline provider for caching
  32088. * @returns the HTMLImageElement of the loaded image
  32089. */
  32090. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32091. /**
  32092. * Loads a file
  32093. * @param url url string, ArrayBuffer, or Blob to load
  32094. * @param onSuccess callback called when the file successfully loads
  32095. * @param onProgress callback called while file is loading (if the server supports this mode)
  32096. * @param offlineProvider defines the offline provider for caching
  32097. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32098. * @param onError callback called when the file fails to load
  32099. * @returns a file request object
  32100. */
  32101. 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;
  32102. /**
  32103. * Load a script (identified by an url). When the url returns, the
  32104. * content of this file is added into a new script element, attached to the DOM (body element)
  32105. * @param scriptUrl defines the url of the script to laod
  32106. * @param onSuccess defines the callback called when the script is loaded
  32107. * @param onError defines the callback to call if an error occurs
  32108. * @param scriptId defines the id of the script element
  32109. */
  32110. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32111. /**
  32112. * Load an asynchronous script (identified by an url). When the url returns, the
  32113. * content of this file is added into a new script element, attached to the DOM (body element)
  32114. * @param scriptUrl defines the url of the script to laod
  32115. * @param scriptId defines the id of the script element
  32116. * @returns a promise request object
  32117. */
  32118. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  32119. /**
  32120. * Loads a file from a blob
  32121. * @param fileToLoad defines the blob to use
  32122. * @param callback defines the callback to call when data is loaded
  32123. * @param progressCallback defines the callback to call during loading process
  32124. * @returns a file request object
  32125. */
  32126. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32127. /**
  32128. * Loads a file
  32129. * @param fileToLoad defines the file to load
  32130. * @param callback defines the callback to call when data is loaded
  32131. * @param progressCallBack defines the callback to call during loading process
  32132. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32133. * @returns a file request object
  32134. */
  32135. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32136. /**
  32137. * Creates a data url from a given string content
  32138. * @param content defines the content to convert
  32139. * @returns the new data url link
  32140. */
  32141. static FileAsURL(content: string): string;
  32142. /**
  32143. * Format the given number to a specific decimal format
  32144. * @param value defines the number to format
  32145. * @param decimals defines the number of decimals to use
  32146. * @returns the formatted string
  32147. */
  32148. static Format(value: number, decimals?: number): string;
  32149. /**
  32150. * Checks if a given vector is inside a specific range
  32151. * @param v defines the vector to test
  32152. * @param min defines the minimum range
  32153. * @param max defines the maximum range
  32154. */
  32155. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32156. /**
  32157. * Tries to copy an object by duplicating every property
  32158. * @param source defines the source object
  32159. * @param destination defines the target object
  32160. * @param doNotCopyList defines a list of properties to avoid
  32161. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32162. */
  32163. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32164. /**
  32165. * Gets a boolean indicating if the given object has no own property
  32166. * @param obj defines the object to test
  32167. * @returns true if object has no own property
  32168. */
  32169. static IsEmpty(obj: any): boolean;
  32170. /**
  32171. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32172. * @param str Source string
  32173. * @param suffix Suffix to search for in the source string
  32174. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32175. */
  32176. static EndsWith(str: string, suffix: string): boolean;
  32177. /**
  32178. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32179. * @param str Source string
  32180. * @param suffix Suffix to search for in the source string
  32181. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32182. */
  32183. static StartsWith(str: string, suffix: string): boolean;
  32184. /**
  32185. * Function used to register events at window level
  32186. * @param events defines the events to register
  32187. */
  32188. static RegisterTopRootEvents(events: {
  32189. name: string;
  32190. handler: Nullable<(e: FocusEvent) => any>;
  32191. }[]): void;
  32192. /**
  32193. * Function used to unregister events from window level
  32194. * @param events defines the events to unregister
  32195. */
  32196. static UnregisterTopRootEvents(events: {
  32197. name: string;
  32198. handler: Nullable<(e: FocusEvent) => any>;
  32199. }[]): void;
  32200. /**
  32201. * @ignore
  32202. */
  32203. static _ScreenshotCanvas: HTMLCanvasElement;
  32204. /**
  32205. * Dumps the current bound framebuffer
  32206. * @param width defines the rendering width
  32207. * @param height defines the rendering height
  32208. * @param engine defines the hosting engine
  32209. * @param successCallback defines the callback triggered once the data are available
  32210. * @param mimeType defines the mime type of the result
  32211. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32212. */
  32213. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32214. /**
  32215. * Converts the canvas data to blob.
  32216. * This acts as a polyfill for browsers not supporting the to blob function.
  32217. * @param canvas Defines the canvas to extract the data from
  32218. * @param successCallback Defines the callback triggered once the data are available
  32219. * @param mimeType Defines the mime type of the result
  32220. */
  32221. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32222. /**
  32223. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32224. * @param successCallback defines the callback triggered once the data are available
  32225. * @param mimeType defines the mime type of the result
  32226. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32227. */
  32228. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32229. /**
  32230. * Downloads a blob in the browser
  32231. * @param blob defines the blob to download
  32232. * @param fileName defines the name of the downloaded file
  32233. */
  32234. static Download(blob: Blob, fileName: string): void;
  32235. /**
  32236. * Captures a screenshot of the current rendering
  32237. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32238. * @param engine defines the rendering engine
  32239. * @param camera defines the source camera
  32240. * @param size This parameter can be set to a single number or to an object with the
  32241. * following (optional) properties: precision, width, height. If a single number is passed,
  32242. * it will be used for both width and height. If an object is passed, the screenshot size
  32243. * will be derived from the parameters. The precision property is a multiplier allowing
  32244. * rendering at a higher or lower resolution
  32245. * @param successCallback defines the callback receives a single parameter which contains the
  32246. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32247. * src parameter of an <img> to display it
  32248. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32249. * Check your browser for supported MIME types
  32250. */
  32251. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32252. /**
  32253. * Generates an image screenshot from the specified camera.
  32254. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32255. * @param engine The engine to use for rendering
  32256. * @param camera The camera to use for rendering
  32257. * @param size This parameter can be set to a single number or to an object with the
  32258. * following (optional) properties: precision, width, height. If a single number is passed,
  32259. * it will be used for both width and height. If an object is passed, the screenshot size
  32260. * will be derived from the parameters. The precision property is a multiplier allowing
  32261. * rendering at a higher or lower resolution
  32262. * @param successCallback The callback receives a single parameter which contains the
  32263. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32264. * src parameter of an <img> to display it
  32265. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32266. * Check your browser for supported MIME types
  32267. * @param samples Texture samples (default: 1)
  32268. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32269. * @param fileName A name for for the downloaded file.
  32270. */
  32271. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32272. /**
  32273. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32274. * Be aware Math.random() could cause collisions, but:
  32275. * "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"
  32276. * @returns a pseudo random id
  32277. */
  32278. static RandomId(): string;
  32279. /**
  32280. * Test if the given uri is a base64 string
  32281. * @param uri The uri to test
  32282. * @return True if the uri is a base64 string or false otherwise
  32283. */
  32284. static IsBase64(uri: string): boolean;
  32285. /**
  32286. * Decode the given base64 uri.
  32287. * @param uri The uri to decode
  32288. * @return The decoded base64 data.
  32289. */
  32290. static DecodeBase64(uri: string): ArrayBuffer;
  32291. /**
  32292. * Gets the absolute url.
  32293. * @param url the input url
  32294. * @return the absolute url
  32295. */
  32296. static GetAbsoluteUrl(url: string): string;
  32297. /**
  32298. * No log
  32299. */
  32300. static readonly NoneLogLevel: number;
  32301. /**
  32302. * Only message logs
  32303. */
  32304. static readonly MessageLogLevel: number;
  32305. /**
  32306. * Only warning logs
  32307. */
  32308. static readonly WarningLogLevel: number;
  32309. /**
  32310. * Only error logs
  32311. */
  32312. static readonly ErrorLogLevel: number;
  32313. /**
  32314. * All logs
  32315. */
  32316. static readonly AllLogLevel: number;
  32317. /**
  32318. * Gets a value indicating the number of loading errors
  32319. * @ignorenaming
  32320. */
  32321. static readonly errorsCount: number;
  32322. /**
  32323. * Callback called when a new log is added
  32324. */
  32325. static OnNewCacheEntry: (entry: string) => void;
  32326. /**
  32327. * Log a message to the console
  32328. * @param message defines the message to log
  32329. */
  32330. static Log(message: string): void;
  32331. /**
  32332. * Write a warning message to the console
  32333. * @param message defines the message to log
  32334. */
  32335. static Warn(message: string): void;
  32336. /**
  32337. * Write an error message to the console
  32338. * @param message defines the message to log
  32339. */
  32340. static Error(message: string): void;
  32341. /**
  32342. * Gets current log cache (list of logs)
  32343. */
  32344. static readonly LogCache: string;
  32345. /**
  32346. * Clears the log cache
  32347. */
  32348. static ClearLogCache(): void;
  32349. /**
  32350. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32351. */
  32352. static LogLevels: number;
  32353. /**
  32354. * Checks if the loaded document was accessed via `file:`-Protocol.
  32355. * @returns boolean
  32356. */
  32357. static IsFileURL(): boolean;
  32358. /**
  32359. * Checks if the window object exists
  32360. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32361. */
  32362. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32363. /**
  32364. * No performance log
  32365. */
  32366. static readonly PerformanceNoneLogLevel: number;
  32367. /**
  32368. * Use user marks to log performance
  32369. */
  32370. static readonly PerformanceUserMarkLogLevel: number;
  32371. /**
  32372. * Log performance to the console
  32373. */
  32374. static readonly PerformanceConsoleLogLevel: number;
  32375. private static _performance;
  32376. /**
  32377. * Sets the current performance log level
  32378. */
  32379. static PerformanceLogLevel: number;
  32380. private static _StartPerformanceCounterDisabled;
  32381. private static _EndPerformanceCounterDisabled;
  32382. private static _StartUserMark;
  32383. private static _EndUserMark;
  32384. private static _StartPerformanceConsole;
  32385. private static _EndPerformanceConsole;
  32386. /**
  32387. * Starts a performance counter
  32388. */
  32389. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32390. /**
  32391. * Ends a specific performance coutner
  32392. */
  32393. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32394. /**
  32395. * Gets either window.performance.now() if supported or Date.now() else
  32396. */
  32397. static readonly Now: number;
  32398. /**
  32399. * This method will return the name of the class used to create the instance of the given object.
  32400. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32401. * @param object the object to get the class name from
  32402. * @param isType defines if the object is actually a type
  32403. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32404. */
  32405. static GetClassName(object: any, isType?: boolean): string;
  32406. /**
  32407. * Gets the first element of an array satisfying a given predicate
  32408. * @param array defines the array to browse
  32409. * @param predicate defines the predicate to use
  32410. * @returns null if not found or the element
  32411. */
  32412. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32413. /**
  32414. * This method will return the name of the full name of the class, including its owning module (if any).
  32415. * 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).
  32416. * @param object the object to get the class name from
  32417. * @param isType defines if the object is actually a type
  32418. * @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.
  32419. * @ignorenaming
  32420. */
  32421. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32422. /**
  32423. * Returns a promise that resolves after the given amount of time.
  32424. * @param delay Number of milliseconds to delay
  32425. * @returns Promise that resolves after the given amount of time
  32426. */
  32427. static DelayAsync(delay: number): Promise<void>;
  32428. /**
  32429. * Gets the current gradient from an array of IValueGradient
  32430. * @param ratio defines the current ratio to get
  32431. * @param gradients defines the array of IValueGradient
  32432. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32433. */
  32434. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32435. }
  32436. /**
  32437. * This class is used to track a performance counter which is number based.
  32438. * The user has access to many properties which give statistics of different nature.
  32439. *
  32440. * The implementer can track two kinds of Performance Counter: time and count.
  32441. * 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.
  32442. * 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.
  32443. */
  32444. export class PerfCounter {
  32445. /**
  32446. * Gets or sets a global boolean to turn on and off all the counters
  32447. */
  32448. static Enabled: boolean;
  32449. /**
  32450. * Returns the smallest value ever
  32451. */
  32452. readonly min: number;
  32453. /**
  32454. * Returns the biggest value ever
  32455. */
  32456. readonly max: number;
  32457. /**
  32458. * Returns the average value since the performance counter is running
  32459. */
  32460. readonly average: number;
  32461. /**
  32462. * Returns the average value of the last second the counter was monitored
  32463. */
  32464. readonly lastSecAverage: number;
  32465. /**
  32466. * Returns the current value
  32467. */
  32468. readonly current: number;
  32469. /**
  32470. * Gets the accumulated total
  32471. */
  32472. readonly total: number;
  32473. /**
  32474. * Gets the total value count
  32475. */
  32476. readonly count: number;
  32477. /**
  32478. * Creates a new counter
  32479. */
  32480. constructor();
  32481. /**
  32482. * Call this method to start monitoring a new frame.
  32483. * 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.
  32484. */
  32485. fetchNewFrame(): void;
  32486. /**
  32487. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32488. * @param newCount the count value to add to the monitored count
  32489. * @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.
  32490. */
  32491. addCount(newCount: number, fetchResult: boolean): void;
  32492. /**
  32493. * Start monitoring this performance counter
  32494. */
  32495. beginMonitoring(): void;
  32496. /**
  32497. * Compute the time lapsed since the previous beginMonitoring() call.
  32498. * @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
  32499. */
  32500. endMonitoring(newFrame?: boolean): void;
  32501. private _fetchResult;
  32502. private _startMonitoringTime;
  32503. private _min;
  32504. private _max;
  32505. private _average;
  32506. private _current;
  32507. private _totalValueCount;
  32508. private _totalAccumulated;
  32509. private _lastSecAverage;
  32510. private _lastSecAccumulated;
  32511. private _lastSecTime;
  32512. private _lastSecValueCount;
  32513. }
  32514. /**
  32515. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32516. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32517. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32518. * @param name The name of the class, case should be preserved
  32519. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32520. */
  32521. export function className(name: string, module?: string): (target: Object) => void;
  32522. /**
  32523. * An implementation of a loop for asynchronous functions.
  32524. */
  32525. export class AsyncLoop {
  32526. /**
  32527. * Defines the number of iterations for the loop
  32528. */
  32529. iterations: number;
  32530. /**
  32531. * Defines the current index of the loop.
  32532. */
  32533. index: number;
  32534. private _done;
  32535. private _fn;
  32536. private _successCallback;
  32537. /**
  32538. * Constructor.
  32539. * @param iterations the number of iterations.
  32540. * @param func the function to run each iteration
  32541. * @param successCallback the callback that will be called upon succesful execution
  32542. * @param offset starting offset.
  32543. */
  32544. constructor(
  32545. /**
  32546. * Defines the number of iterations for the loop
  32547. */
  32548. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32549. /**
  32550. * Execute the next iteration. Must be called after the last iteration was finished.
  32551. */
  32552. executeNext(): void;
  32553. /**
  32554. * Break the loop and run the success callback.
  32555. */
  32556. breakLoop(): void;
  32557. /**
  32558. * Create and run an async loop.
  32559. * @param iterations the number of iterations.
  32560. * @param fn the function to run each iteration
  32561. * @param successCallback the callback that will be called upon succesful execution
  32562. * @param offset starting offset.
  32563. * @returns the created async loop object
  32564. */
  32565. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32566. /**
  32567. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32568. * @param iterations total number of iterations
  32569. * @param syncedIterations number of synchronous iterations in each async iteration.
  32570. * @param fn the function to call each iteration.
  32571. * @param callback a success call back that will be called when iterating stops.
  32572. * @param breakFunction a break condition (optional)
  32573. * @param timeout timeout settings for the setTimeout function. default - 0.
  32574. * @returns the created async loop object
  32575. */
  32576. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32577. }
  32578. }
  32579. declare module "babylonjs/Collisions/collisionCoordinator" {
  32580. import { Nullable } from "babylonjs/types";
  32581. import { Scene } from "babylonjs/scene";
  32582. import { Vector3 } from "babylonjs/Maths/math";
  32583. import { Collider } from "babylonjs/Collisions/collider";
  32584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32585. /** @hidden */
  32586. export interface ICollisionCoordinator {
  32587. createCollider(): Collider;
  32588. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32589. init(scene: Scene): void;
  32590. }
  32591. /** @hidden */
  32592. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32593. private _scene;
  32594. private _scaledPosition;
  32595. private _scaledVelocity;
  32596. private _finalPosition;
  32597. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32598. createCollider(): Collider;
  32599. init(scene: Scene): void;
  32600. private _collideWithWorld;
  32601. }
  32602. }
  32603. declare module "babylonjs/Inputs/scene.inputManager" {
  32604. import { Nullable } from "babylonjs/types";
  32605. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32606. import { Vector2 } from "babylonjs/Maths/math";
  32607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32608. import { Scene } from "babylonjs/scene";
  32609. /**
  32610. * Class used to manage all inputs for the scene.
  32611. */
  32612. export class InputManager {
  32613. /** The distance in pixel that you have to move to prevent some events */
  32614. static DragMovementThreshold: number;
  32615. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32616. static LongPressDelay: number;
  32617. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32618. static DoubleClickDelay: number;
  32619. /** If you need to check double click without raising a single click at first click, enable this flag */
  32620. static ExclusiveDoubleClickMode: boolean;
  32621. private _wheelEventName;
  32622. private _onPointerMove;
  32623. private _onPointerDown;
  32624. private _onPointerUp;
  32625. private _initClickEvent;
  32626. private _initActionManager;
  32627. private _delayedSimpleClick;
  32628. private _delayedSimpleClickTimeout;
  32629. private _previousDelayedSimpleClickTimeout;
  32630. private _meshPickProceed;
  32631. private _previousButtonPressed;
  32632. private _currentPickResult;
  32633. private _previousPickResult;
  32634. private _totalPointersPressed;
  32635. private _doubleClickOccured;
  32636. private _pointerOverMesh;
  32637. private _pickedDownMesh;
  32638. private _pickedUpMesh;
  32639. private _pointerX;
  32640. private _pointerY;
  32641. private _unTranslatedPointerX;
  32642. private _unTranslatedPointerY;
  32643. private _startingPointerPosition;
  32644. private _previousStartingPointerPosition;
  32645. private _startingPointerTime;
  32646. private _previousStartingPointerTime;
  32647. private _pointerCaptures;
  32648. private _onKeyDown;
  32649. private _onKeyUp;
  32650. private _onCanvasFocusObserver;
  32651. private _onCanvasBlurObserver;
  32652. private _scene;
  32653. /**
  32654. * Creates a new InputManager
  32655. * @param scene defines the hosting scene
  32656. */
  32657. constructor(scene: Scene);
  32658. /**
  32659. * Gets the mesh that is currently under the pointer
  32660. */
  32661. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32662. /**
  32663. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32664. */
  32665. readonly unTranslatedPointer: Vector2;
  32666. /**
  32667. * Gets or sets the current on-screen X position of the pointer
  32668. */
  32669. pointerX: number;
  32670. /**
  32671. * Gets or sets the current on-screen Y position of the pointer
  32672. */
  32673. pointerY: number;
  32674. private _updatePointerPosition;
  32675. private _processPointerMove;
  32676. private _setRayOnPointerInfo;
  32677. private _checkPrePointerObservable;
  32678. /**
  32679. * Use this method to simulate a pointer move on a mesh
  32680. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32681. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32682. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32683. */
  32684. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32685. /**
  32686. * Use this method to simulate a pointer down on a mesh
  32687. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32688. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32689. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32690. */
  32691. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32692. private _processPointerDown;
  32693. /** @hidden */
  32694. _isPointerSwiping(): boolean;
  32695. /**
  32696. * Use this method to simulate a pointer up on a mesh
  32697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32700. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32701. */
  32702. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32703. private _processPointerUp;
  32704. /**
  32705. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32706. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32707. * @returns true if the pointer was captured
  32708. */
  32709. isPointerCaptured(pointerId?: number): boolean;
  32710. /**
  32711. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32712. * @param attachUp defines if you want to attach events to pointerup
  32713. * @param attachDown defines if you want to attach events to pointerdown
  32714. * @param attachMove defines if you want to attach events to pointermove
  32715. */
  32716. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32717. /**
  32718. * Detaches all event handlers
  32719. */
  32720. detachControl(): void;
  32721. /**
  32722. * Force the value of meshUnderPointer
  32723. * @param mesh defines the mesh to use
  32724. */
  32725. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32726. /**
  32727. * Gets the mesh under the pointer
  32728. * @returns a Mesh or null if no mesh is under the pointer
  32729. */
  32730. getPointerOverMesh(): Nullable<AbstractMesh>;
  32731. }
  32732. }
  32733. declare module "babylonjs/Animations/animationGroup" {
  32734. import { Animatable } from "babylonjs/Animations/animatable";
  32735. import { Animation } from "babylonjs/Animations/animation";
  32736. import { Scene, IDisposable } from "babylonjs/scene";
  32737. import { Observable } from "babylonjs/Misc/observable";
  32738. import { Nullable } from "babylonjs/types";
  32739. import "babylonjs/Animations/animatable";
  32740. /**
  32741. * This class defines the direct association between an animation and a target
  32742. */
  32743. export class TargetedAnimation {
  32744. /**
  32745. * Animation to perform
  32746. */
  32747. animation: Animation;
  32748. /**
  32749. * Target to animate
  32750. */
  32751. target: any;
  32752. /**
  32753. * Serialize the object
  32754. * @returns the JSON object representing the current entity
  32755. */
  32756. serialize(): any;
  32757. }
  32758. /**
  32759. * Use this class to create coordinated animations on multiple targets
  32760. */
  32761. export class AnimationGroup implements IDisposable {
  32762. /** The name of the animation group */
  32763. name: string;
  32764. private _scene;
  32765. private _targetedAnimations;
  32766. private _animatables;
  32767. private _from;
  32768. private _to;
  32769. private _isStarted;
  32770. private _isPaused;
  32771. private _speedRatio;
  32772. private _loopAnimation;
  32773. /**
  32774. * Gets or sets the unique id of the node
  32775. */
  32776. uniqueId: number;
  32777. /**
  32778. * This observable will notify when one animation have ended
  32779. */
  32780. onAnimationEndObservable: Observable<TargetedAnimation>;
  32781. /**
  32782. * Observer raised when one animation loops
  32783. */
  32784. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32785. /**
  32786. * This observable will notify when all animations have ended.
  32787. */
  32788. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32789. /**
  32790. * This observable will notify when all animations have paused.
  32791. */
  32792. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32793. /**
  32794. * This observable will notify when all animations are playing.
  32795. */
  32796. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32797. /**
  32798. * Gets the first frame
  32799. */
  32800. readonly from: number;
  32801. /**
  32802. * Gets the last frame
  32803. */
  32804. readonly to: number;
  32805. /**
  32806. * Define if the animations are started
  32807. */
  32808. readonly isStarted: boolean;
  32809. /**
  32810. * Gets a value indicating that the current group is playing
  32811. */
  32812. readonly isPlaying: boolean;
  32813. /**
  32814. * Gets or sets the speed ratio to use for all animations
  32815. */
  32816. /**
  32817. * Gets or sets the speed ratio to use for all animations
  32818. */
  32819. speedRatio: number;
  32820. /**
  32821. * Gets or sets if all animations should loop or not
  32822. */
  32823. loopAnimation: boolean;
  32824. /**
  32825. * Gets the targeted animations for this animation group
  32826. */
  32827. readonly targetedAnimations: Array<TargetedAnimation>;
  32828. /**
  32829. * returning the list of animatables controlled by this animation group.
  32830. */
  32831. readonly animatables: Array<Animatable>;
  32832. /**
  32833. * Instantiates a new Animation Group.
  32834. * This helps managing several animations at once.
  32835. * @see http://doc.babylonjs.com/how_to/group
  32836. * @param name Defines the name of the group
  32837. * @param scene Defines the scene the group belongs to
  32838. */
  32839. constructor(
  32840. /** The name of the animation group */
  32841. name: string, scene?: Nullable<Scene>);
  32842. /**
  32843. * Add an animation (with its target) in the group
  32844. * @param animation defines the animation we want to add
  32845. * @param target defines the target of the animation
  32846. * @returns the TargetedAnimation object
  32847. */
  32848. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32849. /**
  32850. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32851. * It can add constant keys at begin or end
  32852. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32853. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32854. * @returns the animation group
  32855. */
  32856. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32857. /**
  32858. * Start all animations on given targets
  32859. * @param loop defines if animations must loop
  32860. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32861. * @param from defines the from key (optional)
  32862. * @param to defines the to key (optional)
  32863. * @returns the current animation group
  32864. */
  32865. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32866. /**
  32867. * Pause all animations
  32868. * @returns the animation group
  32869. */
  32870. pause(): AnimationGroup;
  32871. /**
  32872. * Play all animations to initial state
  32873. * This function will start() the animations if they were not started or will restart() them if they were paused
  32874. * @param loop defines if animations must loop
  32875. * @returns the animation group
  32876. */
  32877. play(loop?: boolean): AnimationGroup;
  32878. /**
  32879. * Reset all animations to initial state
  32880. * @returns the animation group
  32881. */
  32882. reset(): AnimationGroup;
  32883. /**
  32884. * Restart animations from key 0
  32885. * @returns the animation group
  32886. */
  32887. restart(): AnimationGroup;
  32888. /**
  32889. * Stop all animations
  32890. * @returns the animation group
  32891. */
  32892. stop(): AnimationGroup;
  32893. /**
  32894. * Set animation weight for all animatables
  32895. * @param weight defines the weight to use
  32896. * @return the animationGroup
  32897. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32898. */
  32899. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32900. /**
  32901. * Synchronize and normalize all animatables with a source animatable
  32902. * @param root defines the root animatable to synchronize with
  32903. * @return the animationGroup
  32904. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32905. */
  32906. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32907. /**
  32908. * Goes to a specific frame in this animation group
  32909. * @param frame the frame number to go to
  32910. * @return the animationGroup
  32911. */
  32912. goToFrame(frame: number): AnimationGroup;
  32913. /**
  32914. * Dispose all associated resources
  32915. */
  32916. dispose(): void;
  32917. private _checkAnimationGroupEnded;
  32918. /**
  32919. * Clone the current animation group and returns a copy
  32920. * @param newName defines the name of the new group
  32921. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32922. * @returns the new aniamtion group
  32923. */
  32924. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32925. /**
  32926. * Serializes the animationGroup to an object
  32927. * @returns Serialized object
  32928. */
  32929. serialize(): any;
  32930. /**
  32931. * Returns a new AnimationGroup object parsed from the source provided.
  32932. * @param parsedAnimationGroup defines the source
  32933. * @param scene defines the scene that will receive the animationGroup
  32934. * @returns a new AnimationGroup
  32935. */
  32936. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32937. /**
  32938. * Returns the string "AnimationGroup"
  32939. * @returns "AnimationGroup"
  32940. */
  32941. getClassName(): string;
  32942. /**
  32943. * Creates a detailled string about the object
  32944. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32945. * @returns a string representing the object
  32946. */
  32947. toString(fullDetails?: boolean): string;
  32948. }
  32949. }
  32950. declare module "babylonjs/scene" {
  32951. import { Nullable } from "babylonjs/types";
  32952. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32953. import { Observable } from "babylonjs/Misc/observable";
  32954. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32955. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32956. import { Geometry } from "babylonjs/Meshes/geometry";
  32957. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32958. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32960. import { Mesh } from "babylonjs/Meshes/mesh";
  32961. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32962. import { Bone } from "babylonjs/Bones/bone";
  32963. import { Skeleton } from "babylonjs/Bones/skeleton";
  32964. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32965. import { Camera } from "babylonjs/Cameras/camera";
  32966. import { AbstractScene } from "babylonjs/abstractScene";
  32967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32969. import { Material } from "babylonjs/Materials/material";
  32970. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32971. import { Effect } from "babylonjs/Materials/effect";
  32972. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32973. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32974. import { Light } from "babylonjs/Lights/light";
  32975. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32976. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32977. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32978. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32979. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32980. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32981. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32982. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32983. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32984. import { Engine } from "babylonjs/Engines/engine";
  32985. import { Node } from "babylonjs/node";
  32986. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32987. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32988. import { WebRequest } from "babylonjs/Misc/webRequest";
  32989. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32990. import { Ray } from "babylonjs/Culling/ray";
  32991. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32992. import { Animation } from "babylonjs/Animations/animation";
  32993. import { Animatable } from "babylonjs/Animations/animatable";
  32994. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32995. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32996. import { Collider } from "babylonjs/Collisions/collider";
  32997. /**
  32998. * Define an interface for all classes that will hold resources
  32999. */
  33000. export interface IDisposable {
  33001. /**
  33002. * Releases all held resources
  33003. */
  33004. dispose(): void;
  33005. }
  33006. /** Interface defining initialization parameters for Scene class */
  33007. export interface SceneOptions {
  33008. /**
  33009. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33010. * It will improve performance when the number of geometries becomes important.
  33011. */
  33012. useGeometryUniqueIdsMap?: boolean;
  33013. /**
  33014. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33015. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33016. */
  33017. useMaterialMeshMap?: boolean;
  33018. /**
  33019. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33020. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33021. */
  33022. useClonedMeshhMap?: boolean;
  33023. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33024. virtual?: boolean;
  33025. }
  33026. /**
  33027. * Represents a scene to be rendered by the engine.
  33028. * @see http://doc.babylonjs.com/features/scene
  33029. */
  33030. export class Scene extends AbstractScene implements IAnimatable {
  33031. private static _uniqueIdCounter;
  33032. /** The fog is deactivated */
  33033. static readonly FOGMODE_NONE: number;
  33034. /** The fog density is following an exponential function */
  33035. static readonly FOGMODE_EXP: number;
  33036. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33037. static readonly FOGMODE_EXP2: number;
  33038. /** The fog density is following a linear function. */
  33039. static readonly FOGMODE_LINEAR: number;
  33040. /**
  33041. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33043. */
  33044. static MinDeltaTime: number;
  33045. /**
  33046. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33048. */
  33049. static MaxDeltaTime: number;
  33050. /**
  33051. * Factory used to create the default material.
  33052. * @param name The name of the material to create
  33053. * @param scene The scene to create the material for
  33054. * @returns The default material
  33055. */
  33056. static DefaultMaterialFactory(scene: Scene): Material;
  33057. /**
  33058. * Factory used to create the a collision coordinator.
  33059. * @returns The collision coordinator
  33060. */
  33061. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33062. /** @hidden */
  33063. _inputManager: InputManager;
  33064. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33065. cameraToUseForPointers: Nullable<Camera>;
  33066. /** @hidden */
  33067. readonly _isScene: boolean;
  33068. /**
  33069. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33070. */
  33071. autoClear: boolean;
  33072. /**
  33073. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33074. */
  33075. autoClearDepthAndStencil: boolean;
  33076. /**
  33077. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33078. */
  33079. clearColor: Color4;
  33080. /**
  33081. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33082. */
  33083. ambientColor: Color3;
  33084. /**
  33085. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33086. * It should only be one of the following (if not the default embedded one):
  33087. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33088. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33089. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33090. * The material properties need to be setup according to the type of texture in use.
  33091. */
  33092. environmentBRDFTexture: BaseTexture;
  33093. /** @hidden */
  33094. protected _environmentTexture: Nullable<BaseTexture>;
  33095. /**
  33096. * Texture used in all pbr material as the reflection texture.
  33097. * As in the majority of the scene they are the same (exception for multi room and so on),
  33098. * this is easier to reference from here than from all the materials.
  33099. */
  33100. /**
  33101. * Texture used in all pbr material as the reflection texture.
  33102. * As in the majority of the scene they are the same (exception for multi room and so on),
  33103. * this is easier to set here than in all the materials.
  33104. */
  33105. environmentTexture: Nullable<BaseTexture>;
  33106. /** @hidden */
  33107. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33108. /**
  33109. * Default image processing configuration used either in the rendering
  33110. * Forward main pass or through the imageProcessingPostProcess if present.
  33111. * As in the majority of the scene they are the same (exception for multi camera),
  33112. * this is easier to reference from here than from all the materials and post process.
  33113. *
  33114. * No setter as we it is a shared configuration, you can set the values instead.
  33115. */
  33116. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33117. private _forceWireframe;
  33118. /**
  33119. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33120. */
  33121. forceWireframe: boolean;
  33122. private _forcePointsCloud;
  33123. /**
  33124. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33125. */
  33126. forcePointsCloud: boolean;
  33127. /**
  33128. * Gets or sets the active clipplane 1
  33129. */
  33130. clipPlane: Nullable<Plane>;
  33131. /**
  33132. * Gets or sets the active clipplane 2
  33133. */
  33134. clipPlane2: Nullable<Plane>;
  33135. /**
  33136. * Gets or sets the active clipplane 3
  33137. */
  33138. clipPlane3: Nullable<Plane>;
  33139. /**
  33140. * Gets or sets the active clipplane 4
  33141. */
  33142. clipPlane4: Nullable<Plane>;
  33143. /**
  33144. * Gets or sets a boolean indicating if animations are enabled
  33145. */
  33146. animationsEnabled: boolean;
  33147. private _animationPropertiesOverride;
  33148. /**
  33149. * Gets or sets the animation properties override
  33150. */
  33151. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33152. /**
  33153. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33154. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33155. */
  33156. useConstantAnimationDeltaTime: boolean;
  33157. /**
  33158. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33159. * Please note that it requires to run a ray cast through the scene on every frame
  33160. */
  33161. constantlyUpdateMeshUnderPointer: boolean;
  33162. /**
  33163. * Defines the HTML cursor to use when hovering over interactive elements
  33164. */
  33165. hoverCursor: string;
  33166. /**
  33167. * Defines the HTML default cursor to use (empty by default)
  33168. */
  33169. defaultCursor: string;
  33170. /**
  33171. * This is used to call preventDefault() on pointer down
  33172. * in order to block unwanted artifacts like system double clicks
  33173. */
  33174. preventDefaultOnPointerDown: boolean;
  33175. /**
  33176. * This is used to call preventDefault() on pointer up
  33177. * in order to block unwanted artifacts like system double clicks
  33178. */
  33179. preventDefaultOnPointerUp: boolean;
  33180. /**
  33181. * Gets or sets user defined metadata
  33182. */
  33183. metadata: any;
  33184. /**
  33185. * For internal use only. Please do not use.
  33186. */
  33187. reservedDataStore: any;
  33188. /**
  33189. * Gets the name of the plugin used to load this scene (null by default)
  33190. */
  33191. loadingPluginName: string;
  33192. /**
  33193. * Use this array to add regular expressions used to disable offline support for specific urls
  33194. */
  33195. disableOfflineSupportExceptionRules: RegExp[];
  33196. /**
  33197. * An event triggered when the scene is disposed.
  33198. */
  33199. onDisposeObservable: Observable<Scene>;
  33200. private _onDisposeObserver;
  33201. /** Sets a function to be executed when this scene is disposed. */
  33202. onDispose: () => void;
  33203. /**
  33204. * An event triggered before rendering the scene (right after animations and physics)
  33205. */
  33206. onBeforeRenderObservable: Observable<Scene>;
  33207. private _onBeforeRenderObserver;
  33208. /** Sets a function to be executed before rendering this scene */
  33209. beforeRender: Nullable<() => void>;
  33210. /**
  33211. * An event triggered after rendering the scene
  33212. */
  33213. onAfterRenderObservable: Observable<Scene>;
  33214. /**
  33215. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33216. */
  33217. onAfterRenderCameraObservable: Observable<Camera>;
  33218. private _onAfterRenderObserver;
  33219. /** Sets a function to be executed after rendering this scene */
  33220. afterRender: Nullable<() => void>;
  33221. /**
  33222. * An event triggered before animating the scene
  33223. */
  33224. onBeforeAnimationsObservable: Observable<Scene>;
  33225. /**
  33226. * An event triggered after animations processing
  33227. */
  33228. onAfterAnimationsObservable: Observable<Scene>;
  33229. /**
  33230. * An event triggered before draw calls are ready to be sent
  33231. */
  33232. onBeforeDrawPhaseObservable: Observable<Scene>;
  33233. /**
  33234. * An event triggered after draw calls have been sent
  33235. */
  33236. onAfterDrawPhaseObservable: Observable<Scene>;
  33237. /**
  33238. * An event triggered when the scene is ready
  33239. */
  33240. onReadyObservable: Observable<Scene>;
  33241. /**
  33242. * An event triggered before rendering a camera
  33243. */
  33244. onBeforeCameraRenderObservable: Observable<Camera>;
  33245. private _onBeforeCameraRenderObserver;
  33246. /** Sets a function to be executed before rendering a camera*/
  33247. beforeCameraRender: () => void;
  33248. /**
  33249. * An event triggered after rendering a camera
  33250. */
  33251. onAfterCameraRenderObservable: Observable<Camera>;
  33252. private _onAfterCameraRenderObserver;
  33253. /** Sets a function to be executed after rendering a camera*/
  33254. afterCameraRender: () => void;
  33255. /**
  33256. * An event triggered when active meshes evaluation is about to start
  33257. */
  33258. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33259. /**
  33260. * An event triggered when active meshes evaluation is done
  33261. */
  33262. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33263. /**
  33264. * An event triggered when particles rendering is about to start
  33265. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33266. */
  33267. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33268. /**
  33269. * An event triggered when particles rendering is done
  33270. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33271. */
  33272. onAfterParticlesRenderingObservable: Observable<Scene>;
  33273. /**
  33274. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33275. */
  33276. onDataLoadedObservable: Observable<Scene>;
  33277. /**
  33278. * An event triggered when a camera is created
  33279. */
  33280. onNewCameraAddedObservable: Observable<Camera>;
  33281. /**
  33282. * An event triggered when a camera is removed
  33283. */
  33284. onCameraRemovedObservable: Observable<Camera>;
  33285. /**
  33286. * An event triggered when a light is created
  33287. */
  33288. onNewLightAddedObservable: Observable<Light>;
  33289. /**
  33290. * An event triggered when a light is removed
  33291. */
  33292. onLightRemovedObservable: Observable<Light>;
  33293. /**
  33294. * An event triggered when a geometry is created
  33295. */
  33296. onNewGeometryAddedObservable: Observable<Geometry>;
  33297. /**
  33298. * An event triggered when a geometry is removed
  33299. */
  33300. onGeometryRemovedObservable: Observable<Geometry>;
  33301. /**
  33302. * An event triggered when a transform node is created
  33303. */
  33304. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33305. /**
  33306. * An event triggered when a transform node is removed
  33307. */
  33308. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33309. /**
  33310. * An event triggered when a mesh is created
  33311. */
  33312. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33313. /**
  33314. * An event triggered when a mesh is removed
  33315. */
  33316. onMeshRemovedObservable: Observable<AbstractMesh>;
  33317. /**
  33318. * An event triggered when a skeleton is created
  33319. */
  33320. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33321. /**
  33322. * An event triggered when a skeleton is removed
  33323. */
  33324. onSkeletonRemovedObservable: Observable<Skeleton>;
  33325. /**
  33326. * An event triggered when a material is created
  33327. */
  33328. onNewMaterialAddedObservable: Observable<Material>;
  33329. /**
  33330. * An event triggered when a material is removed
  33331. */
  33332. onMaterialRemovedObservable: Observable<Material>;
  33333. /**
  33334. * An event triggered when a texture is created
  33335. */
  33336. onNewTextureAddedObservable: Observable<BaseTexture>;
  33337. /**
  33338. * An event triggered when a texture is removed
  33339. */
  33340. onTextureRemovedObservable: Observable<BaseTexture>;
  33341. /**
  33342. * An event triggered when render targets are about to be rendered
  33343. * Can happen multiple times per frame.
  33344. */
  33345. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33346. /**
  33347. * An event triggered when render targets were rendered.
  33348. * Can happen multiple times per frame.
  33349. */
  33350. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33351. /**
  33352. * An event triggered before calculating deterministic simulation step
  33353. */
  33354. onBeforeStepObservable: Observable<Scene>;
  33355. /**
  33356. * An event triggered after calculating deterministic simulation step
  33357. */
  33358. onAfterStepObservable: Observable<Scene>;
  33359. /**
  33360. * An event triggered when the activeCamera property is updated
  33361. */
  33362. onActiveCameraChanged: Observable<Scene>;
  33363. /**
  33364. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33365. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33366. * 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)
  33367. */
  33368. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33369. /**
  33370. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33371. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33372. * 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)
  33373. */
  33374. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33375. /**
  33376. * This Observable will when a mesh has been imported into the scene.
  33377. */
  33378. onMeshImportedObservable: Observable<AbstractMesh>;
  33379. /**
  33380. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33381. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33382. */
  33383. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33384. /** @hidden */
  33385. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33386. /**
  33387. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33388. */
  33389. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33390. /**
  33391. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33392. */
  33393. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33394. /**
  33395. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33396. */
  33397. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33398. /** Callback called when a pointer move is detected */
  33399. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33400. /** Callback called when a pointer down is detected */
  33401. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33402. /** Callback called when a pointer up is detected */
  33403. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33404. /** Callback called when a pointer pick is detected */
  33405. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33406. /**
  33407. * 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).
  33408. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33409. */
  33410. onPrePointerObservable: Observable<PointerInfoPre>;
  33411. /**
  33412. * Observable event triggered each time an input event is received from the rendering canvas
  33413. */
  33414. onPointerObservable: Observable<PointerInfo>;
  33415. /**
  33416. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33417. */
  33418. readonly unTranslatedPointer: Vector2;
  33419. /**
  33420. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33421. */
  33422. static DragMovementThreshold: number;
  33423. /**
  33424. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33425. */
  33426. static LongPressDelay: number;
  33427. /**
  33428. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33429. */
  33430. static DoubleClickDelay: number;
  33431. /** If you need to check double click without raising a single click at first click, enable this flag */
  33432. static ExclusiveDoubleClickMode: boolean;
  33433. /** @hidden */
  33434. _mirroredCameraPosition: Nullable<Vector3>;
  33435. /**
  33436. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33437. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33438. */
  33439. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33440. /**
  33441. * Observable event triggered each time an keyboard event is received from the hosting window
  33442. */
  33443. onKeyboardObservable: Observable<KeyboardInfo>;
  33444. private _useRightHandedSystem;
  33445. /**
  33446. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33447. */
  33448. useRightHandedSystem: boolean;
  33449. private _timeAccumulator;
  33450. private _currentStepId;
  33451. private _currentInternalStep;
  33452. /**
  33453. * Sets the step Id used by deterministic lock step
  33454. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33455. * @param newStepId defines the step Id
  33456. */
  33457. setStepId(newStepId: number): void;
  33458. /**
  33459. * Gets the step Id used by deterministic lock step
  33460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33461. * @returns the step Id
  33462. */
  33463. getStepId(): number;
  33464. /**
  33465. * Gets the internal step used by deterministic lock step
  33466. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33467. * @returns the internal step
  33468. */
  33469. getInternalStep(): number;
  33470. private _fogEnabled;
  33471. /**
  33472. * Gets or sets a boolean indicating if fog is enabled on this scene
  33473. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33474. * (Default is true)
  33475. */
  33476. fogEnabled: boolean;
  33477. private _fogMode;
  33478. /**
  33479. * Gets or sets the fog mode to use
  33480. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33481. * | mode | value |
  33482. * | --- | --- |
  33483. * | FOGMODE_NONE | 0 |
  33484. * | FOGMODE_EXP | 1 |
  33485. * | FOGMODE_EXP2 | 2 |
  33486. * | FOGMODE_LINEAR | 3 |
  33487. */
  33488. fogMode: number;
  33489. /**
  33490. * Gets or sets the fog color to use
  33491. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33492. * (Default is Color3(0.2, 0.2, 0.3))
  33493. */
  33494. fogColor: Color3;
  33495. /**
  33496. * Gets or sets the fog density to use
  33497. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33498. * (Default is 0.1)
  33499. */
  33500. fogDensity: number;
  33501. /**
  33502. * Gets or sets the fog start distance to use
  33503. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33504. * (Default is 0)
  33505. */
  33506. fogStart: number;
  33507. /**
  33508. * Gets or sets the fog end distance to use
  33509. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33510. * (Default is 1000)
  33511. */
  33512. fogEnd: number;
  33513. private _shadowsEnabled;
  33514. /**
  33515. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33516. */
  33517. shadowsEnabled: boolean;
  33518. private _lightsEnabled;
  33519. /**
  33520. * Gets or sets a boolean indicating if lights are enabled on this scene
  33521. */
  33522. lightsEnabled: boolean;
  33523. /** All of the active cameras added to this scene. */
  33524. activeCameras: Camera[];
  33525. /** @hidden */
  33526. _activeCamera: Nullable<Camera>;
  33527. /** Gets or sets the current active camera */
  33528. activeCamera: Nullable<Camera>;
  33529. private _defaultMaterial;
  33530. /** The default material used on meshes when no material is affected */
  33531. /** The default material used on meshes when no material is affected */
  33532. defaultMaterial: Material;
  33533. private _texturesEnabled;
  33534. /**
  33535. * Gets or sets a boolean indicating if textures are enabled on this scene
  33536. */
  33537. texturesEnabled: boolean;
  33538. /**
  33539. * Gets or sets a boolean indicating if particles are enabled on this scene
  33540. */
  33541. particlesEnabled: boolean;
  33542. /**
  33543. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33544. */
  33545. spritesEnabled: boolean;
  33546. private _skeletonsEnabled;
  33547. /**
  33548. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33549. */
  33550. skeletonsEnabled: boolean;
  33551. /**
  33552. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33553. */
  33554. lensFlaresEnabled: boolean;
  33555. /**
  33556. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33558. */
  33559. collisionsEnabled: boolean;
  33560. private _collisionCoordinator;
  33561. /** @hidden */
  33562. readonly collisionCoordinator: ICollisionCoordinator;
  33563. /**
  33564. * Defines the gravity applied to this scene (used only for collisions)
  33565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33566. */
  33567. gravity: Vector3;
  33568. /**
  33569. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33570. */
  33571. postProcessesEnabled: boolean;
  33572. /**
  33573. * The list of postprocesses added to the scene
  33574. */
  33575. postProcesses: PostProcess[];
  33576. /**
  33577. * Gets the current postprocess manager
  33578. */
  33579. postProcessManager: PostProcessManager;
  33580. /**
  33581. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33582. */
  33583. renderTargetsEnabled: boolean;
  33584. /**
  33585. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33586. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33587. */
  33588. dumpNextRenderTargets: boolean;
  33589. /**
  33590. * The list of user defined render targets added to the scene
  33591. */
  33592. customRenderTargets: RenderTargetTexture[];
  33593. /**
  33594. * Defines if texture loading must be delayed
  33595. * If true, textures will only be loaded when they need to be rendered
  33596. */
  33597. useDelayedTextureLoading: boolean;
  33598. /**
  33599. * Gets the list of meshes imported to the scene through SceneLoader
  33600. */
  33601. importedMeshesFiles: String[];
  33602. /**
  33603. * Gets or sets a boolean indicating if probes are enabled on this scene
  33604. */
  33605. probesEnabled: boolean;
  33606. /**
  33607. * Gets or sets the current offline provider to use to store scene data
  33608. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33609. */
  33610. offlineProvider: IOfflineProvider;
  33611. /**
  33612. * Gets or sets the action manager associated with the scene
  33613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33614. */
  33615. actionManager: AbstractActionManager;
  33616. private _meshesForIntersections;
  33617. /**
  33618. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33619. */
  33620. proceduralTexturesEnabled: boolean;
  33621. private _engine;
  33622. private _totalVertices;
  33623. /** @hidden */
  33624. _activeIndices: PerfCounter;
  33625. /** @hidden */
  33626. _activeParticles: PerfCounter;
  33627. /** @hidden */
  33628. _activeBones: PerfCounter;
  33629. private _animationRatio;
  33630. /** @hidden */
  33631. _animationTimeLast: number;
  33632. /** @hidden */
  33633. _animationTime: number;
  33634. /**
  33635. * Gets or sets a general scale for animation speed
  33636. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33637. */
  33638. animationTimeScale: number;
  33639. /** @hidden */
  33640. _cachedMaterial: Nullable<Material>;
  33641. /** @hidden */
  33642. _cachedEffect: Nullable<Effect>;
  33643. /** @hidden */
  33644. _cachedVisibility: Nullable<number>;
  33645. private _renderId;
  33646. private _frameId;
  33647. private _executeWhenReadyTimeoutId;
  33648. private _intermediateRendering;
  33649. private _viewUpdateFlag;
  33650. private _projectionUpdateFlag;
  33651. /** @hidden */
  33652. _toBeDisposed: Nullable<IDisposable>[];
  33653. private _activeRequests;
  33654. /** @hidden */
  33655. _pendingData: any[];
  33656. private _isDisposed;
  33657. /**
  33658. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33659. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33660. */
  33661. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33662. private _activeMeshes;
  33663. private _processedMaterials;
  33664. private _renderTargets;
  33665. /** @hidden */
  33666. _activeParticleSystems: SmartArray<IParticleSystem>;
  33667. private _activeSkeletons;
  33668. private _softwareSkinnedMeshes;
  33669. private _renderingManager;
  33670. /** @hidden */
  33671. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33672. private _transformMatrix;
  33673. private _sceneUbo;
  33674. /** @hidden */
  33675. _viewMatrix: Matrix;
  33676. private _projectionMatrix;
  33677. /** @hidden */
  33678. _forcedViewPosition: Nullable<Vector3>;
  33679. /** @hidden */
  33680. _frustumPlanes: Plane[];
  33681. /**
  33682. * Gets the list of frustum planes (built from the active camera)
  33683. */
  33684. readonly frustumPlanes: Plane[];
  33685. /**
  33686. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33687. * This is useful if there are more lights that the maximum simulteanous authorized
  33688. */
  33689. requireLightSorting: boolean;
  33690. /** @hidden */
  33691. readonly useMaterialMeshMap: boolean;
  33692. /** @hidden */
  33693. readonly useClonedMeshhMap: boolean;
  33694. private _externalData;
  33695. private _uid;
  33696. /**
  33697. * @hidden
  33698. * Backing store of defined scene components.
  33699. */
  33700. _components: ISceneComponent[];
  33701. /**
  33702. * @hidden
  33703. * Backing store of defined scene components.
  33704. */
  33705. _serializableComponents: ISceneSerializableComponent[];
  33706. /**
  33707. * List of components to register on the next registration step.
  33708. */
  33709. private _transientComponents;
  33710. /**
  33711. * Registers the transient components if needed.
  33712. */
  33713. private _registerTransientComponents;
  33714. /**
  33715. * @hidden
  33716. * Add a component to the scene.
  33717. * Note that the ccomponent could be registered on th next frame if this is called after
  33718. * the register component stage.
  33719. * @param component Defines the component to add to the scene
  33720. */
  33721. _addComponent(component: ISceneComponent): void;
  33722. /**
  33723. * @hidden
  33724. * Gets a component from the scene.
  33725. * @param name defines the name of the component to retrieve
  33726. * @returns the component or null if not present
  33727. */
  33728. _getComponent(name: string): Nullable<ISceneComponent>;
  33729. /**
  33730. * @hidden
  33731. * Defines the actions happening before camera updates.
  33732. */
  33733. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33734. /**
  33735. * @hidden
  33736. * Defines the actions happening before clear the canvas.
  33737. */
  33738. _beforeClearStage: Stage<SimpleStageAction>;
  33739. /**
  33740. * @hidden
  33741. * Defines the actions when collecting render targets for the frame.
  33742. */
  33743. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33744. /**
  33745. * @hidden
  33746. * Defines the actions happening for one camera in the frame.
  33747. */
  33748. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33749. /**
  33750. * @hidden
  33751. * Defines the actions happening during the per mesh ready checks.
  33752. */
  33753. _isReadyForMeshStage: Stage<MeshStageAction>;
  33754. /**
  33755. * @hidden
  33756. * Defines the actions happening before evaluate active mesh checks.
  33757. */
  33758. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33759. /**
  33760. * @hidden
  33761. * Defines the actions happening during the evaluate sub mesh checks.
  33762. */
  33763. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33764. /**
  33765. * @hidden
  33766. * Defines the actions happening during the active mesh stage.
  33767. */
  33768. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33769. /**
  33770. * @hidden
  33771. * Defines the actions happening during the per camera render target step.
  33772. */
  33773. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33774. /**
  33775. * @hidden
  33776. * Defines the actions happening just before the active camera is drawing.
  33777. */
  33778. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33779. /**
  33780. * @hidden
  33781. * Defines the actions happening just before a render target is drawing.
  33782. */
  33783. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33784. /**
  33785. * @hidden
  33786. * Defines the actions happening just before a rendering group is drawing.
  33787. */
  33788. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33789. /**
  33790. * @hidden
  33791. * Defines the actions happening just before a mesh is drawing.
  33792. */
  33793. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33794. /**
  33795. * @hidden
  33796. * Defines the actions happening just after a mesh has been drawn.
  33797. */
  33798. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33799. /**
  33800. * @hidden
  33801. * Defines the actions happening just after a rendering group has been drawn.
  33802. */
  33803. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33804. /**
  33805. * @hidden
  33806. * Defines the actions happening just after the active camera has been drawn.
  33807. */
  33808. _afterCameraDrawStage: Stage<CameraStageAction>;
  33809. /**
  33810. * @hidden
  33811. * Defines the actions happening just after a render target has been drawn.
  33812. */
  33813. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33814. /**
  33815. * @hidden
  33816. * Defines the actions happening just after rendering all cameras and computing intersections.
  33817. */
  33818. _afterRenderStage: Stage<SimpleStageAction>;
  33819. /**
  33820. * @hidden
  33821. * Defines the actions happening when a pointer move event happens.
  33822. */
  33823. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33824. /**
  33825. * @hidden
  33826. * Defines the actions happening when a pointer down event happens.
  33827. */
  33828. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33829. /**
  33830. * @hidden
  33831. * Defines the actions happening when a pointer up event happens.
  33832. */
  33833. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33834. /**
  33835. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33836. */
  33837. private geometriesByUniqueId;
  33838. /**
  33839. * Creates a new Scene
  33840. * @param engine defines the engine to use to render this scene
  33841. * @param options defines the scene options
  33842. */
  33843. constructor(engine: Engine, options?: SceneOptions);
  33844. /**
  33845. * Gets a string idenfifying the name of the class
  33846. * @returns "Scene" string
  33847. */
  33848. getClassName(): string;
  33849. private _defaultMeshCandidates;
  33850. /**
  33851. * @hidden
  33852. */
  33853. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33854. private _defaultSubMeshCandidates;
  33855. /**
  33856. * @hidden
  33857. */
  33858. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33859. /**
  33860. * Sets the default candidate providers for the scene.
  33861. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33862. * and getCollidingSubMeshCandidates to their default function
  33863. */
  33864. setDefaultCandidateProviders(): void;
  33865. /**
  33866. * Gets the mesh that is currently under the pointer
  33867. */
  33868. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33869. /**
  33870. * Gets or sets the current on-screen X position of the pointer
  33871. */
  33872. pointerX: number;
  33873. /**
  33874. * Gets or sets the current on-screen Y position of the pointer
  33875. */
  33876. pointerY: number;
  33877. /**
  33878. * Gets the cached material (ie. the latest rendered one)
  33879. * @returns the cached material
  33880. */
  33881. getCachedMaterial(): Nullable<Material>;
  33882. /**
  33883. * Gets the cached effect (ie. the latest rendered one)
  33884. * @returns the cached effect
  33885. */
  33886. getCachedEffect(): Nullable<Effect>;
  33887. /**
  33888. * Gets the cached visibility state (ie. the latest rendered one)
  33889. * @returns the cached visibility state
  33890. */
  33891. getCachedVisibility(): Nullable<number>;
  33892. /**
  33893. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33894. * @param material defines the current material
  33895. * @param effect defines the current effect
  33896. * @param visibility defines the current visibility state
  33897. * @returns true if one parameter is not cached
  33898. */
  33899. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33900. /**
  33901. * Gets the engine associated with the scene
  33902. * @returns an Engine
  33903. */
  33904. getEngine(): Engine;
  33905. /**
  33906. * Gets the total number of vertices rendered per frame
  33907. * @returns the total number of vertices rendered per frame
  33908. */
  33909. getTotalVertices(): number;
  33910. /**
  33911. * Gets the performance counter for total vertices
  33912. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33913. */
  33914. readonly totalVerticesPerfCounter: PerfCounter;
  33915. /**
  33916. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33917. * @returns the total number of active indices rendered per frame
  33918. */
  33919. getActiveIndices(): number;
  33920. /**
  33921. * Gets the performance counter for active indices
  33922. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33923. */
  33924. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33925. /**
  33926. * Gets the total number of active particles rendered per frame
  33927. * @returns the total number of active particles rendered per frame
  33928. */
  33929. getActiveParticles(): number;
  33930. /**
  33931. * Gets the performance counter for active particles
  33932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33933. */
  33934. readonly activeParticlesPerfCounter: PerfCounter;
  33935. /**
  33936. * Gets the total number of active bones rendered per frame
  33937. * @returns the total number of active bones rendered per frame
  33938. */
  33939. getActiveBones(): number;
  33940. /**
  33941. * Gets the performance counter for active bones
  33942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33943. */
  33944. readonly activeBonesPerfCounter: PerfCounter;
  33945. /**
  33946. * Gets the array of active meshes
  33947. * @returns an array of AbstractMesh
  33948. */
  33949. getActiveMeshes(): SmartArray<AbstractMesh>;
  33950. /**
  33951. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33952. * @returns a number
  33953. */
  33954. getAnimationRatio(): number;
  33955. /**
  33956. * Gets an unique Id for the current render phase
  33957. * @returns a number
  33958. */
  33959. getRenderId(): number;
  33960. /**
  33961. * Gets an unique Id for the current frame
  33962. * @returns a number
  33963. */
  33964. getFrameId(): number;
  33965. /** Call this function if you want to manually increment the render Id*/
  33966. incrementRenderId(): void;
  33967. private _createUbo;
  33968. /**
  33969. * Use this method to simulate a pointer move on a mesh
  33970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33973. * @returns the current scene
  33974. */
  33975. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33976. /**
  33977. * Use this method to simulate a pointer down on a mesh
  33978. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33979. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33980. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33981. * @returns the current scene
  33982. */
  33983. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33984. /**
  33985. * Use this method to simulate a pointer up on a mesh
  33986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33989. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33990. * @returns the current scene
  33991. */
  33992. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33993. /**
  33994. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33995. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33996. * @returns true if the pointer was captured
  33997. */
  33998. isPointerCaptured(pointerId?: number): boolean;
  33999. /**
  34000. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34001. * @param attachUp defines if you want to attach events to pointerup
  34002. * @param attachDown defines if you want to attach events to pointerdown
  34003. * @param attachMove defines if you want to attach events to pointermove
  34004. */
  34005. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34006. /** Detaches all event handlers*/
  34007. detachControl(): void;
  34008. /**
  34009. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34010. * Delay loaded resources are not taking in account
  34011. * @return true if all required resources are ready
  34012. */
  34013. isReady(): boolean;
  34014. /** Resets all cached information relative to material (including effect and visibility) */
  34015. resetCachedMaterial(): void;
  34016. /**
  34017. * Registers a function to be called before every frame render
  34018. * @param func defines the function to register
  34019. */
  34020. registerBeforeRender(func: () => void): void;
  34021. /**
  34022. * Unregisters a function called before every frame render
  34023. * @param func defines the function to unregister
  34024. */
  34025. unregisterBeforeRender(func: () => void): void;
  34026. /**
  34027. * Registers a function to be called after every frame render
  34028. * @param func defines the function to register
  34029. */
  34030. registerAfterRender(func: () => void): void;
  34031. /**
  34032. * Unregisters a function called after every frame render
  34033. * @param func defines the function to unregister
  34034. */
  34035. unregisterAfterRender(func: () => void): void;
  34036. private _executeOnceBeforeRender;
  34037. /**
  34038. * The provided function will run before render once and will be disposed afterwards.
  34039. * A timeout delay can be provided so that the function will be executed in N ms.
  34040. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34041. * @param func The function to be executed.
  34042. * @param timeout optional delay in ms
  34043. */
  34044. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34045. /** @hidden */
  34046. _addPendingData(data: any): void;
  34047. /** @hidden */
  34048. _removePendingData(data: any): void;
  34049. /**
  34050. * Returns the number of items waiting to be loaded
  34051. * @returns the number of items waiting to be loaded
  34052. */
  34053. getWaitingItemsCount(): number;
  34054. /**
  34055. * Returns a boolean indicating if the scene is still loading data
  34056. */
  34057. readonly isLoading: boolean;
  34058. /**
  34059. * Registers a function to be executed when the scene is ready
  34060. * @param {Function} func - the function to be executed
  34061. */
  34062. executeWhenReady(func: () => void): void;
  34063. /**
  34064. * Returns a promise that resolves when the scene is ready
  34065. * @returns A promise that resolves when the scene is ready
  34066. */
  34067. whenReadyAsync(): Promise<void>;
  34068. /** @hidden */
  34069. _checkIsReady(): void;
  34070. /**
  34071. * Gets all animatable attached to the scene
  34072. */
  34073. readonly animatables: Animatable[];
  34074. /**
  34075. * Resets the last animation time frame.
  34076. * Useful to override when animations start running when loading a scene for the first time.
  34077. */
  34078. resetLastAnimationTimeFrame(): void;
  34079. /**
  34080. * Gets the current view matrix
  34081. * @returns a Matrix
  34082. */
  34083. getViewMatrix(): Matrix;
  34084. /**
  34085. * Gets the current projection matrix
  34086. * @returns a Matrix
  34087. */
  34088. getProjectionMatrix(): Matrix;
  34089. /**
  34090. * Gets the current transform matrix
  34091. * @returns a Matrix made of View * Projection
  34092. */
  34093. getTransformMatrix(): Matrix;
  34094. /**
  34095. * Sets the current transform matrix
  34096. * @param viewL defines the View matrix to use
  34097. * @param projectionL defines the Projection matrix to use
  34098. * @param viewR defines the right View matrix to use (if provided)
  34099. * @param projectionR defines the right Projection matrix to use (if provided)
  34100. */
  34101. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34102. /**
  34103. * Gets the uniform buffer used to store scene data
  34104. * @returns a UniformBuffer
  34105. */
  34106. getSceneUniformBuffer(): UniformBuffer;
  34107. /**
  34108. * Gets an unique (relatively to the current scene) Id
  34109. * @returns an unique number for the scene
  34110. */
  34111. getUniqueId(): number;
  34112. /**
  34113. * Add a mesh to the list of scene's meshes
  34114. * @param newMesh defines the mesh to add
  34115. * @param recursive if all child meshes should also be added to the scene
  34116. */
  34117. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34118. /**
  34119. * Remove a mesh for the list of scene's meshes
  34120. * @param toRemove defines the mesh to remove
  34121. * @param recursive if all child meshes should also be removed from the scene
  34122. * @returns the index where the mesh was in the mesh list
  34123. */
  34124. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34125. /**
  34126. * Add a transform node to the list of scene's transform nodes
  34127. * @param newTransformNode defines the transform node to add
  34128. */
  34129. addTransformNode(newTransformNode: TransformNode): void;
  34130. /**
  34131. * Remove a transform node for the list of scene's transform nodes
  34132. * @param toRemove defines the transform node to remove
  34133. * @returns the index where the transform node was in the transform node list
  34134. */
  34135. removeTransformNode(toRemove: TransformNode): number;
  34136. /**
  34137. * Remove a skeleton for the list of scene's skeletons
  34138. * @param toRemove defines the skeleton to remove
  34139. * @returns the index where the skeleton was in the skeleton list
  34140. */
  34141. removeSkeleton(toRemove: Skeleton): number;
  34142. /**
  34143. * Remove a morph target for the list of scene's morph targets
  34144. * @param toRemove defines the morph target to remove
  34145. * @returns the index where the morph target was in the morph target list
  34146. */
  34147. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34148. /**
  34149. * Remove a light for the list of scene's lights
  34150. * @param toRemove defines the light to remove
  34151. * @returns the index where the light was in the light list
  34152. */
  34153. removeLight(toRemove: Light): number;
  34154. /**
  34155. * Remove a camera for the list of scene's cameras
  34156. * @param toRemove defines the camera to remove
  34157. * @returns the index where the camera was in the camera list
  34158. */
  34159. removeCamera(toRemove: Camera): number;
  34160. /**
  34161. * Remove a particle system for the list of scene's particle systems
  34162. * @param toRemove defines the particle system to remove
  34163. * @returns the index where the particle system was in the particle system list
  34164. */
  34165. removeParticleSystem(toRemove: IParticleSystem): number;
  34166. /**
  34167. * Remove a animation for the list of scene's animations
  34168. * @param toRemove defines the animation to remove
  34169. * @returns the index where the animation was in the animation list
  34170. */
  34171. removeAnimation(toRemove: Animation): number;
  34172. /**
  34173. * Will stop the animation of the given target
  34174. * @param target - the target
  34175. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34176. * @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)
  34177. */
  34178. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34179. /**
  34180. * Removes the given animation group from this scene.
  34181. * @param toRemove The animation group to remove
  34182. * @returns The index of the removed animation group
  34183. */
  34184. removeAnimationGroup(toRemove: AnimationGroup): number;
  34185. /**
  34186. * Removes the given multi-material from this scene.
  34187. * @param toRemove The multi-material to remove
  34188. * @returns The index of the removed multi-material
  34189. */
  34190. removeMultiMaterial(toRemove: MultiMaterial): number;
  34191. /**
  34192. * Removes the given material from this scene.
  34193. * @param toRemove The material to remove
  34194. * @returns The index of the removed material
  34195. */
  34196. removeMaterial(toRemove: Material): number;
  34197. /**
  34198. * Removes the given action manager from this scene.
  34199. * @param toRemove The action manager to remove
  34200. * @returns The index of the removed action manager
  34201. */
  34202. removeActionManager(toRemove: AbstractActionManager): number;
  34203. /**
  34204. * Removes the given texture from this scene.
  34205. * @param toRemove The texture to remove
  34206. * @returns The index of the removed texture
  34207. */
  34208. removeTexture(toRemove: BaseTexture): number;
  34209. /**
  34210. * Adds the given light to this scene
  34211. * @param newLight The light to add
  34212. */
  34213. addLight(newLight: Light): void;
  34214. /**
  34215. * Sorts the list list based on light priorities
  34216. */
  34217. sortLightsByPriority(): void;
  34218. /**
  34219. * Adds the given camera to this scene
  34220. * @param newCamera The camera to add
  34221. */
  34222. addCamera(newCamera: Camera): void;
  34223. /**
  34224. * Adds the given skeleton to this scene
  34225. * @param newSkeleton The skeleton to add
  34226. */
  34227. addSkeleton(newSkeleton: Skeleton): void;
  34228. /**
  34229. * Adds the given particle system to this scene
  34230. * @param newParticleSystem The particle system to add
  34231. */
  34232. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34233. /**
  34234. * Adds the given animation to this scene
  34235. * @param newAnimation The animation to add
  34236. */
  34237. addAnimation(newAnimation: Animation): void;
  34238. /**
  34239. * Adds the given animation group to this scene.
  34240. * @param newAnimationGroup The animation group to add
  34241. */
  34242. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34243. /**
  34244. * Adds the given multi-material to this scene
  34245. * @param newMultiMaterial The multi-material to add
  34246. */
  34247. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34248. /**
  34249. * Adds the given material to this scene
  34250. * @param newMaterial The material to add
  34251. */
  34252. addMaterial(newMaterial: Material): void;
  34253. /**
  34254. * Adds the given morph target to this scene
  34255. * @param newMorphTargetManager The morph target to add
  34256. */
  34257. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34258. /**
  34259. * Adds the given geometry to this scene
  34260. * @param newGeometry The geometry to add
  34261. */
  34262. addGeometry(newGeometry: Geometry): void;
  34263. /**
  34264. * Adds the given action manager to this scene
  34265. * @param newActionManager The action manager to add
  34266. */
  34267. addActionManager(newActionManager: AbstractActionManager): void;
  34268. /**
  34269. * Adds the given texture to this scene.
  34270. * @param newTexture The texture to add
  34271. */
  34272. addTexture(newTexture: BaseTexture): void;
  34273. /**
  34274. * Switch active camera
  34275. * @param newCamera defines the new active camera
  34276. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34277. */
  34278. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34279. /**
  34280. * sets the active camera of the scene using its ID
  34281. * @param id defines the camera's ID
  34282. * @return the new active camera or null if none found.
  34283. */
  34284. setActiveCameraByID(id: string): Nullable<Camera>;
  34285. /**
  34286. * sets the active camera of the scene using its name
  34287. * @param name defines the camera's name
  34288. * @returns the new active camera or null if none found.
  34289. */
  34290. setActiveCameraByName(name: string): Nullable<Camera>;
  34291. /**
  34292. * get an animation group using its name
  34293. * @param name defines the material's name
  34294. * @return the animation group or null if none found.
  34295. */
  34296. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34297. /**
  34298. * Get a material using its unique id
  34299. * @param uniqueId defines the material's unique id
  34300. * @return the material or null if none found.
  34301. */
  34302. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34303. /**
  34304. * get a material using its id
  34305. * @param id defines the material's ID
  34306. * @return the material or null if none found.
  34307. */
  34308. getMaterialByID(id: string): Nullable<Material>;
  34309. /**
  34310. * Gets a material using its name
  34311. * @param name defines the material's name
  34312. * @return the material or null if none found.
  34313. */
  34314. getMaterialByName(name: string): Nullable<Material>;
  34315. /**
  34316. * Gets a camera using its id
  34317. * @param id defines the id to look for
  34318. * @returns the camera or null if not found
  34319. */
  34320. getCameraByID(id: string): Nullable<Camera>;
  34321. /**
  34322. * Gets a camera using its unique id
  34323. * @param uniqueId defines the unique id to look for
  34324. * @returns the camera or null if not found
  34325. */
  34326. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34327. /**
  34328. * Gets a camera using its name
  34329. * @param name defines the camera's name
  34330. * @return the camera or null if none found.
  34331. */
  34332. getCameraByName(name: string): Nullable<Camera>;
  34333. /**
  34334. * Gets a bone using its id
  34335. * @param id defines the bone's id
  34336. * @return the bone or null if not found
  34337. */
  34338. getBoneByID(id: string): Nullable<Bone>;
  34339. /**
  34340. * Gets a bone using its id
  34341. * @param name defines the bone's name
  34342. * @return the bone or null if not found
  34343. */
  34344. getBoneByName(name: string): Nullable<Bone>;
  34345. /**
  34346. * Gets a light node using its name
  34347. * @param name defines the the light's name
  34348. * @return the light or null if none found.
  34349. */
  34350. getLightByName(name: string): Nullable<Light>;
  34351. /**
  34352. * Gets a light node using its id
  34353. * @param id defines the light's id
  34354. * @return the light or null if none found.
  34355. */
  34356. getLightByID(id: string): Nullable<Light>;
  34357. /**
  34358. * Gets a light node using its scene-generated unique ID
  34359. * @param uniqueId defines the light's unique id
  34360. * @return the light or null if none found.
  34361. */
  34362. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34363. /**
  34364. * Gets a particle system by id
  34365. * @param id defines the particle system id
  34366. * @return the corresponding system or null if none found
  34367. */
  34368. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34369. /**
  34370. * Gets a geometry using its ID
  34371. * @param id defines the geometry's id
  34372. * @return the geometry or null if none found.
  34373. */
  34374. getGeometryByID(id: string): Nullable<Geometry>;
  34375. private _getGeometryByUniqueID;
  34376. /**
  34377. * Add a new geometry to this scene
  34378. * @param geometry defines the geometry to be added to the scene.
  34379. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34380. * @return a boolean defining if the geometry was added or not
  34381. */
  34382. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34383. /**
  34384. * Removes an existing geometry
  34385. * @param geometry defines the geometry to be removed from the scene
  34386. * @return a boolean defining if the geometry was removed or not
  34387. */
  34388. removeGeometry(geometry: Geometry): boolean;
  34389. /**
  34390. * Gets the list of geometries attached to the scene
  34391. * @returns an array of Geometry
  34392. */
  34393. getGeometries(): Geometry[];
  34394. /**
  34395. * Gets the first added mesh found of a given ID
  34396. * @param id defines the id to search for
  34397. * @return the mesh found or null if not found at all
  34398. */
  34399. getMeshByID(id: string): Nullable<AbstractMesh>;
  34400. /**
  34401. * Gets a list of meshes using their id
  34402. * @param id defines the id to search for
  34403. * @returns a list of meshes
  34404. */
  34405. getMeshesByID(id: string): Array<AbstractMesh>;
  34406. /**
  34407. * Gets the first added transform node found of a given ID
  34408. * @param id defines the id to search for
  34409. * @return the found transform node or null if not found at all.
  34410. */
  34411. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34412. /**
  34413. * Gets a transform node with its auto-generated unique id
  34414. * @param uniqueId efines the unique id to search for
  34415. * @return the found transform node or null if not found at all.
  34416. */
  34417. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34418. /**
  34419. * Gets a list of transform nodes using their id
  34420. * @param id defines the id to search for
  34421. * @returns a list of transform nodes
  34422. */
  34423. getTransformNodesByID(id: string): Array<TransformNode>;
  34424. /**
  34425. * Gets a mesh with its auto-generated unique id
  34426. * @param uniqueId defines the unique id to search for
  34427. * @return the found mesh or null if not found at all.
  34428. */
  34429. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34430. /**
  34431. * Gets a the last added mesh using a given id
  34432. * @param id defines the id to search for
  34433. * @return the found mesh or null if not found at all.
  34434. */
  34435. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34436. /**
  34437. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34438. * @param id defines the id to search for
  34439. * @return the found node or null if not found at all
  34440. */
  34441. getLastEntryByID(id: string): Nullable<Node>;
  34442. /**
  34443. * Gets a node (Mesh, Camera, Light) using a given id
  34444. * @param id defines the id to search for
  34445. * @return the found node or null if not found at all
  34446. */
  34447. getNodeByID(id: string): Nullable<Node>;
  34448. /**
  34449. * Gets a node (Mesh, Camera, Light) using a given name
  34450. * @param name defines the name to search for
  34451. * @return the found node or null if not found at all.
  34452. */
  34453. getNodeByName(name: string): Nullable<Node>;
  34454. /**
  34455. * Gets a mesh using a given name
  34456. * @param name defines the name to search for
  34457. * @return the found mesh or null if not found at all.
  34458. */
  34459. getMeshByName(name: string): Nullable<AbstractMesh>;
  34460. /**
  34461. * Gets a transform node using a given name
  34462. * @param name defines the name to search for
  34463. * @return the found transform node or null if not found at all.
  34464. */
  34465. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34466. /**
  34467. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34468. * @param id defines the id to search for
  34469. * @return the found skeleton or null if not found at all.
  34470. */
  34471. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34472. /**
  34473. * Gets a skeleton using a given auto generated unique id
  34474. * @param uniqueId defines the unique id to search for
  34475. * @return the found skeleton or null if not found at all.
  34476. */
  34477. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34478. /**
  34479. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34480. * @param id defines the id to search for
  34481. * @return the found skeleton or null if not found at all.
  34482. */
  34483. getSkeletonById(id: string): Nullable<Skeleton>;
  34484. /**
  34485. * Gets a skeleton using a given name
  34486. * @param name defines the name to search for
  34487. * @return the found skeleton or null if not found at all.
  34488. */
  34489. getSkeletonByName(name: string): Nullable<Skeleton>;
  34490. /**
  34491. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34492. * @param id defines the id to search for
  34493. * @return the found morph target manager or null if not found at all.
  34494. */
  34495. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34496. /**
  34497. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34498. * @param id defines the id to search for
  34499. * @return the found morph target or null if not found at all.
  34500. */
  34501. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34502. /**
  34503. * Gets a boolean indicating if the given mesh is active
  34504. * @param mesh defines the mesh to look for
  34505. * @returns true if the mesh is in the active list
  34506. */
  34507. isActiveMesh(mesh: AbstractMesh): boolean;
  34508. /**
  34509. * Return a unique id as a string which can serve as an identifier for the scene
  34510. */
  34511. readonly uid: string;
  34512. /**
  34513. * Add an externaly attached data from its key.
  34514. * This method call will fail and return false, if such key already exists.
  34515. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34516. * @param key the unique key that identifies the data
  34517. * @param data the data object to associate to the key for this Engine instance
  34518. * @return true if no such key were already present and the data was added successfully, false otherwise
  34519. */
  34520. addExternalData<T>(key: string, data: T): boolean;
  34521. /**
  34522. * Get an externaly attached data from its key
  34523. * @param key the unique key that identifies the data
  34524. * @return the associated data, if present (can be null), or undefined if not present
  34525. */
  34526. getExternalData<T>(key: string): Nullable<T>;
  34527. /**
  34528. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34529. * @param key the unique key that identifies the data
  34530. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34531. * @return the associated data, can be null if the factory returned null.
  34532. */
  34533. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34534. /**
  34535. * Remove an externaly attached data from the Engine instance
  34536. * @param key the unique key that identifies the data
  34537. * @return true if the data was successfully removed, false if it doesn't exist
  34538. */
  34539. removeExternalData(key: string): boolean;
  34540. private _evaluateSubMesh;
  34541. /**
  34542. * Clear the processed materials smart array preventing retention point in material dispose.
  34543. */
  34544. freeProcessedMaterials(): void;
  34545. private _preventFreeActiveMeshesAndRenderingGroups;
  34546. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34547. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34548. * when disposing several meshes in a row or a hierarchy of meshes.
  34549. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34550. */
  34551. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34552. /**
  34553. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34554. */
  34555. freeActiveMeshes(): void;
  34556. /**
  34557. * Clear the info related to rendering groups preventing retention points during dispose.
  34558. */
  34559. freeRenderingGroups(): void;
  34560. /** @hidden */
  34561. _isInIntermediateRendering(): boolean;
  34562. /**
  34563. * Lambda returning the list of potentially active meshes.
  34564. */
  34565. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34566. /**
  34567. * Lambda returning the list of potentially active sub meshes.
  34568. */
  34569. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34570. /**
  34571. * Lambda returning the list of potentially intersecting sub meshes.
  34572. */
  34573. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34574. /**
  34575. * Lambda returning the list of potentially colliding sub meshes.
  34576. */
  34577. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34578. private _activeMeshesFrozen;
  34579. /**
  34580. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34581. * @returns the current scene
  34582. */
  34583. freezeActiveMeshes(): Scene;
  34584. /**
  34585. * Use this function to restart evaluating active meshes on every frame
  34586. * @returns the current scene
  34587. */
  34588. unfreezeActiveMeshes(): Scene;
  34589. private _evaluateActiveMeshes;
  34590. private _activeMesh;
  34591. /**
  34592. * Update the transform matrix to update from the current active camera
  34593. * @param force defines a boolean used to force the update even if cache is up to date
  34594. */
  34595. updateTransformMatrix(force?: boolean): void;
  34596. private _bindFrameBuffer;
  34597. /** @hidden */
  34598. _allowPostProcessClearColor: boolean;
  34599. /** @hidden */
  34600. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34601. private _processSubCameras;
  34602. private _checkIntersections;
  34603. /** @hidden */
  34604. _advancePhysicsEngineStep(step: number): void;
  34605. /**
  34606. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34607. */
  34608. getDeterministicFrameTime: () => number;
  34609. /** @hidden */
  34610. _animate(): void;
  34611. /** Execute all animations (for a frame) */
  34612. animate(): void;
  34613. /**
  34614. * Render the scene
  34615. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34616. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34617. */
  34618. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34619. /**
  34620. * Freeze all materials
  34621. * A frozen material will not be updatable but should be faster to render
  34622. */
  34623. freezeMaterials(): void;
  34624. /**
  34625. * Unfreeze all materials
  34626. * A frozen material will not be updatable but should be faster to render
  34627. */
  34628. unfreezeMaterials(): void;
  34629. /**
  34630. * Releases all held ressources
  34631. */
  34632. dispose(): void;
  34633. /**
  34634. * Gets if the scene is already disposed
  34635. */
  34636. readonly isDisposed: boolean;
  34637. /**
  34638. * Call this function to reduce memory footprint of the scene.
  34639. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34640. */
  34641. clearCachedVertexData(): void;
  34642. /**
  34643. * This function will remove the local cached buffer data from texture.
  34644. * It will save memory but will prevent the texture from being rebuilt
  34645. */
  34646. cleanCachedTextureBuffer(): void;
  34647. /**
  34648. * Get the world extend vectors with an optional filter
  34649. *
  34650. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34651. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34652. */
  34653. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34654. min: Vector3;
  34655. max: Vector3;
  34656. };
  34657. /**
  34658. * Creates a ray that can be used to pick in the scene
  34659. * @param x defines the x coordinate of the origin (on-screen)
  34660. * @param y defines the y coordinate of the origin (on-screen)
  34661. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34662. * @param camera defines the camera to use for the picking
  34663. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34664. * @returns a Ray
  34665. */
  34666. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34667. /**
  34668. * Creates a ray that can be used to pick in the scene
  34669. * @param x defines the x coordinate of the origin (on-screen)
  34670. * @param y defines the y coordinate of the origin (on-screen)
  34671. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34672. * @param result defines the ray where to store the picking ray
  34673. * @param camera defines the camera to use for the picking
  34674. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34675. * @returns the current scene
  34676. */
  34677. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34678. /**
  34679. * Creates a ray that can be used to pick in the scene
  34680. * @param x defines the x coordinate of the origin (on-screen)
  34681. * @param y defines the y coordinate of the origin (on-screen)
  34682. * @param camera defines the camera to use for the picking
  34683. * @returns a Ray
  34684. */
  34685. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34686. /**
  34687. * Creates a ray that can be used to pick in the scene
  34688. * @param x defines the x coordinate of the origin (on-screen)
  34689. * @param y defines the y coordinate of the origin (on-screen)
  34690. * @param result defines the ray where to store the picking ray
  34691. * @param camera defines the camera to use for the picking
  34692. * @returns the current scene
  34693. */
  34694. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34695. /** Launch a ray to try to pick a mesh in the scene
  34696. * @param x position on screen
  34697. * @param y position on screen
  34698. * @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
  34699. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34700. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34701. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34702. * @returns a PickingInfo
  34703. */
  34704. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34705. /** Use the given ray to pick a mesh in the scene
  34706. * @param ray The ray to use to pick meshes
  34707. * @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
  34708. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34709. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34710. * @returns a PickingInfo
  34711. */
  34712. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34713. /**
  34714. * Launch a ray to try to pick a mesh in the scene
  34715. * @param x X position on screen
  34716. * @param y Y position on screen
  34717. * @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
  34718. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34719. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34720. * @returns an array of PickingInfo
  34721. */
  34722. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34723. /**
  34724. * Launch a ray to try to pick a mesh in the scene
  34725. * @param ray Ray to use
  34726. * @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
  34727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34728. * @returns an array of PickingInfo
  34729. */
  34730. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34731. /**
  34732. * Force the value of meshUnderPointer
  34733. * @param mesh defines the mesh to use
  34734. */
  34735. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34736. /**
  34737. * Gets the mesh under the pointer
  34738. * @returns a Mesh or null if no mesh is under the pointer
  34739. */
  34740. getPointerOverMesh(): Nullable<AbstractMesh>;
  34741. /** @hidden */
  34742. _rebuildGeometries(): void;
  34743. /** @hidden */
  34744. _rebuildTextures(): void;
  34745. private _getByTags;
  34746. /**
  34747. * Get a list of meshes by tags
  34748. * @param tagsQuery defines the tags query to use
  34749. * @param forEach defines a predicate used to filter results
  34750. * @returns an array of Mesh
  34751. */
  34752. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34753. /**
  34754. * Get a list of cameras by tags
  34755. * @param tagsQuery defines the tags query to use
  34756. * @param forEach defines a predicate used to filter results
  34757. * @returns an array of Camera
  34758. */
  34759. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34760. /**
  34761. * Get a list of lights by tags
  34762. * @param tagsQuery defines the tags query to use
  34763. * @param forEach defines a predicate used to filter results
  34764. * @returns an array of Light
  34765. */
  34766. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34767. /**
  34768. * Get a list of materials by tags
  34769. * @param tagsQuery defines the tags query to use
  34770. * @param forEach defines a predicate used to filter results
  34771. * @returns an array of Material
  34772. */
  34773. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34774. /**
  34775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34776. * This allowed control for front to back rendering or reversly depending of the special needs.
  34777. *
  34778. * @param renderingGroupId The rendering group id corresponding to its index
  34779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34782. */
  34783. 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;
  34784. /**
  34785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34786. *
  34787. * @param renderingGroupId The rendering group id corresponding to its index
  34788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34789. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34790. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34791. */
  34792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34793. /**
  34794. * Gets the current auto clear configuration for one rendering group of the rendering
  34795. * manager.
  34796. * @param index the rendering group index to get the information for
  34797. * @returns The auto clear setup for the requested rendering group
  34798. */
  34799. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34800. private _blockMaterialDirtyMechanism;
  34801. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34802. blockMaterialDirtyMechanism: boolean;
  34803. /**
  34804. * Will flag all materials as dirty to trigger new shader compilation
  34805. * @param flag defines the flag used to specify which material part must be marked as dirty
  34806. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34807. */
  34808. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34809. /** @hidden */
  34810. _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;
  34811. /** @hidden */
  34812. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34813. }
  34814. }
  34815. declare module "babylonjs/assetContainer" {
  34816. import { AbstractScene } from "babylonjs/abstractScene";
  34817. import { Scene } from "babylonjs/scene";
  34818. import { Mesh } from "babylonjs/Meshes/mesh";
  34819. /**
  34820. * Set of assets to keep when moving a scene into an asset container.
  34821. */
  34822. export class KeepAssets extends AbstractScene {
  34823. }
  34824. /**
  34825. * Container with a set of assets that can be added or removed from a scene.
  34826. */
  34827. export class AssetContainer extends AbstractScene {
  34828. /**
  34829. * The scene the AssetContainer belongs to.
  34830. */
  34831. scene: Scene;
  34832. /**
  34833. * Instantiates an AssetContainer.
  34834. * @param scene The scene the AssetContainer belongs to.
  34835. */
  34836. constructor(scene: Scene);
  34837. /**
  34838. * Adds all the assets from the container to the scene.
  34839. */
  34840. addAllToScene(): void;
  34841. /**
  34842. * Removes all the assets in the container from the scene
  34843. */
  34844. removeAllFromScene(): void;
  34845. /**
  34846. * Disposes all the assets in the container
  34847. */
  34848. dispose(): void;
  34849. private _moveAssets;
  34850. /**
  34851. * Removes all the assets contained in the scene and adds them to the container.
  34852. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34853. */
  34854. moveAllFromScene(keepAssets?: KeepAssets): void;
  34855. /**
  34856. * 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.
  34857. * @returns the root mesh
  34858. */
  34859. createRootMesh(): Mesh;
  34860. }
  34861. }
  34862. declare module "babylonjs/abstractScene" {
  34863. import { Scene } from "babylonjs/scene";
  34864. import { Nullable } from "babylonjs/types";
  34865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34866. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34867. import { Geometry } from "babylonjs/Meshes/geometry";
  34868. import { Skeleton } from "babylonjs/Bones/skeleton";
  34869. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34870. import { AssetContainer } from "babylonjs/assetContainer";
  34871. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34872. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34874. import { Material } from "babylonjs/Materials/material";
  34875. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34876. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34877. import { Camera } from "babylonjs/Cameras/camera";
  34878. import { Light } from "babylonjs/Lights/light";
  34879. import { Node } from "babylonjs/node";
  34880. import { Animation } from "babylonjs/Animations/animation";
  34881. /**
  34882. * Defines how the parser contract is defined.
  34883. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34884. */
  34885. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34886. /**
  34887. * Defines how the individual parser contract is defined.
  34888. * These parser can parse an individual asset
  34889. */
  34890. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34891. /**
  34892. * Base class of the scene acting as a container for the different elements composing a scene.
  34893. * This class is dynamically extended by the different components of the scene increasing
  34894. * flexibility and reducing coupling
  34895. */
  34896. export abstract class AbstractScene {
  34897. /**
  34898. * Stores the list of available parsers in the application.
  34899. */
  34900. private static _BabylonFileParsers;
  34901. /**
  34902. * Stores the list of available individual parsers in the application.
  34903. */
  34904. private static _IndividualBabylonFileParsers;
  34905. /**
  34906. * Adds a parser in the list of available ones
  34907. * @param name Defines the name of the parser
  34908. * @param parser Defines the parser to add
  34909. */
  34910. static AddParser(name: string, parser: BabylonFileParser): void;
  34911. /**
  34912. * Gets a general parser from the list of avaialble ones
  34913. * @param name Defines the name of the parser
  34914. * @returns the requested parser or null
  34915. */
  34916. static GetParser(name: string): Nullable<BabylonFileParser>;
  34917. /**
  34918. * Adds n individual parser in the list of available ones
  34919. * @param name Defines the name of the parser
  34920. * @param parser Defines the parser to add
  34921. */
  34922. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34923. /**
  34924. * Gets an individual parser from the list of avaialble ones
  34925. * @param name Defines the name of the parser
  34926. * @returns the requested parser or null
  34927. */
  34928. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34929. /**
  34930. * Parser json data and populate both a scene and its associated container object
  34931. * @param jsonData Defines the data to parse
  34932. * @param scene Defines the scene to parse the data for
  34933. * @param container Defines the container attached to the parsing sequence
  34934. * @param rootUrl Defines the root url of the data
  34935. */
  34936. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34937. /**
  34938. * Gets the list of root nodes (ie. nodes with no parent)
  34939. */
  34940. rootNodes: Node[];
  34941. /** All of the cameras added to this scene
  34942. * @see http://doc.babylonjs.com/babylon101/cameras
  34943. */
  34944. cameras: Camera[];
  34945. /**
  34946. * All of the lights added to this scene
  34947. * @see http://doc.babylonjs.com/babylon101/lights
  34948. */
  34949. lights: Light[];
  34950. /**
  34951. * All of the (abstract) meshes added to this scene
  34952. */
  34953. meshes: AbstractMesh[];
  34954. /**
  34955. * The list of skeletons added to the scene
  34956. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34957. */
  34958. skeletons: Skeleton[];
  34959. /**
  34960. * All of the particle systems added to this scene
  34961. * @see http://doc.babylonjs.com/babylon101/particles
  34962. */
  34963. particleSystems: IParticleSystem[];
  34964. /**
  34965. * Gets a list of Animations associated with the scene
  34966. */
  34967. animations: Animation[];
  34968. /**
  34969. * All of the animation groups added to this scene
  34970. * @see http://doc.babylonjs.com/how_to/group
  34971. */
  34972. animationGroups: AnimationGroup[];
  34973. /**
  34974. * All of the multi-materials added to this scene
  34975. * @see http://doc.babylonjs.com/how_to/multi_materials
  34976. */
  34977. multiMaterials: MultiMaterial[];
  34978. /**
  34979. * All of the materials added to this scene
  34980. * In the context of a Scene, it is not supposed to be modified manually.
  34981. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34982. * Note also that the order of the Material wihin the array is not significant and might change.
  34983. * @see http://doc.babylonjs.com/babylon101/materials
  34984. */
  34985. materials: Material[];
  34986. /**
  34987. * The list of morph target managers added to the scene
  34988. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34989. */
  34990. morphTargetManagers: MorphTargetManager[];
  34991. /**
  34992. * The list of geometries used in the scene.
  34993. */
  34994. geometries: Geometry[];
  34995. /**
  34996. * All of the tranform nodes added to this scene
  34997. * In the context of a Scene, it is not supposed to be modified manually.
  34998. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34999. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35000. * @see http://doc.babylonjs.com/how_to/transformnode
  35001. */
  35002. transformNodes: TransformNode[];
  35003. /**
  35004. * ActionManagers available on the scene.
  35005. */
  35006. actionManagers: AbstractActionManager[];
  35007. /**
  35008. * Textures to keep.
  35009. */
  35010. textures: BaseTexture[];
  35011. /**
  35012. * Environment texture for the scene
  35013. */
  35014. environmentTexture: Nullable<BaseTexture>;
  35015. }
  35016. }
  35017. declare module "babylonjs/Audio/sound" {
  35018. import { Observable } from "babylonjs/Misc/observable";
  35019. import { Vector3 } from "babylonjs/Maths/math";
  35020. import { Nullable } from "babylonjs/types";
  35021. import { Scene } from "babylonjs/scene";
  35022. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35023. /**
  35024. * Defines a sound that can be played in the application.
  35025. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35027. */
  35028. export class Sound {
  35029. /**
  35030. * The name of the sound in the scene.
  35031. */
  35032. name: string;
  35033. /**
  35034. * Does the sound autoplay once loaded.
  35035. */
  35036. autoplay: boolean;
  35037. /**
  35038. * Does the sound loop after it finishes playing once.
  35039. */
  35040. loop: boolean;
  35041. /**
  35042. * Does the sound use a custom attenuation curve to simulate the falloff
  35043. * happening when the source gets further away from the camera.
  35044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35045. */
  35046. useCustomAttenuation: boolean;
  35047. /**
  35048. * The sound track id this sound belongs to.
  35049. */
  35050. soundTrackId: number;
  35051. /**
  35052. * Is this sound currently played.
  35053. */
  35054. isPlaying: boolean;
  35055. /**
  35056. * Is this sound currently paused.
  35057. */
  35058. isPaused: boolean;
  35059. /**
  35060. * Does this sound enables spatial sound.
  35061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35062. */
  35063. spatialSound: boolean;
  35064. /**
  35065. * Define the reference distance the sound should be heard perfectly.
  35066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35067. */
  35068. refDistance: number;
  35069. /**
  35070. * Define the roll off factor of spatial sounds.
  35071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35072. */
  35073. rolloffFactor: number;
  35074. /**
  35075. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35077. */
  35078. maxDistance: number;
  35079. /**
  35080. * Define the distance attenuation model the sound will follow.
  35081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35082. */
  35083. distanceModel: string;
  35084. /**
  35085. * @hidden
  35086. * Back Compat
  35087. **/
  35088. onended: () => any;
  35089. /**
  35090. * Observable event when the current playing sound finishes.
  35091. */
  35092. onEndedObservable: Observable<Sound>;
  35093. private _panningModel;
  35094. private _playbackRate;
  35095. private _streaming;
  35096. private _startTime;
  35097. private _startOffset;
  35098. private _position;
  35099. /** @hidden */
  35100. _positionInEmitterSpace: boolean;
  35101. private _localDirection;
  35102. private _volume;
  35103. private _isReadyToPlay;
  35104. private _isDirectional;
  35105. private _readyToPlayCallback;
  35106. private _audioBuffer;
  35107. private _soundSource;
  35108. private _streamingSource;
  35109. private _soundPanner;
  35110. private _soundGain;
  35111. private _inputAudioNode;
  35112. private _outputAudioNode;
  35113. private _coneInnerAngle;
  35114. private _coneOuterAngle;
  35115. private _coneOuterGain;
  35116. private _scene;
  35117. private _connectedTransformNode;
  35118. private _customAttenuationFunction;
  35119. private _registerFunc;
  35120. private _isOutputConnected;
  35121. private _htmlAudioElement;
  35122. private _urlType;
  35123. /** @hidden */
  35124. static _SceneComponentInitialization: (scene: Scene) => void;
  35125. /**
  35126. * Create a sound and attach it to a scene
  35127. * @param name Name of your sound
  35128. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35129. * @param scene defines the scene the sound belongs to
  35130. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35131. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35132. */
  35133. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  35134. /**
  35135. * Release the sound and its associated resources
  35136. */
  35137. dispose(): void;
  35138. /**
  35139. * Gets if the sounds is ready to be played or not.
  35140. * @returns true if ready, otherwise false
  35141. */
  35142. isReady(): boolean;
  35143. private _soundLoaded;
  35144. /**
  35145. * Sets the data of the sound from an audiobuffer
  35146. * @param audioBuffer The audioBuffer containing the data
  35147. */
  35148. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35149. /**
  35150. * Updates the current sounds options such as maxdistance, loop...
  35151. * @param options A JSON object containing values named as the object properties
  35152. */
  35153. updateOptions(options: any): void;
  35154. private _createSpatialParameters;
  35155. private _updateSpatialParameters;
  35156. /**
  35157. * Switch the panning model to HRTF:
  35158. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35160. */
  35161. switchPanningModelToHRTF(): void;
  35162. /**
  35163. * Switch the panning model to Equal Power:
  35164. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35166. */
  35167. switchPanningModelToEqualPower(): void;
  35168. private _switchPanningModel;
  35169. /**
  35170. * Connect this sound to a sound track audio node like gain...
  35171. * @param soundTrackAudioNode the sound track audio node to connect to
  35172. */
  35173. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35174. /**
  35175. * Transform this sound into a directional source
  35176. * @param coneInnerAngle Size of the inner cone in degree
  35177. * @param coneOuterAngle Size of the outer cone in degree
  35178. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35179. */
  35180. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35181. /**
  35182. * Gets or sets the inner angle for the directional cone.
  35183. */
  35184. /**
  35185. * Gets or sets the inner angle for the directional cone.
  35186. */
  35187. directionalConeInnerAngle: number;
  35188. /**
  35189. * Gets or sets the outer angle for the directional cone.
  35190. */
  35191. /**
  35192. * Gets or sets the outer angle for the directional cone.
  35193. */
  35194. directionalConeOuterAngle: number;
  35195. /**
  35196. * Sets the position of the emitter if spatial sound is enabled
  35197. * @param newPosition Defines the new posisiton
  35198. */
  35199. setPosition(newPosition: Vector3): void;
  35200. /**
  35201. * Sets the local direction of the emitter if spatial sound is enabled
  35202. * @param newLocalDirection Defines the new local direction
  35203. */
  35204. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35205. private _updateDirection;
  35206. /** @hidden */
  35207. updateDistanceFromListener(): void;
  35208. /**
  35209. * Sets a new custom attenuation function for the sound.
  35210. * @param callback Defines the function used for the attenuation
  35211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35212. */
  35213. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35214. /**
  35215. * Play the sound
  35216. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35217. * @param offset (optional) Start the sound setting it at a specific time
  35218. */
  35219. play(time?: number, offset?: number): void;
  35220. private _onended;
  35221. /**
  35222. * Stop the sound
  35223. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35224. */
  35225. stop(time?: number): void;
  35226. /**
  35227. * Put the sound in pause
  35228. */
  35229. pause(): void;
  35230. /**
  35231. * Sets a dedicated volume for this sounds
  35232. * @param newVolume Define the new volume of the sound
  35233. * @param time Define in how long the sound should be at this value
  35234. */
  35235. setVolume(newVolume: number, time?: number): void;
  35236. /**
  35237. * Set the sound play back rate
  35238. * @param newPlaybackRate Define the playback rate the sound should be played at
  35239. */
  35240. setPlaybackRate(newPlaybackRate: number): void;
  35241. /**
  35242. * Gets the volume of the sound.
  35243. * @returns the volume of the sound
  35244. */
  35245. getVolume(): number;
  35246. /**
  35247. * Attach the sound to a dedicated mesh
  35248. * @param transformNode The transform node to connect the sound with
  35249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35250. */
  35251. attachToMesh(transformNode: TransformNode): void;
  35252. /**
  35253. * Detach the sound from the previously attached mesh
  35254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35255. */
  35256. detachFromMesh(): void;
  35257. private _onRegisterAfterWorldMatrixUpdate;
  35258. /**
  35259. * Clone the current sound in the scene.
  35260. * @returns the new sound clone
  35261. */
  35262. clone(): Nullable<Sound>;
  35263. /**
  35264. * Gets the current underlying audio buffer containing the data
  35265. * @returns the audio buffer
  35266. */
  35267. getAudioBuffer(): Nullable<AudioBuffer>;
  35268. /**
  35269. * Serializes the Sound in a JSON representation
  35270. * @returns the JSON representation of the sound
  35271. */
  35272. serialize(): any;
  35273. /**
  35274. * Parse a JSON representation of a sound to innstantiate in a given scene
  35275. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35276. * @param scene Define the scene the new parsed sound should be created in
  35277. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35278. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35279. * @returns the newly parsed sound
  35280. */
  35281. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35282. }
  35283. }
  35284. declare module "babylonjs/Actions/directAudioActions" {
  35285. import { Action } from "babylonjs/Actions/action";
  35286. import { Condition } from "babylonjs/Actions/condition";
  35287. import { Sound } from "babylonjs/Audio/sound";
  35288. /**
  35289. * This defines an action helpful to play a defined sound on a triggered action.
  35290. */
  35291. export class PlaySoundAction extends Action {
  35292. private _sound;
  35293. /**
  35294. * Instantiate the action
  35295. * @param triggerOptions defines the trigger options
  35296. * @param sound defines the sound to play
  35297. * @param condition defines the trigger related conditions
  35298. */
  35299. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35300. /** @hidden */
  35301. _prepare(): void;
  35302. /**
  35303. * Execute the action and play the sound.
  35304. */
  35305. execute(): void;
  35306. /**
  35307. * Serializes the actions and its related information.
  35308. * @param parent defines the object to serialize in
  35309. * @returns the serialized object
  35310. */
  35311. serialize(parent: any): any;
  35312. }
  35313. /**
  35314. * This defines an action helpful to stop a defined sound on a triggered action.
  35315. */
  35316. export class StopSoundAction extends Action {
  35317. private _sound;
  35318. /**
  35319. * Instantiate the action
  35320. * @param triggerOptions defines the trigger options
  35321. * @param sound defines the sound to stop
  35322. * @param condition defines the trigger related conditions
  35323. */
  35324. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35325. /** @hidden */
  35326. _prepare(): void;
  35327. /**
  35328. * Execute the action and stop the sound.
  35329. */
  35330. execute(): void;
  35331. /**
  35332. * Serializes the actions and its related information.
  35333. * @param parent defines the object to serialize in
  35334. * @returns the serialized object
  35335. */
  35336. serialize(parent: any): any;
  35337. }
  35338. }
  35339. declare module "babylonjs/Actions/interpolateValueAction" {
  35340. import { Action } from "babylonjs/Actions/action";
  35341. import { Condition } from "babylonjs/Actions/condition";
  35342. import { Observable } from "babylonjs/Misc/observable";
  35343. /**
  35344. * This defines an action responsible to change the value of a property
  35345. * by interpolating between its current value and the newly set one once triggered.
  35346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35347. */
  35348. export class InterpolateValueAction extends Action {
  35349. /**
  35350. * Defines the path of the property where the value should be interpolated
  35351. */
  35352. propertyPath: string;
  35353. /**
  35354. * Defines the target value at the end of the interpolation.
  35355. */
  35356. value: any;
  35357. /**
  35358. * Defines the time it will take for the property to interpolate to the value.
  35359. */
  35360. duration: number;
  35361. /**
  35362. * Defines if the other scene animations should be stopped when the action has been triggered
  35363. */
  35364. stopOtherAnimations?: boolean;
  35365. /**
  35366. * Defines a callback raised once the interpolation animation has been done.
  35367. */
  35368. onInterpolationDone?: () => void;
  35369. /**
  35370. * Observable triggered once the interpolation animation has been done.
  35371. */
  35372. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35373. private _target;
  35374. private _effectiveTarget;
  35375. private _property;
  35376. /**
  35377. * Instantiate the action
  35378. * @param triggerOptions defines the trigger options
  35379. * @param target defines the object containing the value to interpolate
  35380. * @param propertyPath defines the path to the property in the target object
  35381. * @param value defines the target value at the end of the interpolation
  35382. * @param duration deines the time it will take for the property to interpolate to the value.
  35383. * @param condition defines the trigger related conditions
  35384. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35385. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35386. */
  35387. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35388. /** @hidden */
  35389. _prepare(): void;
  35390. /**
  35391. * Execute the action starts the value interpolation.
  35392. */
  35393. execute(): void;
  35394. /**
  35395. * Serializes the actions and its related information.
  35396. * @param parent defines the object to serialize in
  35397. * @returns the serialized object
  35398. */
  35399. serialize(parent: any): any;
  35400. }
  35401. }
  35402. declare module "babylonjs/Actions/index" {
  35403. export * from "babylonjs/Actions/action";
  35404. export * from "babylonjs/Actions/actionEvent";
  35405. export * from "babylonjs/Actions/actionManager";
  35406. export * from "babylonjs/Actions/condition";
  35407. export * from "babylonjs/Actions/directActions";
  35408. export * from "babylonjs/Actions/directAudioActions";
  35409. export * from "babylonjs/Actions/interpolateValueAction";
  35410. }
  35411. declare module "babylonjs/Animations/index" {
  35412. export * from "babylonjs/Animations/animatable";
  35413. export * from "babylonjs/Animations/animation";
  35414. export * from "babylonjs/Animations/animationGroup";
  35415. export * from "babylonjs/Animations/animationPropertiesOverride";
  35416. export * from "babylonjs/Animations/easing";
  35417. export * from "babylonjs/Animations/runtimeAnimation";
  35418. export * from "babylonjs/Animations/animationEvent";
  35419. export * from "babylonjs/Animations/animationGroup";
  35420. export * from "babylonjs/Animations/animationKey";
  35421. export * from "babylonjs/Animations/animationRange";
  35422. }
  35423. declare module "babylonjs/Audio/soundTrack" {
  35424. import { Sound } from "babylonjs/Audio/sound";
  35425. import { Analyser } from "babylonjs/Audio/analyser";
  35426. import { Scene } from "babylonjs/scene";
  35427. /**
  35428. * Options allowed during the creation of a sound track.
  35429. */
  35430. export interface ISoundTrackOptions {
  35431. /**
  35432. * The volume the sound track should take during creation
  35433. */
  35434. volume?: number;
  35435. /**
  35436. * Define if the sound track is the main sound track of the scene
  35437. */
  35438. mainTrack?: boolean;
  35439. }
  35440. /**
  35441. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35442. * It will be also used in a future release to apply effects on a specific track.
  35443. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35444. */
  35445. export class SoundTrack {
  35446. /**
  35447. * The unique identifier of the sound track in the scene.
  35448. */
  35449. id: number;
  35450. /**
  35451. * The list of sounds included in the sound track.
  35452. */
  35453. soundCollection: Array<Sound>;
  35454. private _outputAudioNode;
  35455. private _scene;
  35456. private _isMainTrack;
  35457. private _connectedAnalyser;
  35458. private _options;
  35459. private _isInitialized;
  35460. /**
  35461. * Creates a new sound track.
  35462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35463. * @param scene Define the scene the sound track belongs to
  35464. * @param options
  35465. */
  35466. constructor(scene: Scene, options?: ISoundTrackOptions);
  35467. private _initializeSoundTrackAudioGraph;
  35468. /**
  35469. * Release the sound track and its associated resources
  35470. */
  35471. dispose(): void;
  35472. /**
  35473. * Adds a sound to this sound track
  35474. * @param sound define the cound to add
  35475. * @ignoreNaming
  35476. */
  35477. AddSound(sound: Sound): void;
  35478. /**
  35479. * Removes a sound to this sound track
  35480. * @param sound define the cound to remove
  35481. * @ignoreNaming
  35482. */
  35483. RemoveSound(sound: Sound): void;
  35484. /**
  35485. * Set a global volume for the full sound track.
  35486. * @param newVolume Define the new volume of the sound track
  35487. */
  35488. setVolume(newVolume: number): void;
  35489. /**
  35490. * Switch the panning model to HRTF:
  35491. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35493. */
  35494. switchPanningModelToHRTF(): void;
  35495. /**
  35496. * Switch the panning model to Equal Power:
  35497. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35499. */
  35500. switchPanningModelToEqualPower(): void;
  35501. /**
  35502. * Connect the sound track to an audio analyser allowing some amazing
  35503. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35505. * @param analyser The analyser to connect to the engine
  35506. */
  35507. connectToAnalyser(analyser: Analyser): void;
  35508. }
  35509. }
  35510. declare module "babylonjs/Audio/audioSceneComponent" {
  35511. import { Sound } from "babylonjs/Audio/sound";
  35512. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35513. import { Nullable } from "babylonjs/types";
  35514. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35515. import { Scene } from "babylonjs/scene";
  35516. import { AbstractScene } from "babylonjs/abstractScene";
  35517. module "babylonjs/abstractScene" {
  35518. interface AbstractScene {
  35519. /**
  35520. * The list of sounds used in the scene.
  35521. */
  35522. sounds: Nullable<Array<Sound>>;
  35523. }
  35524. }
  35525. module "babylonjs/scene" {
  35526. interface Scene {
  35527. /**
  35528. * @hidden
  35529. * Backing field
  35530. */
  35531. _mainSoundTrack: SoundTrack;
  35532. /**
  35533. * The main sound track played by the scene.
  35534. * It cotains your primary collection of sounds.
  35535. */
  35536. mainSoundTrack: SoundTrack;
  35537. /**
  35538. * The list of sound tracks added to the scene
  35539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35540. */
  35541. soundTracks: Nullable<Array<SoundTrack>>;
  35542. /**
  35543. * Gets a sound using a given name
  35544. * @param name defines the name to search for
  35545. * @return the found sound or null if not found at all.
  35546. */
  35547. getSoundByName(name: string): Nullable<Sound>;
  35548. /**
  35549. * Gets or sets if audio support is enabled
  35550. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35551. */
  35552. audioEnabled: boolean;
  35553. /**
  35554. * Gets or sets if audio will be output to headphones
  35555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35556. */
  35557. headphone: boolean;
  35558. }
  35559. }
  35560. /**
  35561. * Defines the sound scene component responsible to manage any sounds
  35562. * in a given scene.
  35563. */
  35564. export class AudioSceneComponent implements ISceneSerializableComponent {
  35565. /**
  35566. * The component name helpfull to identify the component in the list of scene components.
  35567. */
  35568. readonly name: string;
  35569. /**
  35570. * The scene the component belongs to.
  35571. */
  35572. scene: Scene;
  35573. private _audioEnabled;
  35574. /**
  35575. * Gets whether audio is enabled or not.
  35576. * Please use related enable/disable method to switch state.
  35577. */
  35578. readonly audioEnabled: boolean;
  35579. private _headphone;
  35580. /**
  35581. * Gets whether audio is outputing to headphone or not.
  35582. * Please use the according Switch methods to change output.
  35583. */
  35584. readonly headphone: boolean;
  35585. /**
  35586. * Creates a new instance of the component for the given scene
  35587. * @param scene Defines the scene to register the component in
  35588. */
  35589. constructor(scene: Scene);
  35590. /**
  35591. * Registers the component in a given scene
  35592. */
  35593. register(): void;
  35594. /**
  35595. * Rebuilds the elements related to this component in case of
  35596. * context lost for instance.
  35597. */
  35598. rebuild(): void;
  35599. /**
  35600. * Serializes the component data to the specified json object
  35601. * @param serializationObject The object to serialize to
  35602. */
  35603. serialize(serializationObject: any): void;
  35604. /**
  35605. * Adds all the elements from the container to the scene
  35606. * @param container the container holding the elements
  35607. */
  35608. addFromContainer(container: AbstractScene): void;
  35609. /**
  35610. * Removes all the elements in the container from the scene
  35611. * @param container contains the elements to remove
  35612. * @param dispose if the removed element should be disposed (default: false)
  35613. */
  35614. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35615. /**
  35616. * Disposes the component and the associated ressources.
  35617. */
  35618. dispose(): void;
  35619. /**
  35620. * Disables audio in the associated scene.
  35621. */
  35622. disableAudio(): void;
  35623. /**
  35624. * Enables audio in the associated scene.
  35625. */
  35626. enableAudio(): void;
  35627. /**
  35628. * Switch audio to headphone output.
  35629. */
  35630. switchAudioModeForHeadphones(): void;
  35631. /**
  35632. * Switch audio to normal speakers.
  35633. */
  35634. switchAudioModeForNormalSpeakers(): void;
  35635. private _afterRender;
  35636. }
  35637. }
  35638. declare module "babylonjs/Audio/weightedsound" {
  35639. import { Sound } from "babylonjs/Audio/sound";
  35640. /**
  35641. * Wraps one or more Sound objects and selects one with random weight for playback.
  35642. */
  35643. export class WeightedSound {
  35644. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35645. loop: boolean;
  35646. private _coneInnerAngle;
  35647. private _coneOuterAngle;
  35648. private _volume;
  35649. /** A Sound is currently playing. */
  35650. isPlaying: boolean;
  35651. /** A Sound is currently paused. */
  35652. isPaused: boolean;
  35653. private _sounds;
  35654. private _weights;
  35655. private _currentIndex?;
  35656. /**
  35657. * Creates a new WeightedSound from the list of sounds given.
  35658. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35659. * @param sounds Array of Sounds that will be selected from.
  35660. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35661. */
  35662. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35663. /**
  35664. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35665. */
  35666. /**
  35667. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35668. */
  35669. directionalConeInnerAngle: number;
  35670. /**
  35671. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35672. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35673. */
  35674. /**
  35675. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35676. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35677. */
  35678. directionalConeOuterAngle: number;
  35679. /**
  35680. * Playback volume.
  35681. */
  35682. /**
  35683. * Playback volume.
  35684. */
  35685. volume: number;
  35686. private _onended;
  35687. /**
  35688. * Suspend playback
  35689. */
  35690. pause(): void;
  35691. /**
  35692. * Stop playback
  35693. */
  35694. stop(): void;
  35695. /**
  35696. * Start playback.
  35697. * @param startOffset Position the clip head at a specific time in seconds.
  35698. */
  35699. play(startOffset?: number): void;
  35700. }
  35701. }
  35702. declare module "babylonjs/Audio/index" {
  35703. export * from "babylonjs/Audio/analyser";
  35704. export * from "babylonjs/Audio/audioEngine";
  35705. export * from "babylonjs/Audio/audioSceneComponent";
  35706. export * from "babylonjs/Audio/sound";
  35707. export * from "babylonjs/Audio/soundTrack";
  35708. export * from "babylonjs/Audio/weightedsound";
  35709. }
  35710. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35711. import { Behavior } from "babylonjs/Behaviors/behavior";
  35712. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35713. import { BackEase } from "babylonjs/Animations/easing";
  35714. /**
  35715. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35716. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35717. */
  35718. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35719. /**
  35720. * Gets the name of the behavior.
  35721. */
  35722. readonly name: string;
  35723. /**
  35724. * The easing function used by animations
  35725. */
  35726. static EasingFunction: BackEase;
  35727. /**
  35728. * The easing mode used by animations
  35729. */
  35730. static EasingMode: number;
  35731. /**
  35732. * The duration of the animation, in milliseconds
  35733. */
  35734. transitionDuration: number;
  35735. /**
  35736. * Length of the distance animated by the transition when lower radius is reached
  35737. */
  35738. lowerRadiusTransitionRange: number;
  35739. /**
  35740. * Length of the distance animated by the transition when upper radius is reached
  35741. */
  35742. upperRadiusTransitionRange: number;
  35743. private _autoTransitionRange;
  35744. /**
  35745. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35746. */
  35747. /**
  35748. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35749. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35750. */
  35751. autoTransitionRange: boolean;
  35752. private _attachedCamera;
  35753. private _onAfterCheckInputsObserver;
  35754. private _onMeshTargetChangedObserver;
  35755. /**
  35756. * Initializes the behavior.
  35757. */
  35758. init(): void;
  35759. /**
  35760. * Attaches the behavior to its arc rotate camera.
  35761. * @param camera Defines the camera to attach the behavior to
  35762. */
  35763. attach(camera: ArcRotateCamera): void;
  35764. /**
  35765. * Detaches the behavior from its current arc rotate camera.
  35766. */
  35767. detach(): void;
  35768. private _radiusIsAnimating;
  35769. private _radiusBounceTransition;
  35770. private _animatables;
  35771. private _cachedWheelPrecision;
  35772. /**
  35773. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35774. * @param radiusLimit The limit to check against.
  35775. * @return Bool to indicate if at limit.
  35776. */
  35777. private _isRadiusAtLimit;
  35778. /**
  35779. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35780. * @param radiusDelta The delta by which to animate to. Can be negative.
  35781. */
  35782. private _applyBoundRadiusAnimation;
  35783. /**
  35784. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35785. */
  35786. protected _clearAnimationLocks(): void;
  35787. /**
  35788. * Stops and removes all animations that have been applied to the camera
  35789. */
  35790. stopAllAnimations(): void;
  35791. }
  35792. }
  35793. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35794. import { Behavior } from "babylonjs/Behaviors/behavior";
  35795. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35796. import { ExponentialEase } from "babylonjs/Animations/easing";
  35797. import { Nullable } from "babylonjs/types";
  35798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35799. import { Vector3 } from "babylonjs/Maths/math";
  35800. /**
  35801. * 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.
  35802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35803. */
  35804. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35805. /**
  35806. * Gets the name of the behavior.
  35807. */
  35808. readonly name: string;
  35809. private _mode;
  35810. private _radiusScale;
  35811. private _positionScale;
  35812. private _defaultElevation;
  35813. private _elevationReturnTime;
  35814. private _elevationReturnWaitTime;
  35815. private _zoomStopsAnimation;
  35816. private _framingTime;
  35817. /**
  35818. * The easing function used by animations
  35819. */
  35820. static EasingFunction: ExponentialEase;
  35821. /**
  35822. * The easing mode used by animations
  35823. */
  35824. static EasingMode: number;
  35825. /**
  35826. * Sets the current mode used by the behavior
  35827. */
  35828. /**
  35829. * Gets current mode used by the behavior.
  35830. */
  35831. mode: number;
  35832. /**
  35833. * Sets the scale applied to the radius (1 by default)
  35834. */
  35835. /**
  35836. * Gets the scale applied to the radius
  35837. */
  35838. radiusScale: number;
  35839. /**
  35840. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35841. */
  35842. /**
  35843. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35844. */
  35845. positionScale: number;
  35846. /**
  35847. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35848. * behaviour is triggered, in radians.
  35849. */
  35850. /**
  35851. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35852. * behaviour is triggered, in radians.
  35853. */
  35854. defaultElevation: number;
  35855. /**
  35856. * Sets the time (in milliseconds) taken to return to the default beta position.
  35857. * Negative value indicates camera should not return to default.
  35858. */
  35859. /**
  35860. * Gets the time (in milliseconds) taken to return to the default beta position.
  35861. * Negative value indicates camera should not return to default.
  35862. */
  35863. elevationReturnTime: number;
  35864. /**
  35865. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35866. */
  35867. /**
  35868. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35869. */
  35870. elevationReturnWaitTime: number;
  35871. /**
  35872. * Sets the flag that indicates if user zooming should stop animation.
  35873. */
  35874. /**
  35875. * Gets the flag that indicates if user zooming should stop animation.
  35876. */
  35877. zoomStopsAnimation: boolean;
  35878. /**
  35879. * Sets the transition time when framing the mesh, in milliseconds
  35880. */
  35881. /**
  35882. * Gets the transition time when framing the mesh, in milliseconds
  35883. */
  35884. framingTime: number;
  35885. /**
  35886. * Define if the behavior should automatically change the configured
  35887. * camera limits and sensibilities.
  35888. */
  35889. autoCorrectCameraLimitsAndSensibility: boolean;
  35890. private _onPrePointerObservableObserver;
  35891. private _onAfterCheckInputsObserver;
  35892. private _onMeshTargetChangedObserver;
  35893. private _attachedCamera;
  35894. private _isPointerDown;
  35895. private _lastInteractionTime;
  35896. /**
  35897. * Initializes the behavior.
  35898. */
  35899. init(): void;
  35900. /**
  35901. * Attaches the behavior to its arc rotate camera.
  35902. * @param camera Defines the camera to attach the behavior to
  35903. */
  35904. attach(camera: ArcRotateCamera): void;
  35905. /**
  35906. * Detaches the behavior from its current arc rotate camera.
  35907. */
  35908. detach(): void;
  35909. private _animatables;
  35910. private _betaIsAnimating;
  35911. private _betaTransition;
  35912. private _radiusTransition;
  35913. private _vectorTransition;
  35914. /**
  35915. * Targets the given mesh and updates zoom level accordingly.
  35916. * @param mesh The mesh to target.
  35917. * @param radius Optional. If a cached radius position already exists, overrides default.
  35918. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35919. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35920. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35921. */
  35922. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35923. /**
  35924. * Targets the given mesh with its children and updates zoom level accordingly.
  35925. * @param mesh The mesh to target.
  35926. * @param radius Optional. If a cached radius position already exists, overrides default.
  35927. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35928. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35929. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35930. */
  35931. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35932. /**
  35933. * Targets the given meshes with their children and updates zoom level accordingly.
  35934. * @param meshes The mesh to target.
  35935. * @param radius Optional. If a cached radius position already exists, overrides default.
  35936. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35937. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35938. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35939. */
  35940. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35941. /**
  35942. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35943. * @param minimumWorld Determines the smaller position of the bounding box extend
  35944. * @param maximumWorld Determines the bigger position of the bounding box extend
  35945. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35946. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35947. */
  35948. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35949. /**
  35950. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35951. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35952. * frustum width.
  35953. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35954. * to fully enclose the mesh in the viewing frustum.
  35955. */
  35956. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35957. /**
  35958. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35959. * is automatically returned to its default position (expected to be above ground plane).
  35960. */
  35961. private _maintainCameraAboveGround;
  35962. /**
  35963. * Returns the frustum slope based on the canvas ratio and camera FOV
  35964. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35965. */
  35966. private _getFrustumSlope;
  35967. /**
  35968. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35969. */
  35970. private _clearAnimationLocks;
  35971. /**
  35972. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35973. */
  35974. private _applyUserInteraction;
  35975. /**
  35976. * Stops and removes all animations that have been applied to the camera
  35977. */
  35978. stopAllAnimations(): void;
  35979. /**
  35980. * Gets a value indicating if the user is moving the camera
  35981. */
  35982. readonly isUserIsMoving: boolean;
  35983. /**
  35984. * The camera can move all the way towards the mesh.
  35985. */
  35986. static IgnoreBoundsSizeMode: number;
  35987. /**
  35988. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35989. */
  35990. static FitFrustumSidesMode: number;
  35991. }
  35992. }
  35993. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35994. import { Nullable } from "babylonjs/types";
  35995. import { Camera } from "babylonjs/Cameras/camera";
  35996. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35997. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35998. /**
  35999. * Base class for Camera Pointer Inputs.
  36000. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36001. * for example usage.
  36002. */
  36003. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36004. /**
  36005. * Defines the camera the input is attached to.
  36006. */
  36007. abstract camera: Camera;
  36008. /**
  36009. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36010. */
  36011. protected _altKey: boolean;
  36012. protected _ctrlKey: boolean;
  36013. protected _metaKey: boolean;
  36014. protected _shiftKey: boolean;
  36015. /**
  36016. * Which mouse buttons were pressed at time of last mouse event.
  36017. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36018. */
  36019. protected _buttonsPressed: number;
  36020. /**
  36021. * Defines the buttons associated with the input to handle camera move.
  36022. */
  36023. buttons: number[];
  36024. /**
  36025. * Attach the input controls to a specific dom element to get the input from.
  36026. * @param element Defines the element the controls should be listened from
  36027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36028. */
  36029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36030. /**
  36031. * Detach the current controls from the specified dom element.
  36032. * @param element Defines the element to stop listening the inputs from
  36033. */
  36034. detachControl(element: Nullable<HTMLElement>): void;
  36035. /**
  36036. * Gets the class name of the current input.
  36037. * @returns the class name
  36038. */
  36039. getClassName(): string;
  36040. /**
  36041. * Get the friendly name associated with the input class.
  36042. * @returns the input friendly name
  36043. */
  36044. getSimpleName(): string;
  36045. /**
  36046. * Called on pointer POINTERDOUBLETAP event.
  36047. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36048. */
  36049. protected onDoubleTap(type: string): void;
  36050. /**
  36051. * Called on pointer POINTERMOVE event if only a single touch is active.
  36052. * Override this method to provide functionality.
  36053. */
  36054. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36055. /**
  36056. * Called on pointer POINTERMOVE event if multiple touches are active.
  36057. * Override this method to provide functionality.
  36058. */
  36059. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36060. /**
  36061. * Called on JS contextmenu event.
  36062. * Override this method to provide functionality.
  36063. */
  36064. protected onContextMenu(evt: PointerEvent): void;
  36065. /**
  36066. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36067. * press.
  36068. * Override this method to provide functionality.
  36069. */
  36070. protected onButtonDown(evt: PointerEvent): void;
  36071. /**
  36072. * Called each time a new POINTERUP event occurs. Ie, for each button
  36073. * release.
  36074. * Override this method to provide functionality.
  36075. */
  36076. protected onButtonUp(evt: PointerEvent): void;
  36077. /**
  36078. * Called when window becomes inactive.
  36079. * Override this method to provide functionality.
  36080. */
  36081. protected onLostFocus(): void;
  36082. private _pointerInput;
  36083. private _observer;
  36084. private _onLostFocus;
  36085. private pointA;
  36086. private pointB;
  36087. }
  36088. }
  36089. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36090. import { Nullable } from "babylonjs/types";
  36091. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36092. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36093. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36094. /**
  36095. * Manage the pointers inputs to control an arc rotate camera.
  36096. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36097. */
  36098. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36099. /**
  36100. * Defines the camera the input is attached to.
  36101. */
  36102. camera: ArcRotateCamera;
  36103. /**
  36104. * Gets the class name of the current input.
  36105. * @returns the class name
  36106. */
  36107. getClassName(): string;
  36108. /**
  36109. * Defines the buttons associated with the input to handle camera move.
  36110. */
  36111. buttons: number[];
  36112. /**
  36113. * Defines the pointer angular sensibility along the X axis or how fast is
  36114. * the camera rotating.
  36115. */
  36116. angularSensibilityX: number;
  36117. /**
  36118. * Defines the pointer angular sensibility along the Y axis or how fast is
  36119. * the camera rotating.
  36120. */
  36121. angularSensibilityY: number;
  36122. /**
  36123. * Defines the pointer pinch precision or how fast is the camera zooming.
  36124. */
  36125. pinchPrecision: number;
  36126. /**
  36127. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36128. * from 0.
  36129. * It defines the percentage of current camera.radius to use as delta when
  36130. * pinch zoom is used.
  36131. */
  36132. pinchDeltaPercentage: number;
  36133. /**
  36134. * Defines the pointer panning sensibility or how fast is the camera moving.
  36135. */
  36136. panningSensibility: number;
  36137. /**
  36138. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36139. */
  36140. multiTouchPanning: boolean;
  36141. /**
  36142. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36143. * zoom (pinch) through multitouch.
  36144. */
  36145. multiTouchPanAndZoom: boolean;
  36146. /**
  36147. * Revers pinch action direction.
  36148. */
  36149. pinchInwards: boolean;
  36150. private _isPanClick;
  36151. private _twoFingerActivityCount;
  36152. private _isPinching;
  36153. /**
  36154. * Called on pointer POINTERMOVE event if only a single touch is active.
  36155. */
  36156. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36157. /**
  36158. * Called on pointer POINTERDOUBLETAP event.
  36159. */
  36160. protected onDoubleTap(type: string): void;
  36161. /**
  36162. * Called on pointer POINTERMOVE event if multiple touches are active.
  36163. */
  36164. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36165. /**
  36166. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36167. * press.
  36168. */
  36169. protected onButtonDown(evt: PointerEvent): void;
  36170. /**
  36171. * Called each time a new POINTERUP event occurs. Ie, for each button
  36172. * release.
  36173. */
  36174. protected onButtonUp(evt: PointerEvent): void;
  36175. /**
  36176. * Called when window becomes inactive.
  36177. */
  36178. protected onLostFocus(): void;
  36179. }
  36180. }
  36181. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36182. import { Nullable } from "babylonjs/types";
  36183. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36184. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36185. /**
  36186. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36188. */
  36189. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36190. /**
  36191. * Defines the camera the input is attached to.
  36192. */
  36193. camera: ArcRotateCamera;
  36194. /**
  36195. * Defines the list of key codes associated with the up action (increase alpha)
  36196. */
  36197. keysUp: number[];
  36198. /**
  36199. * Defines the list of key codes associated with the down action (decrease alpha)
  36200. */
  36201. keysDown: number[];
  36202. /**
  36203. * Defines the list of key codes associated with the left action (increase beta)
  36204. */
  36205. keysLeft: number[];
  36206. /**
  36207. * Defines the list of key codes associated with the right action (decrease beta)
  36208. */
  36209. keysRight: number[];
  36210. /**
  36211. * Defines the list of key codes associated with the reset action.
  36212. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36213. */
  36214. keysReset: number[];
  36215. /**
  36216. * Defines the panning sensibility of the inputs.
  36217. * (How fast is the camera paning)
  36218. */
  36219. panningSensibility: number;
  36220. /**
  36221. * Defines the zooming sensibility of the inputs.
  36222. * (How fast is the camera zooming)
  36223. */
  36224. zoomingSensibility: number;
  36225. /**
  36226. * Defines wether maintaining the alt key down switch the movement mode from
  36227. * orientation to zoom.
  36228. */
  36229. useAltToZoom: boolean;
  36230. /**
  36231. * Rotation speed of the camera
  36232. */
  36233. angularSpeed: number;
  36234. private _keys;
  36235. private _ctrlPressed;
  36236. private _altPressed;
  36237. private _onCanvasBlurObserver;
  36238. private _onKeyboardObserver;
  36239. private _engine;
  36240. private _scene;
  36241. /**
  36242. * Attach the input controls to a specific dom element to get the input from.
  36243. * @param element Defines the element the controls should be listened from
  36244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36245. */
  36246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36247. /**
  36248. * Detach the current controls from the specified dom element.
  36249. * @param element Defines the element to stop listening the inputs from
  36250. */
  36251. detachControl(element: Nullable<HTMLElement>): void;
  36252. /**
  36253. * Update the current camera state depending on the inputs that have been used this frame.
  36254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36255. */
  36256. checkInputs(): void;
  36257. /**
  36258. * Gets the class name of the current intput.
  36259. * @returns the class name
  36260. */
  36261. getClassName(): string;
  36262. /**
  36263. * Get the friendly name associated with the input class.
  36264. * @returns the input friendly name
  36265. */
  36266. getSimpleName(): string;
  36267. }
  36268. }
  36269. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36270. import { Nullable } from "babylonjs/types";
  36271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36272. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36273. /**
  36274. * Manage the mouse wheel inputs to control an arc rotate camera.
  36275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36276. */
  36277. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36278. /**
  36279. * Defines the camera the input is attached to.
  36280. */
  36281. camera: ArcRotateCamera;
  36282. /**
  36283. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36284. */
  36285. wheelPrecision: number;
  36286. /**
  36287. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36288. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36289. */
  36290. wheelDeltaPercentage: number;
  36291. private _wheel;
  36292. private _observer;
  36293. private computeDeltaFromMouseWheelLegacyEvent;
  36294. /**
  36295. * Attach the input controls to a specific dom element to get the input from.
  36296. * @param element Defines the element the controls should be listened from
  36297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36298. */
  36299. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36300. /**
  36301. * Detach the current controls from the specified dom element.
  36302. * @param element Defines the element to stop listening the inputs from
  36303. */
  36304. detachControl(element: Nullable<HTMLElement>): void;
  36305. /**
  36306. * Gets the class name of the current intput.
  36307. * @returns the class name
  36308. */
  36309. getClassName(): string;
  36310. /**
  36311. * Get the friendly name associated with the input class.
  36312. * @returns the input friendly name
  36313. */
  36314. getSimpleName(): string;
  36315. }
  36316. }
  36317. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36318. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36319. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36320. /**
  36321. * Default Inputs manager for the ArcRotateCamera.
  36322. * It groups all the default supported inputs for ease of use.
  36323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36324. */
  36325. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36326. /**
  36327. * Instantiates a new ArcRotateCameraInputsManager.
  36328. * @param camera Defines the camera the inputs belong to
  36329. */
  36330. constructor(camera: ArcRotateCamera);
  36331. /**
  36332. * Add mouse wheel input support to the input manager.
  36333. * @returns the current input manager
  36334. */
  36335. addMouseWheel(): ArcRotateCameraInputsManager;
  36336. /**
  36337. * Add pointers input support to the input manager.
  36338. * @returns the current input manager
  36339. */
  36340. addPointers(): ArcRotateCameraInputsManager;
  36341. /**
  36342. * Add keyboard input support to the input manager.
  36343. * @returns the current input manager
  36344. */
  36345. addKeyboard(): ArcRotateCameraInputsManager;
  36346. }
  36347. }
  36348. declare module "babylonjs/Cameras/arcRotateCamera" {
  36349. import { Observable } from "babylonjs/Misc/observable";
  36350. import { Nullable } from "babylonjs/types";
  36351. import { Scene } from "babylonjs/scene";
  36352. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36354. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36355. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36356. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36357. import { Camera } from "babylonjs/Cameras/camera";
  36358. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36359. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36360. import { Collider } from "babylonjs/Collisions/collider";
  36361. /**
  36362. * This represents an orbital type of camera.
  36363. *
  36364. * 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.
  36365. * 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.
  36366. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36367. */
  36368. export class ArcRotateCamera extends TargetCamera {
  36369. /**
  36370. * Defines the rotation angle of the camera along the longitudinal axis.
  36371. */
  36372. alpha: number;
  36373. /**
  36374. * Defines the rotation angle of the camera along the latitudinal axis.
  36375. */
  36376. beta: number;
  36377. /**
  36378. * Defines the radius of the camera from it s target point.
  36379. */
  36380. radius: number;
  36381. protected _target: Vector3;
  36382. protected _targetHost: Nullable<AbstractMesh>;
  36383. /**
  36384. * Defines the target point of the camera.
  36385. * The camera looks towards it form the radius distance.
  36386. */
  36387. target: Vector3;
  36388. /**
  36389. * Define the current local position of the camera in the scene
  36390. */
  36391. position: Vector3;
  36392. protected _upVector: Vector3;
  36393. protected _upToYMatrix: Matrix;
  36394. protected _YToUpMatrix: Matrix;
  36395. /**
  36396. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36397. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36398. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36399. */
  36400. upVector: Vector3;
  36401. /**
  36402. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36403. */
  36404. setMatUp(): void;
  36405. /**
  36406. * Current inertia value on the longitudinal axis.
  36407. * The bigger this number the longer it will take for the camera to stop.
  36408. */
  36409. inertialAlphaOffset: number;
  36410. /**
  36411. * Current inertia value on the latitudinal axis.
  36412. * The bigger this number the longer it will take for the camera to stop.
  36413. */
  36414. inertialBetaOffset: number;
  36415. /**
  36416. * Current inertia value on the radius axis.
  36417. * The bigger this number the longer it will take for the camera to stop.
  36418. */
  36419. inertialRadiusOffset: number;
  36420. /**
  36421. * Minimum allowed angle on the longitudinal axis.
  36422. * This can help limiting how the Camera is able to move in the scene.
  36423. */
  36424. lowerAlphaLimit: Nullable<number>;
  36425. /**
  36426. * Maximum allowed angle on the longitudinal axis.
  36427. * This can help limiting how the Camera is able to move in the scene.
  36428. */
  36429. upperAlphaLimit: Nullable<number>;
  36430. /**
  36431. * Minimum allowed angle on the latitudinal axis.
  36432. * This can help limiting how the Camera is able to move in the scene.
  36433. */
  36434. lowerBetaLimit: number;
  36435. /**
  36436. * Maximum allowed angle on the latitudinal axis.
  36437. * This can help limiting how the Camera is able to move in the scene.
  36438. */
  36439. upperBetaLimit: number;
  36440. /**
  36441. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36442. * This can help limiting how the Camera is able to move in the scene.
  36443. */
  36444. lowerRadiusLimit: Nullable<number>;
  36445. /**
  36446. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36447. * This can help limiting how the Camera is able to move in the scene.
  36448. */
  36449. upperRadiusLimit: Nullable<number>;
  36450. /**
  36451. * Defines the current inertia value used during panning of the camera along the X axis.
  36452. */
  36453. inertialPanningX: number;
  36454. /**
  36455. * Defines the current inertia value used during panning of the camera along the Y axis.
  36456. */
  36457. inertialPanningY: number;
  36458. /**
  36459. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36460. * Basically if your fingers moves away from more than this distance you will be considered
  36461. * in pinch mode.
  36462. */
  36463. pinchToPanMaxDistance: number;
  36464. /**
  36465. * Defines the maximum distance the camera can pan.
  36466. * This could help keeping the cammera always in your scene.
  36467. */
  36468. panningDistanceLimit: Nullable<number>;
  36469. /**
  36470. * Defines the target of the camera before paning.
  36471. */
  36472. panningOriginTarget: Vector3;
  36473. /**
  36474. * Defines the value of the inertia used during panning.
  36475. * 0 would mean stop inertia and one would mean no decelleration at all.
  36476. */
  36477. panningInertia: number;
  36478. /**
  36479. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36480. */
  36481. angularSensibilityX: number;
  36482. /**
  36483. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36484. */
  36485. angularSensibilityY: number;
  36486. /**
  36487. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36488. */
  36489. pinchPrecision: number;
  36490. /**
  36491. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36492. * It will be used instead of pinchDeltaPrecision if different from 0.
  36493. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36494. */
  36495. pinchDeltaPercentage: number;
  36496. /**
  36497. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36498. */
  36499. panningSensibility: number;
  36500. /**
  36501. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36502. */
  36503. keysUp: number[];
  36504. /**
  36505. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36506. */
  36507. keysDown: number[];
  36508. /**
  36509. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36510. */
  36511. keysLeft: number[];
  36512. /**
  36513. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36514. */
  36515. keysRight: number[];
  36516. /**
  36517. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36518. */
  36519. wheelPrecision: number;
  36520. /**
  36521. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36522. * It will be used instead of pinchDeltaPrecision if different from 0.
  36523. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36524. */
  36525. wheelDeltaPercentage: number;
  36526. /**
  36527. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36528. */
  36529. zoomOnFactor: number;
  36530. /**
  36531. * Defines a screen offset for the camera position.
  36532. */
  36533. targetScreenOffset: Vector2;
  36534. /**
  36535. * Allows the camera to be completely reversed.
  36536. * If false the camera can not arrive upside down.
  36537. */
  36538. allowUpsideDown: boolean;
  36539. /**
  36540. * Define if double tap/click is used to restore the previously saved state of the camera.
  36541. */
  36542. useInputToRestoreState: boolean;
  36543. /** @hidden */
  36544. _viewMatrix: Matrix;
  36545. /** @hidden */
  36546. _useCtrlForPanning: boolean;
  36547. /** @hidden */
  36548. _panningMouseButton: number;
  36549. /**
  36550. * Defines the input associated to the camera.
  36551. */
  36552. inputs: ArcRotateCameraInputsManager;
  36553. /** @hidden */
  36554. _reset: () => void;
  36555. /**
  36556. * Defines the allowed panning axis.
  36557. */
  36558. panningAxis: Vector3;
  36559. protected _localDirection: Vector3;
  36560. protected _transformedDirection: Vector3;
  36561. private _bouncingBehavior;
  36562. /**
  36563. * Gets the bouncing behavior of the camera if it has been enabled.
  36564. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36565. */
  36566. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36567. /**
  36568. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36569. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36570. */
  36571. useBouncingBehavior: boolean;
  36572. private _framingBehavior;
  36573. /**
  36574. * Gets the framing behavior of the camera if it has been enabled.
  36575. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36576. */
  36577. readonly framingBehavior: Nullable<FramingBehavior>;
  36578. /**
  36579. * Defines if the framing behavior of the camera is enabled on the camera.
  36580. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36581. */
  36582. useFramingBehavior: boolean;
  36583. private _autoRotationBehavior;
  36584. /**
  36585. * Gets the auto rotation behavior of the camera if it has been enabled.
  36586. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36587. */
  36588. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36589. /**
  36590. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36591. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36592. */
  36593. useAutoRotationBehavior: boolean;
  36594. /**
  36595. * Observable triggered when the mesh target has been changed on the camera.
  36596. */
  36597. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36598. /**
  36599. * Event raised when the camera is colliding with a mesh.
  36600. */
  36601. onCollide: (collidedMesh: AbstractMesh) => void;
  36602. /**
  36603. * Defines whether the camera should check collision with the objects oh the scene.
  36604. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36605. */
  36606. checkCollisions: boolean;
  36607. /**
  36608. * Defines the collision radius of the camera.
  36609. * This simulates a sphere around the camera.
  36610. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36611. */
  36612. collisionRadius: Vector3;
  36613. protected _collider: Collider;
  36614. protected _previousPosition: Vector3;
  36615. protected _collisionVelocity: Vector3;
  36616. protected _newPosition: Vector3;
  36617. protected _previousAlpha: number;
  36618. protected _previousBeta: number;
  36619. protected _previousRadius: number;
  36620. protected _collisionTriggered: boolean;
  36621. protected _targetBoundingCenter: Nullable<Vector3>;
  36622. private _computationVector;
  36623. /**
  36624. * Instantiates a new ArcRotateCamera in a given scene
  36625. * @param name Defines the name of the camera
  36626. * @param alpha Defines the camera rotation along the logitudinal axis
  36627. * @param beta Defines the camera rotation along the latitudinal axis
  36628. * @param radius Defines the camera distance from its target
  36629. * @param target Defines the camera target
  36630. * @param scene Defines the scene the camera belongs to
  36631. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36632. */
  36633. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36634. /** @hidden */
  36635. _initCache(): void;
  36636. /** @hidden */
  36637. _updateCache(ignoreParentClass?: boolean): void;
  36638. protected _getTargetPosition(): Vector3;
  36639. private _storedAlpha;
  36640. private _storedBeta;
  36641. private _storedRadius;
  36642. private _storedTarget;
  36643. /**
  36644. * Stores the current state of the camera (alpha, beta, radius and target)
  36645. * @returns the camera itself
  36646. */
  36647. storeState(): Camera;
  36648. /**
  36649. * @hidden
  36650. * Restored camera state. You must call storeState() first
  36651. */
  36652. _restoreStateValues(): boolean;
  36653. /** @hidden */
  36654. _isSynchronizedViewMatrix(): boolean;
  36655. /**
  36656. * Attached controls to the current camera.
  36657. * @param element Defines the element the controls should be listened from
  36658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36659. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36660. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36661. */
  36662. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36663. /**
  36664. * Detach the current controls from the camera.
  36665. * The camera will stop reacting to inputs.
  36666. * @param element Defines the element to stop listening the inputs from
  36667. */
  36668. detachControl(element: HTMLElement): void;
  36669. /** @hidden */
  36670. _checkInputs(): void;
  36671. protected _checkLimits(): void;
  36672. /**
  36673. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36674. */
  36675. rebuildAnglesAndRadius(): void;
  36676. /**
  36677. * Use a position to define the current camera related information like aplha, beta and radius
  36678. * @param position Defines the position to set the camera at
  36679. */
  36680. setPosition(position: Vector3): void;
  36681. /**
  36682. * Defines the target the camera should look at.
  36683. * This will automatically adapt alpha beta and radius to fit within the new target.
  36684. * @param target Defines the new target as a Vector or a mesh
  36685. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36686. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36687. */
  36688. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36689. /** @hidden */
  36690. _getViewMatrix(): Matrix;
  36691. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36692. /**
  36693. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36694. * @param meshes Defines the mesh to zoom on
  36695. * @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)
  36696. */
  36697. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36698. /**
  36699. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36700. * The target will be changed but the radius
  36701. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36702. * @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)
  36703. */
  36704. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36705. min: Vector3;
  36706. max: Vector3;
  36707. distance: number;
  36708. }, doNotUpdateMaxZ?: boolean): void;
  36709. /**
  36710. * @override
  36711. * Override Camera.createRigCamera
  36712. */
  36713. createRigCamera(name: string, cameraIndex: number): Camera;
  36714. /**
  36715. * @hidden
  36716. * @override
  36717. * Override Camera._updateRigCameras
  36718. */
  36719. _updateRigCameras(): void;
  36720. /**
  36721. * Destroy the camera and release the current resources hold by it.
  36722. */
  36723. dispose(): void;
  36724. /**
  36725. * Gets the current object class name.
  36726. * @return the class name
  36727. */
  36728. getClassName(): string;
  36729. }
  36730. }
  36731. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36732. import { Behavior } from "babylonjs/Behaviors/behavior";
  36733. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36734. /**
  36735. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36737. */
  36738. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36739. /**
  36740. * Gets the name of the behavior.
  36741. */
  36742. readonly name: string;
  36743. private _zoomStopsAnimation;
  36744. private _idleRotationSpeed;
  36745. private _idleRotationWaitTime;
  36746. private _idleRotationSpinupTime;
  36747. /**
  36748. * Sets the flag that indicates if user zooming should stop animation.
  36749. */
  36750. /**
  36751. * Gets the flag that indicates if user zooming should stop animation.
  36752. */
  36753. zoomStopsAnimation: boolean;
  36754. /**
  36755. * Sets the default speed at which the camera rotates around the model.
  36756. */
  36757. /**
  36758. * Gets the default speed at which the camera rotates around the model.
  36759. */
  36760. idleRotationSpeed: number;
  36761. /**
  36762. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36763. */
  36764. /**
  36765. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36766. */
  36767. idleRotationWaitTime: number;
  36768. /**
  36769. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36770. */
  36771. /**
  36772. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36773. */
  36774. idleRotationSpinupTime: number;
  36775. /**
  36776. * Gets a value indicating if the camera is currently rotating because of this behavior
  36777. */
  36778. readonly rotationInProgress: boolean;
  36779. private _onPrePointerObservableObserver;
  36780. private _onAfterCheckInputsObserver;
  36781. private _attachedCamera;
  36782. private _isPointerDown;
  36783. private _lastFrameTime;
  36784. private _lastInteractionTime;
  36785. private _cameraRotationSpeed;
  36786. /**
  36787. * Initializes the behavior.
  36788. */
  36789. init(): void;
  36790. /**
  36791. * Attaches the behavior to its arc rotate camera.
  36792. * @param camera Defines the camera to attach the behavior to
  36793. */
  36794. attach(camera: ArcRotateCamera): void;
  36795. /**
  36796. * Detaches the behavior from its current arc rotate camera.
  36797. */
  36798. detach(): void;
  36799. /**
  36800. * Returns true if user is scrolling.
  36801. * @return true if user is scrolling.
  36802. */
  36803. private _userIsZooming;
  36804. private _lastFrameRadius;
  36805. private _shouldAnimationStopForInteraction;
  36806. /**
  36807. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36808. */
  36809. private _applyUserInteraction;
  36810. private _userIsMoving;
  36811. }
  36812. }
  36813. declare module "babylonjs/Behaviors/Cameras/index" {
  36814. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36815. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36816. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36817. }
  36818. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36819. import { Mesh } from "babylonjs/Meshes/mesh";
  36820. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36821. import { Behavior } from "babylonjs/Behaviors/behavior";
  36822. /**
  36823. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36824. */
  36825. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36826. private ui;
  36827. /**
  36828. * The name of the behavior
  36829. */
  36830. name: string;
  36831. /**
  36832. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36833. */
  36834. distanceAwayFromFace: number;
  36835. /**
  36836. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36837. */
  36838. distanceAwayFromBottomOfFace: number;
  36839. private _faceVectors;
  36840. private _target;
  36841. private _scene;
  36842. private _onRenderObserver;
  36843. private _tmpMatrix;
  36844. private _tmpVector;
  36845. /**
  36846. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36847. * @param ui The transform node that should be attched to the mesh
  36848. */
  36849. constructor(ui: TransformNode);
  36850. /**
  36851. * Initializes the behavior
  36852. */
  36853. init(): void;
  36854. private _closestFace;
  36855. private _zeroVector;
  36856. private _lookAtTmpMatrix;
  36857. private _lookAtToRef;
  36858. /**
  36859. * Attaches the AttachToBoxBehavior to the passed in mesh
  36860. * @param target The mesh that the specified node will be attached to
  36861. */
  36862. attach(target: Mesh): void;
  36863. /**
  36864. * Detaches the behavior from the mesh
  36865. */
  36866. detach(): void;
  36867. }
  36868. }
  36869. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36870. import { Behavior } from "babylonjs/Behaviors/behavior";
  36871. import { Mesh } from "babylonjs/Meshes/mesh";
  36872. /**
  36873. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36874. */
  36875. export class FadeInOutBehavior implements Behavior<Mesh> {
  36876. /**
  36877. * Time in milliseconds to delay before fading in (Default: 0)
  36878. */
  36879. delay: number;
  36880. /**
  36881. * Time in milliseconds for the mesh to fade in (Default: 300)
  36882. */
  36883. fadeInTime: number;
  36884. private _millisecondsPerFrame;
  36885. private _hovered;
  36886. private _hoverValue;
  36887. private _ownerNode;
  36888. /**
  36889. * Instatiates the FadeInOutBehavior
  36890. */
  36891. constructor();
  36892. /**
  36893. * The name of the behavior
  36894. */
  36895. readonly name: string;
  36896. /**
  36897. * Initializes the behavior
  36898. */
  36899. init(): void;
  36900. /**
  36901. * Attaches the fade behavior on the passed in mesh
  36902. * @param ownerNode The mesh that will be faded in/out once attached
  36903. */
  36904. attach(ownerNode: Mesh): void;
  36905. /**
  36906. * Detaches the behavior from the mesh
  36907. */
  36908. detach(): void;
  36909. /**
  36910. * Triggers the mesh to begin fading in or out
  36911. * @param value if the object should fade in or out (true to fade in)
  36912. */
  36913. fadeIn(value: boolean): void;
  36914. private _update;
  36915. private _setAllVisibility;
  36916. }
  36917. }
  36918. declare module "babylonjs/Misc/pivotTools" {
  36919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36920. /**
  36921. * Class containing a set of static utilities functions for managing Pivots
  36922. * @hidden
  36923. */
  36924. export class PivotTools {
  36925. private static _PivotCached;
  36926. private static _OldPivotPoint;
  36927. private static _PivotTranslation;
  36928. private static _PivotTmpVector;
  36929. /** @hidden */
  36930. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36931. /** @hidden */
  36932. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36933. }
  36934. }
  36935. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36936. import { Scene } from "babylonjs/scene";
  36937. import { Vector4, Plane } from "babylonjs/Maths/math";
  36938. import { Mesh } from "babylonjs/Meshes/mesh";
  36939. import { Nullable } from "babylonjs/types";
  36940. /**
  36941. * Class containing static functions to help procedurally build meshes
  36942. */
  36943. export class PlaneBuilder {
  36944. /**
  36945. * Creates a plane mesh
  36946. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36947. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36948. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36952. * @param name defines the name of the mesh
  36953. * @param options defines the options used to create the mesh
  36954. * @param scene defines the hosting scene
  36955. * @returns the plane mesh
  36956. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36957. */
  36958. static CreatePlane(name: string, options: {
  36959. size?: number;
  36960. width?: number;
  36961. height?: number;
  36962. sideOrientation?: number;
  36963. frontUVs?: Vector4;
  36964. backUVs?: Vector4;
  36965. updatable?: boolean;
  36966. sourcePlane?: Plane;
  36967. }, scene?: Nullable<Scene>): Mesh;
  36968. }
  36969. }
  36970. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36971. import { Behavior } from "babylonjs/Behaviors/behavior";
  36972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36973. import { Observable } from "babylonjs/Misc/observable";
  36974. import { Vector3 } from "babylonjs/Maths/math";
  36975. import { Ray } from "babylonjs/Culling/ray";
  36976. import "babylonjs/Meshes/Builders/planeBuilder";
  36977. /**
  36978. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36979. */
  36980. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36981. private static _AnyMouseID;
  36982. /**
  36983. * Abstract mesh the behavior is set on
  36984. */
  36985. attachedNode: AbstractMesh;
  36986. private _dragPlane;
  36987. private _scene;
  36988. private _pointerObserver;
  36989. private _beforeRenderObserver;
  36990. private static _planeScene;
  36991. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36992. /**
  36993. * 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)
  36994. */
  36995. maxDragAngle: number;
  36996. /**
  36997. * @hidden
  36998. */
  36999. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37000. /**
  37001. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37002. */
  37003. currentDraggingPointerID: number;
  37004. /**
  37005. * The last position where the pointer hit the drag plane in world space
  37006. */
  37007. lastDragPosition: Vector3;
  37008. /**
  37009. * If the behavior is currently in a dragging state
  37010. */
  37011. dragging: boolean;
  37012. /**
  37013. * 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)
  37014. */
  37015. dragDeltaRatio: number;
  37016. /**
  37017. * If the drag plane orientation should be updated during the dragging (Default: true)
  37018. */
  37019. updateDragPlane: boolean;
  37020. private _debugMode;
  37021. private _moving;
  37022. /**
  37023. * Fires each time the attached mesh is dragged with the pointer
  37024. * * delta between last drag position and current drag position in world space
  37025. * * dragDistance along the drag axis
  37026. * * dragPlaneNormal normal of the current drag plane used during the drag
  37027. * * dragPlanePoint in world space where the drag intersects the drag plane
  37028. */
  37029. onDragObservable: Observable<{
  37030. delta: Vector3;
  37031. dragPlanePoint: Vector3;
  37032. dragPlaneNormal: Vector3;
  37033. dragDistance: number;
  37034. pointerId: number;
  37035. }>;
  37036. /**
  37037. * Fires each time a drag begins (eg. mouse down on mesh)
  37038. */
  37039. onDragStartObservable: Observable<{
  37040. dragPlanePoint: Vector3;
  37041. pointerId: number;
  37042. }>;
  37043. /**
  37044. * Fires each time a drag ends (eg. mouse release after drag)
  37045. */
  37046. onDragEndObservable: Observable<{
  37047. dragPlanePoint: Vector3;
  37048. pointerId: number;
  37049. }>;
  37050. /**
  37051. * If the attached mesh should be moved when dragged
  37052. */
  37053. moveAttached: boolean;
  37054. /**
  37055. * If the drag behavior will react to drag events (Default: true)
  37056. */
  37057. enabled: boolean;
  37058. /**
  37059. * If camera controls should be detached during the drag
  37060. */
  37061. detachCameraControls: boolean;
  37062. /**
  37063. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37064. */
  37065. useObjectOrienationForDragging: boolean;
  37066. private _options;
  37067. /**
  37068. * Creates a pointer drag behavior that can be attached to a mesh
  37069. * @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)
  37070. */
  37071. constructor(options?: {
  37072. dragAxis?: Vector3;
  37073. dragPlaneNormal?: Vector3;
  37074. });
  37075. /**
  37076. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37077. */
  37078. validateDrag: (targetPosition: Vector3) => boolean;
  37079. /**
  37080. * The name of the behavior
  37081. */
  37082. readonly name: string;
  37083. /**
  37084. * Initializes the behavior
  37085. */
  37086. init(): void;
  37087. private _tmpVector;
  37088. private _alternatePickedPoint;
  37089. private _worldDragAxis;
  37090. private _targetPosition;
  37091. private _attachedElement;
  37092. /**
  37093. * Attaches the drag behavior the passed in mesh
  37094. * @param ownerNode The mesh that will be dragged around once attached
  37095. */
  37096. attach(ownerNode: AbstractMesh): void;
  37097. /**
  37098. * Force relase the drag action by code.
  37099. */
  37100. releaseDrag(): void;
  37101. private _startDragRay;
  37102. private _lastPointerRay;
  37103. /**
  37104. * Simulates the start of a pointer drag event on the behavior
  37105. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37106. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37107. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37108. */
  37109. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37110. private _startDrag;
  37111. private _dragDelta;
  37112. private _moveDrag;
  37113. private _pickWithRayOnDragPlane;
  37114. private _pointA;
  37115. private _pointB;
  37116. private _pointC;
  37117. private _lineA;
  37118. private _lineB;
  37119. private _localAxis;
  37120. private _lookAt;
  37121. private _updateDragPlanePosition;
  37122. /**
  37123. * Detaches the behavior from the mesh
  37124. */
  37125. detach(): void;
  37126. }
  37127. }
  37128. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37129. import { Mesh } from "babylonjs/Meshes/mesh";
  37130. import { Behavior } from "babylonjs/Behaviors/behavior";
  37131. /**
  37132. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37133. */
  37134. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37135. private _dragBehaviorA;
  37136. private _dragBehaviorB;
  37137. private _startDistance;
  37138. private _initialScale;
  37139. private _targetScale;
  37140. private _ownerNode;
  37141. private _sceneRenderObserver;
  37142. /**
  37143. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37144. */
  37145. constructor();
  37146. /**
  37147. * The name of the behavior
  37148. */
  37149. readonly name: string;
  37150. /**
  37151. * Initializes the behavior
  37152. */
  37153. init(): void;
  37154. private _getCurrentDistance;
  37155. /**
  37156. * Attaches the scale behavior the passed in mesh
  37157. * @param ownerNode The mesh that will be scaled around once attached
  37158. */
  37159. attach(ownerNode: Mesh): void;
  37160. /**
  37161. * Detaches the behavior from the mesh
  37162. */
  37163. detach(): void;
  37164. }
  37165. }
  37166. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37167. import { Behavior } from "babylonjs/Behaviors/behavior";
  37168. import { Mesh } from "babylonjs/Meshes/mesh";
  37169. import { Observable } from "babylonjs/Misc/observable";
  37170. /**
  37171. * 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
  37172. */
  37173. export class SixDofDragBehavior implements Behavior<Mesh> {
  37174. private static _virtualScene;
  37175. private _ownerNode;
  37176. private _sceneRenderObserver;
  37177. private _scene;
  37178. private _targetPosition;
  37179. private _virtualOriginMesh;
  37180. private _virtualDragMesh;
  37181. private _pointerObserver;
  37182. private _moving;
  37183. private _startingOrientation;
  37184. /**
  37185. * 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)
  37186. */
  37187. private zDragFactor;
  37188. /**
  37189. * If the object should rotate to face the drag origin
  37190. */
  37191. rotateDraggedObject: boolean;
  37192. /**
  37193. * If the behavior is currently in a dragging state
  37194. */
  37195. dragging: boolean;
  37196. /**
  37197. * 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)
  37198. */
  37199. dragDeltaRatio: number;
  37200. /**
  37201. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37202. */
  37203. currentDraggingPointerID: number;
  37204. /**
  37205. * If camera controls should be detached during the drag
  37206. */
  37207. detachCameraControls: boolean;
  37208. /**
  37209. * Fires each time a drag starts
  37210. */
  37211. onDragStartObservable: Observable<{}>;
  37212. /**
  37213. * Fires each time a drag ends (eg. mouse release after drag)
  37214. */
  37215. onDragEndObservable: Observable<{}>;
  37216. /**
  37217. * 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
  37218. */
  37219. constructor();
  37220. /**
  37221. * The name of the behavior
  37222. */
  37223. readonly name: string;
  37224. /**
  37225. * Initializes the behavior
  37226. */
  37227. init(): void;
  37228. /**
  37229. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37230. */
  37231. private readonly _pointerCamera;
  37232. /**
  37233. * Attaches the scale behavior the passed in mesh
  37234. * @param ownerNode The mesh that will be scaled around once attached
  37235. */
  37236. attach(ownerNode: Mesh): void;
  37237. /**
  37238. * Detaches the behavior from the mesh
  37239. */
  37240. detach(): void;
  37241. }
  37242. }
  37243. declare module "babylonjs/Behaviors/Meshes/index" {
  37244. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37245. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37246. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37247. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37248. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37249. }
  37250. declare module "babylonjs/Behaviors/index" {
  37251. export * from "babylonjs/Behaviors/behavior";
  37252. export * from "babylonjs/Behaviors/Cameras/index";
  37253. export * from "babylonjs/Behaviors/Meshes/index";
  37254. }
  37255. declare module "babylonjs/Bones/boneIKController" {
  37256. import { Bone } from "babylonjs/Bones/bone";
  37257. import { Vector3 } from "babylonjs/Maths/math";
  37258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37259. import { Nullable } from "babylonjs/types";
  37260. /**
  37261. * Class used to apply inverse kinematics to bones
  37262. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37263. */
  37264. export class BoneIKController {
  37265. private static _tmpVecs;
  37266. private static _tmpQuat;
  37267. private static _tmpMats;
  37268. /**
  37269. * Gets or sets the target mesh
  37270. */
  37271. targetMesh: AbstractMesh;
  37272. /** Gets or sets the mesh used as pole */
  37273. poleTargetMesh: AbstractMesh;
  37274. /**
  37275. * Gets or sets the bone used as pole
  37276. */
  37277. poleTargetBone: Nullable<Bone>;
  37278. /**
  37279. * Gets or sets the target position
  37280. */
  37281. targetPosition: Vector3;
  37282. /**
  37283. * Gets or sets the pole target position
  37284. */
  37285. poleTargetPosition: Vector3;
  37286. /**
  37287. * Gets or sets the pole target local offset
  37288. */
  37289. poleTargetLocalOffset: Vector3;
  37290. /**
  37291. * Gets or sets the pole angle
  37292. */
  37293. poleAngle: number;
  37294. /**
  37295. * Gets or sets the mesh associated with the controller
  37296. */
  37297. mesh: AbstractMesh;
  37298. /**
  37299. * 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)
  37300. */
  37301. slerpAmount: number;
  37302. private _bone1Quat;
  37303. private _bone1Mat;
  37304. private _bone2Ang;
  37305. private _bone1;
  37306. private _bone2;
  37307. private _bone1Length;
  37308. private _bone2Length;
  37309. private _maxAngle;
  37310. private _maxReach;
  37311. private _rightHandedSystem;
  37312. private _bendAxis;
  37313. private _slerping;
  37314. private _adjustRoll;
  37315. /**
  37316. * Gets or sets maximum allowed angle
  37317. */
  37318. maxAngle: number;
  37319. /**
  37320. * Creates a new BoneIKController
  37321. * @param mesh defines the mesh to control
  37322. * @param bone defines the bone to control
  37323. * @param options defines options to set up the controller
  37324. */
  37325. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37326. targetMesh?: AbstractMesh;
  37327. poleTargetMesh?: AbstractMesh;
  37328. poleTargetBone?: Bone;
  37329. poleTargetLocalOffset?: Vector3;
  37330. poleAngle?: number;
  37331. bendAxis?: Vector3;
  37332. maxAngle?: number;
  37333. slerpAmount?: number;
  37334. });
  37335. private _setMaxAngle;
  37336. /**
  37337. * Force the controller to update the bones
  37338. */
  37339. update(): void;
  37340. }
  37341. }
  37342. declare module "babylonjs/Bones/boneLookController" {
  37343. import { Vector3, Space } from "babylonjs/Maths/math";
  37344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37345. import { Bone } from "babylonjs/Bones/bone";
  37346. /**
  37347. * Class used to make a bone look toward a point in space
  37348. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37349. */
  37350. export class BoneLookController {
  37351. private static _tmpVecs;
  37352. private static _tmpQuat;
  37353. private static _tmpMats;
  37354. /**
  37355. * The target Vector3 that the bone will look at
  37356. */
  37357. target: Vector3;
  37358. /**
  37359. * The mesh that the bone is attached to
  37360. */
  37361. mesh: AbstractMesh;
  37362. /**
  37363. * The bone that will be looking to the target
  37364. */
  37365. bone: Bone;
  37366. /**
  37367. * The up axis of the coordinate system that is used when the bone is rotated
  37368. */
  37369. upAxis: Vector3;
  37370. /**
  37371. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37372. */
  37373. upAxisSpace: Space;
  37374. /**
  37375. * Used to make an adjustment to the yaw of the bone
  37376. */
  37377. adjustYaw: number;
  37378. /**
  37379. * Used to make an adjustment to the pitch of the bone
  37380. */
  37381. adjustPitch: number;
  37382. /**
  37383. * Used to make an adjustment to the roll of the bone
  37384. */
  37385. adjustRoll: number;
  37386. /**
  37387. * 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)
  37388. */
  37389. slerpAmount: number;
  37390. private _minYaw;
  37391. private _maxYaw;
  37392. private _minPitch;
  37393. private _maxPitch;
  37394. private _minYawSin;
  37395. private _minYawCos;
  37396. private _maxYawSin;
  37397. private _maxYawCos;
  37398. private _midYawConstraint;
  37399. private _minPitchTan;
  37400. private _maxPitchTan;
  37401. private _boneQuat;
  37402. private _slerping;
  37403. private _transformYawPitch;
  37404. private _transformYawPitchInv;
  37405. private _firstFrameSkipped;
  37406. private _yawRange;
  37407. private _fowardAxis;
  37408. /**
  37409. * Gets or sets the minimum yaw angle that the bone can look to
  37410. */
  37411. minYaw: number;
  37412. /**
  37413. * Gets or sets the maximum yaw angle that the bone can look to
  37414. */
  37415. maxYaw: number;
  37416. /**
  37417. * Gets or sets the minimum pitch angle that the bone can look to
  37418. */
  37419. minPitch: number;
  37420. /**
  37421. * Gets or sets the maximum pitch angle that the bone can look to
  37422. */
  37423. maxPitch: number;
  37424. /**
  37425. * Create a BoneLookController
  37426. * @param mesh the mesh that the bone belongs to
  37427. * @param bone the bone that will be looking to the target
  37428. * @param target the target Vector3 to look at
  37429. * @param options optional settings:
  37430. * * maxYaw: the maximum angle the bone will yaw to
  37431. * * minYaw: the minimum angle the bone will yaw to
  37432. * * maxPitch: the maximum angle the bone will pitch to
  37433. * * minPitch: the minimum angle the bone will yaw to
  37434. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37435. * * upAxis: the up axis of the coordinate system
  37436. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37437. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37438. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37439. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37440. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37441. * * adjustRoll: used to make an adjustment to the roll of the bone
  37442. **/
  37443. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37444. maxYaw?: number;
  37445. minYaw?: number;
  37446. maxPitch?: number;
  37447. minPitch?: number;
  37448. slerpAmount?: number;
  37449. upAxis?: Vector3;
  37450. upAxisSpace?: Space;
  37451. yawAxis?: Vector3;
  37452. pitchAxis?: Vector3;
  37453. adjustYaw?: number;
  37454. adjustPitch?: number;
  37455. adjustRoll?: number;
  37456. });
  37457. /**
  37458. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37459. */
  37460. update(): void;
  37461. private _getAngleDiff;
  37462. private _getAngleBetween;
  37463. private _isAngleBetween;
  37464. }
  37465. }
  37466. declare module "babylonjs/Bones/index" {
  37467. export * from "babylonjs/Bones/bone";
  37468. export * from "babylonjs/Bones/boneIKController";
  37469. export * from "babylonjs/Bones/boneLookController";
  37470. export * from "babylonjs/Bones/skeleton";
  37471. }
  37472. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37473. import { Nullable } from "babylonjs/types";
  37474. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37475. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37476. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37477. /**
  37478. * Manage the gamepad inputs to control an arc rotate camera.
  37479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37480. */
  37481. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37482. /**
  37483. * Defines the camera the input is attached to.
  37484. */
  37485. camera: ArcRotateCamera;
  37486. /**
  37487. * Defines the gamepad the input is gathering event from.
  37488. */
  37489. gamepad: Nullable<Gamepad>;
  37490. /**
  37491. * Defines the gamepad rotation sensiblity.
  37492. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37493. */
  37494. gamepadRotationSensibility: number;
  37495. /**
  37496. * Defines the gamepad move sensiblity.
  37497. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37498. */
  37499. gamepadMoveSensibility: number;
  37500. private _onGamepadConnectedObserver;
  37501. private _onGamepadDisconnectedObserver;
  37502. /**
  37503. * Attach the input controls to a specific dom element to get the input from.
  37504. * @param element Defines the element the controls should be listened from
  37505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37506. */
  37507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37508. /**
  37509. * Detach the current controls from the specified dom element.
  37510. * @param element Defines the element to stop listening the inputs from
  37511. */
  37512. detachControl(element: Nullable<HTMLElement>): void;
  37513. /**
  37514. * Update the current camera state depending on the inputs that have been used this frame.
  37515. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37516. */
  37517. checkInputs(): void;
  37518. /**
  37519. * Gets the class name of the current intput.
  37520. * @returns the class name
  37521. */
  37522. getClassName(): string;
  37523. /**
  37524. * Get the friendly name associated with the input class.
  37525. * @returns the input friendly name
  37526. */
  37527. getSimpleName(): string;
  37528. }
  37529. }
  37530. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37531. import { Nullable } from "babylonjs/types";
  37532. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37533. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37534. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37535. interface ArcRotateCameraInputsManager {
  37536. /**
  37537. * Add orientation input support to the input manager.
  37538. * @returns the current input manager
  37539. */
  37540. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37541. }
  37542. }
  37543. /**
  37544. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37546. */
  37547. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37548. /**
  37549. * Defines the camera the input is attached to.
  37550. */
  37551. camera: ArcRotateCamera;
  37552. /**
  37553. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37554. */
  37555. alphaCorrection: number;
  37556. /**
  37557. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37558. */
  37559. gammaCorrection: number;
  37560. private _alpha;
  37561. private _gamma;
  37562. private _dirty;
  37563. private _deviceOrientationHandler;
  37564. /**
  37565. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37566. */
  37567. constructor();
  37568. /**
  37569. * Attach the input controls to a specific dom element to get the input from.
  37570. * @param element Defines the element the controls should be listened from
  37571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37572. */
  37573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37574. /** @hidden */
  37575. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37576. /**
  37577. * Update the current camera state depending on the inputs that have been used this frame.
  37578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37579. */
  37580. checkInputs(): void;
  37581. /**
  37582. * Detach the current controls from the specified dom element.
  37583. * @param element Defines the element to stop listening the inputs from
  37584. */
  37585. detachControl(element: Nullable<HTMLElement>): void;
  37586. /**
  37587. * Gets the class name of the current intput.
  37588. * @returns the class name
  37589. */
  37590. getClassName(): string;
  37591. /**
  37592. * Get the friendly name associated with the input class.
  37593. * @returns the input friendly name
  37594. */
  37595. getSimpleName(): string;
  37596. }
  37597. }
  37598. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37599. import { Nullable } from "babylonjs/types";
  37600. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37601. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37602. /**
  37603. * Listen to mouse events to control the camera.
  37604. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37605. */
  37606. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37607. /**
  37608. * Defines the camera the input is attached to.
  37609. */
  37610. camera: FlyCamera;
  37611. /**
  37612. * Defines if touch is enabled. (Default is true.)
  37613. */
  37614. touchEnabled: boolean;
  37615. /**
  37616. * Defines the buttons associated with the input to handle camera rotation.
  37617. */
  37618. buttons: number[];
  37619. /**
  37620. * Assign buttons for Yaw control.
  37621. */
  37622. buttonsYaw: number[];
  37623. /**
  37624. * Assign buttons for Pitch control.
  37625. */
  37626. buttonsPitch: number[];
  37627. /**
  37628. * Assign buttons for Roll control.
  37629. */
  37630. buttonsRoll: number[];
  37631. /**
  37632. * Detect if any button is being pressed while mouse is moved.
  37633. * -1 = Mouse locked.
  37634. * 0 = Left button.
  37635. * 1 = Middle Button.
  37636. * 2 = Right Button.
  37637. */
  37638. activeButton: number;
  37639. /**
  37640. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37641. * Higher values reduce its sensitivity.
  37642. */
  37643. angularSensibility: number;
  37644. private _mousemoveCallback;
  37645. private _observer;
  37646. private _rollObserver;
  37647. private previousPosition;
  37648. private noPreventDefault;
  37649. private element;
  37650. /**
  37651. * Listen to mouse events to control the camera.
  37652. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37654. */
  37655. constructor(touchEnabled?: boolean);
  37656. /**
  37657. * Attach the mouse control to the HTML DOM element.
  37658. * @param element Defines the element that listens to the input events.
  37659. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37660. */
  37661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37662. /**
  37663. * Detach the current controls from the specified dom element.
  37664. * @param element Defines the element to stop listening the inputs from
  37665. */
  37666. detachControl(element: Nullable<HTMLElement>): void;
  37667. /**
  37668. * Gets the class name of the current input.
  37669. * @returns the class name.
  37670. */
  37671. getClassName(): string;
  37672. /**
  37673. * Get the friendly name associated with the input class.
  37674. * @returns the input's friendly name.
  37675. */
  37676. getSimpleName(): string;
  37677. private _pointerInput;
  37678. private _onMouseMove;
  37679. /**
  37680. * Rotate camera by mouse offset.
  37681. */
  37682. private rotateCamera;
  37683. }
  37684. }
  37685. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37686. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37687. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37688. /**
  37689. * Default Inputs manager for the FlyCamera.
  37690. * It groups all the default supported inputs for ease of use.
  37691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37692. */
  37693. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37694. /**
  37695. * Instantiates a new FlyCameraInputsManager.
  37696. * @param camera Defines the camera the inputs belong to.
  37697. */
  37698. constructor(camera: FlyCamera);
  37699. /**
  37700. * Add keyboard input support to the input manager.
  37701. * @returns the new FlyCameraKeyboardMoveInput().
  37702. */
  37703. addKeyboard(): FlyCameraInputsManager;
  37704. /**
  37705. * Add mouse input support to the input manager.
  37706. * @param touchEnabled Enable touch screen support.
  37707. * @returns the new FlyCameraMouseInput().
  37708. */
  37709. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37710. }
  37711. }
  37712. declare module "babylonjs/Cameras/flyCamera" {
  37713. import { Scene } from "babylonjs/scene";
  37714. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37716. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37717. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37718. /**
  37719. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37720. * such as in a 3D Space Shooter or a Flight Simulator.
  37721. */
  37722. export class FlyCamera extends TargetCamera {
  37723. /**
  37724. * Define the collision ellipsoid of the camera.
  37725. * This is helpful for simulating a camera body, like a player's body.
  37726. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37727. */
  37728. ellipsoid: Vector3;
  37729. /**
  37730. * Define an offset for the position of the ellipsoid around the camera.
  37731. * This can be helpful if the camera is attached away from the player's body center,
  37732. * such as at its head.
  37733. */
  37734. ellipsoidOffset: Vector3;
  37735. /**
  37736. * Enable or disable collisions of the camera with the rest of the scene objects.
  37737. */
  37738. checkCollisions: boolean;
  37739. /**
  37740. * Enable or disable gravity on the camera.
  37741. */
  37742. applyGravity: boolean;
  37743. /**
  37744. * Define the current direction the camera is moving to.
  37745. */
  37746. cameraDirection: Vector3;
  37747. /**
  37748. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37749. * This overrides and empties cameraRotation.
  37750. */
  37751. rotationQuaternion: Quaternion;
  37752. /**
  37753. * Track Roll to maintain the wanted Rolling when looking around.
  37754. */
  37755. _trackRoll: number;
  37756. /**
  37757. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37758. */
  37759. rollCorrect: number;
  37760. /**
  37761. * Mimic a banked turn, Rolling the camera when Yawing.
  37762. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37763. */
  37764. bankedTurn: boolean;
  37765. /**
  37766. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37767. */
  37768. bankedTurnLimit: number;
  37769. /**
  37770. * Value of 0 disables the banked Roll.
  37771. * Value of 1 is equal to the Yaw angle in radians.
  37772. */
  37773. bankedTurnMultiplier: number;
  37774. /**
  37775. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37776. */
  37777. inputs: FlyCameraInputsManager;
  37778. /**
  37779. * Gets the input sensibility for mouse input.
  37780. * Higher values reduce sensitivity.
  37781. */
  37782. /**
  37783. * Sets the input sensibility for a mouse input.
  37784. * Higher values reduce sensitivity.
  37785. */
  37786. angularSensibility: number;
  37787. /**
  37788. * Get the keys for camera movement forward.
  37789. */
  37790. /**
  37791. * Set the keys for camera movement forward.
  37792. */
  37793. keysForward: number[];
  37794. /**
  37795. * Get the keys for camera movement backward.
  37796. */
  37797. keysBackward: number[];
  37798. /**
  37799. * Get the keys for camera movement up.
  37800. */
  37801. /**
  37802. * Set the keys for camera movement up.
  37803. */
  37804. keysUp: number[];
  37805. /**
  37806. * Get the keys for camera movement down.
  37807. */
  37808. /**
  37809. * Set the keys for camera movement down.
  37810. */
  37811. keysDown: number[];
  37812. /**
  37813. * Get the keys for camera movement left.
  37814. */
  37815. /**
  37816. * Set the keys for camera movement left.
  37817. */
  37818. keysLeft: number[];
  37819. /**
  37820. * Set the keys for camera movement right.
  37821. */
  37822. /**
  37823. * Set the keys for camera movement right.
  37824. */
  37825. keysRight: number[];
  37826. /**
  37827. * Event raised when the camera collides with a mesh in the scene.
  37828. */
  37829. onCollide: (collidedMesh: AbstractMesh) => void;
  37830. private _collider;
  37831. private _needMoveForGravity;
  37832. private _oldPosition;
  37833. private _diffPosition;
  37834. private _newPosition;
  37835. /** @hidden */
  37836. _localDirection: Vector3;
  37837. /** @hidden */
  37838. _transformedDirection: Vector3;
  37839. /**
  37840. * Instantiates a FlyCamera.
  37841. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37842. * such as in a 3D Space Shooter or a Flight Simulator.
  37843. * @param name Define the name of the camera in the scene.
  37844. * @param position Define the starting position of the camera in the scene.
  37845. * @param scene Define the scene the camera belongs to.
  37846. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37847. */
  37848. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37849. /**
  37850. * Attach a control to the HTML DOM element.
  37851. * @param element Defines the element that listens to the input events.
  37852. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37853. */
  37854. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37855. /**
  37856. * Detach a control from the HTML DOM element.
  37857. * The camera will stop reacting to that input.
  37858. * @param element Defines the element that listens to the input events.
  37859. */
  37860. detachControl(element: HTMLElement): void;
  37861. private _collisionMask;
  37862. /**
  37863. * Get the mask that the camera ignores in collision events.
  37864. */
  37865. /**
  37866. * Set the mask that the camera ignores in collision events.
  37867. */
  37868. collisionMask: number;
  37869. /** @hidden */
  37870. _collideWithWorld(displacement: Vector3): void;
  37871. /** @hidden */
  37872. private _onCollisionPositionChange;
  37873. /** @hidden */
  37874. _checkInputs(): void;
  37875. /** @hidden */
  37876. _decideIfNeedsToMove(): boolean;
  37877. /** @hidden */
  37878. _updatePosition(): void;
  37879. /**
  37880. * Restore the Roll to its target value at the rate specified.
  37881. * @param rate - Higher means slower restoring.
  37882. * @hidden
  37883. */
  37884. restoreRoll(rate: number): void;
  37885. /**
  37886. * Destroy the camera and release the current resources held by it.
  37887. */
  37888. dispose(): void;
  37889. /**
  37890. * Get the current object class name.
  37891. * @returns the class name.
  37892. */
  37893. getClassName(): string;
  37894. }
  37895. }
  37896. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37897. import { Nullable } from "babylonjs/types";
  37898. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37899. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37900. /**
  37901. * Listen to keyboard events to control the camera.
  37902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37903. */
  37904. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37905. /**
  37906. * Defines the camera the input is attached to.
  37907. */
  37908. camera: FlyCamera;
  37909. /**
  37910. * The list of keyboard keys used to control the forward move of the camera.
  37911. */
  37912. keysForward: number[];
  37913. /**
  37914. * The list of keyboard keys used to control the backward move of the camera.
  37915. */
  37916. keysBackward: number[];
  37917. /**
  37918. * The list of keyboard keys used to control the forward move of the camera.
  37919. */
  37920. keysUp: number[];
  37921. /**
  37922. * The list of keyboard keys used to control the backward move of the camera.
  37923. */
  37924. keysDown: number[];
  37925. /**
  37926. * The list of keyboard keys used to control the right strafe move of the camera.
  37927. */
  37928. keysRight: number[];
  37929. /**
  37930. * The list of keyboard keys used to control the left strafe move of the camera.
  37931. */
  37932. keysLeft: number[];
  37933. private _keys;
  37934. private _onCanvasBlurObserver;
  37935. private _onKeyboardObserver;
  37936. private _engine;
  37937. private _scene;
  37938. /**
  37939. * Attach the input controls to a specific dom element to get the input from.
  37940. * @param element Defines the element the controls should be listened from
  37941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37942. */
  37943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37944. /**
  37945. * Detach the current controls from the specified dom element.
  37946. * @param element Defines the element to stop listening the inputs from
  37947. */
  37948. detachControl(element: Nullable<HTMLElement>): void;
  37949. /**
  37950. * Gets the class name of the current intput.
  37951. * @returns the class name
  37952. */
  37953. getClassName(): string;
  37954. /** @hidden */
  37955. _onLostFocus(e: FocusEvent): void;
  37956. /**
  37957. * Get the friendly name associated with the input class.
  37958. * @returns the input friendly name
  37959. */
  37960. getSimpleName(): string;
  37961. /**
  37962. * Update the current camera state depending on the inputs that have been used this frame.
  37963. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37964. */
  37965. checkInputs(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37969. import { Nullable } from "babylonjs/types";
  37970. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37971. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37972. /**
  37973. * Manage the mouse wheel inputs to control a follow camera.
  37974. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37975. */
  37976. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37977. /**
  37978. * Defines the camera the input is attached to.
  37979. */
  37980. camera: FollowCamera;
  37981. /**
  37982. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37983. */
  37984. axisControlRadius: boolean;
  37985. /**
  37986. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37987. */
  37988. axisControlHeight: boolean;
  37989. /**
  37990. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37991. */
  37992. axisControlRotation: boolean;
  37993. /**
  37994. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37995. * relation to mouseWheel events.
  37996. */
  37997. wheelPrecision: number;
  37998. /**
  37999. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38000. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38001. */
  38002. wheelDeltaPercentage: number;
  38003. private _wheel;
  38004. private _observer;
  38005. /**
  38006. * Attach the input controls to a specific dom element to get the input from.
  38007. * @param element Defines the element the controls should be listened from
  38008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38009. */
  38010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38011. /**
  38012. * Detach the current controls from the specified dom element.
  38013. * @param element Defines the element to stop listening the inputs from
  38014. */
  38015. detachControl(element: Nullable<HTMLElement>): void;
  38016. /**
  38017. * Gets the class name of the current intput.
  38018. * @returns the class name
  38019. */
  38020. getClassName(): string;
  38021. /**
  38022. * Get the friendly name associated with the input class.
  38023. * @returns the input friendly name
  38024. */
  38025. getSimpleName(): string;
  38026. }
  38027. }
  38028. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38029. import { Nullable } from "babylonjs/types";
  38030. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38031. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38032. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38033. /**
  38034. * Manage the pointers inputs to control an follow camera.
  38035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38036. */
  38037. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38038. /**
  38039. * Defines the camera the input is attached to.
  38040. */
  38041. camera: FollowCamera;
  38042. /**
  38043. * Gets the class name of the current input.
  38044. * @returns the class name
  38045. */
  38046. getClassName(): string;
  38047. /**
  38048. * Defines the pointer angular sensibility along the X axis or how fast is
  38049. * the camera rotating.
  38050. * A negative number will reverse the axis direction.
  38051. */
  38052. angularSensibilityX: number;
  38053. /**
  38054. * Defines the pointer angular sensibility along the Y axis or how fast is
  38055. * the camera rotating.
  38056. * A negative number will reverse the axis direction.
  38057. */
  38058. angularSensibilityY: number;
  38059. /**
  38060. * Defines the pointer pinch precision or how fast is the camera zooming.
  38061. * A negative number will reverse the axis direction.
  38062. */
  38063. pinchPrecision: number;
  38064. /**
  38065. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38066. * from 0.
  38067. * It defines the percentage of current camera.radius to use as delta when
  38068. * pinch zoom is used.
  38069. */
  38070. pinchDeltaPercentage: number;
  38071. /**
  38072. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38073. */
  38074. axisXControlRadius: boolean;
  38075. /**
  38076. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38077. */
  38078. axisXControlHeight: boolean;
  38079. /**
  38080. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38081. */
  38082. axisXControlRotation: boolean;
  38083. /**
  38084. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38085. */
  38086. axisYControlRadius: boolean;
  38087. /**
  38088. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38089. */
  38090. axisYControlHeight: boolean;
  38091. /**
  38092. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38093. */
  38094. axisYControlRotation: boolean;
  38095. /**
  38096. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38097. */
  38098. axisPinchControlRadius: boolean;
  38099. /**
  38100. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38101. */
  38102. axisPinchControlHeight: boolean;
  38103. /**
  38104. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38105. */
  38106. axisPinchControlRotation: boolean;
  38107. /**
  38108. * Log error messages if basic misconfiguration has occurred.
  38109. */
  38110. warningEnable: boolean;
  38111. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38112. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38113. private _warningCounter;
  38114. private _warning;
  38115. }
  38116. }
  38117. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38118. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38119. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38120. /**
  38121. * Default Inputs manager for the FollowCamera.
  38122. * It groups all the default supported inputs for ease of use.
  38123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38124. */
  38125. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38126. /**
  38127. * Instantiates a new FollowCameraInputsManager.
  38128. * @param camera Defines the camera the inputs belong to
  38129. */
  38130. constructor(camera: FollowCamera);
  38131. /**
  38132. * Add keyboard input support to the input manager.
  38133. * @returns the current input manager
  38134. */
  38135. addKeyboard(): FollowCameraInputsManager;
  38136. /**
  38137. * Add mouse wheel input support to the input manager.
  38138. * @returns the current input manager
  38139. */
  38140. addMouseWheel(): FollowCameraInputsManager;
  38141. /**
  38142. * Add pointers input support to the input manager.
  38143. * @returns the current input manager
  38144. */
  38145. addPointers(): FollowCameraInputsManager;
  38146. /**
  38147. * Add orientation input support to the input manager.
  38148. * @returns the current input manager
  38149. */
  38150. addVRDeviceOrientation(): FollowCameraInputsManager;
  38151. }
  38152. }
  38153. declare module "babylonjs/Cameras/followCamera" {
  38154. import { Nullable } from "babylonjs/types";
  38155. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38156. import { Scene } from "babylonjs/scene";
  38157. import { Vector3 } from "babylonjs/Maths/math";
  38158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38159. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38160. /**
  38161. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38162. * an arc rotate version arcFollowCamera are available.
  38163. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38164. */
  38165. export class FollowCamera extends TargetCamera {
  38166. /**
  38167. * Distance the follow camera should follow an object at
  38168. */
  38169. radius: number;
  38170. /**
  38171. * Minimum allowed distance of the camera to the axis of rotation
  38172. * (The camera can not get closer).
  38173. * This can help limiting how the Camera is able to move in the scene.
  38174. */
  38175. lowerRadiusLimit: Nullable<number>;
  38176. /**
  38177. * Maximum allowed distance of the camera to the axis of rotation
  38178. * (The camera can not get further).
  38179. * This can help limiting how the Camera is able to move in the scene.
  38180. */
  38181. upperRadiusLimit: Nullable<number>;
  38182. /**
  38183. * Define a rotation offset between the camera and the object it follows
  38184. */
  38185. rotationOffset: number;
  38186. /**
  38187. * Minimum allowed angle to camera position relative to target object.
  38188. * This can help limiting how the Camera is able to move in the scene.
  38189. */
  38190. lowerRotationOffsetLimit: Nullable<number>;
  38191. /**
  38192. * Maximum allowed angle to camera position relative to target object.
  38193. * This can help limiting how the Camera is able to move in the scene.
  38194. */
  38195. upperRotationOffsetLimit: Nullable<number>;
  38196. /**
  38197. * Define a height offset between the camera and the object it follows.
  38198. * It can help following an object from the top (like a car chaing a plane)
  38199. */
  38200. heightOffset: number;
  38201. /**
  38202. * Minimum allowed height of camera position relative to target object.
  38203. * This can help limiting how the Camera is able to move in the scene.
  38204. */
  38205. lowerHeightOffsetLimit: Nullable<number>;
  38206. /**
  38207. * Maximum allowed height of camera position relative to target object.
  38208. * This can help limiting how the Camera is able to move in the scene.
  38209. */
  38210. upperHeightOffsetLimit: Nullable<number>;
  38211. /**
  38212. * Define how fast the camera can accelerate to follow it s target.
  38213. */
  38214. cameraAcceleration: number;
  38215. /**
  38216. * Define the speed limit of the camera following an object.
  38217. */
  38218. maxCameraSpeed: number;
  38219. /**
  38220. * Define the target of the camera.
  38221. */
  38222. lockedTarget: Nullable<AbstractMesh>;
  38223. /**
  38224. * Defines the input associated with the camera.
  38225. */
  38226. inputs: FollowCameraInputsManager;
  38227. /**
  38228. * Instantiates the follow camera.
  38229. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38230. * @param name Define the name of the camera in the scene
  38231. * @param position Define the position of the camera
  38232. * @param scene Define the scene the camera belong to
  38233. * @param lockedTarget Define the target of the camera
  38234. */
  38235. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38236. private _follow;
  38237. /**
  38238. * Attached controls to the current camera.
  38239. * @param element Defines the element the controls should be listened from
  38240. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38241. */
  38242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38243. /**
  38244. * Detach the current controls from the camera.
  38245. * The camera will stop reacting to inputs.
  38246. * @param element Defines the element to stop listening the inputs from
  38247. */
  38248. detachControl(element: HTMLElement): void;
  38249. /** @hidden */
  38250. _checkInputs(): void;
  38251. private _checkLimits;
  38252. /**
  38253. * Gets the camera class name.
  38254. * @returns the class name
  38255. */
  38256. getClassName(): string;
  38257. }
  38258. /**
  38259. * Arc Rotate version of the follow camera.
  38260. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38261. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38262. */
  38263. export class ArcFollowCamera extends TargetCamera {
  38264. /** The longitudinal angle of the camera */
  38265. alpha: number;
  38266. /** The latitudinal angle of the camera */
  38267. beta: number;
  38268. /** The radius of the camera from its target */
  38269. radius: number;
  38270. /** Define the camera target (the messh it should follow) */
  38271. target: Nullable<AbstractMesh>;
  38272. private _cartesianCoordinates;
  38273. /**
  38274. * Instantiates a new ArcFollowCamera
  38275. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38276. * @param name Define the name of the camera
  38277. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38278. * @param beta Define the rotation angle of the camera around the elevation axis
  38279. * @param radius Define the radius of the camera from its target point
  38280. * @param target Define the target of the camera
  38281. * @param scene Define the scene the camera belongs to
  38282. */
  38283. constructor(name: string,
  38284. /** The longitudinal angle of the camera */
  38285. alpha: number,
  38286. /** The latitudinal angle of the camera */
  38287. beta: number,
  38288. /** The radius of the camera from its target */
  38289. radius: number,
  38290. /** Define the camera target (the messh it should follow) */
  38291. target: Nullable<AbstractMesh>, scene: Scene);
  38292. private _follow;
  38293. /** @hidden */
  38294. _checkInputs(): void;
  38295. /**
  38296. * Returns the class name of the object.
  38297. * It is mostly used internally for serialization purposes.
  38298. */
  38299. getClassName(): string;
  38300. }
  38301. }
  38302. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38303. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38304. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38305. import { Nullable } from "babylonjs/types";
  38306. /**
  38307. * Manage the keyboard inputs to control the movement of a follow camera.
  38308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38309. */
  38310. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38311. /**
  38312. * Defines the camera the input is attached to.
  38313. */
  38314. camera: FollowCamera;
  38315. /**
  38316. * Defines the list of key codes associated with the up action (increase heightOffset)
  38317. */
  38318. keysHeightOffsetIncr: number[];
  38319. /**
  38320. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38321. */
  38322. keysHeightOffsetDecr: number[];
  38323. /**
  38324. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38325. */
  38326. keysHeightOffsetModifierAlt: boolean;
  38327. /**
  38328. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38329. */
  38330. keysHeightOffsetModifierCtrl: boolean;
  38331. /**
  38332. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38333. */
  38334. keysHeightOffsetModifierShift: boolean;
  38335. /**
  38336. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38337. */
  38338. keysRotationOffsetIncr: number[];
  38339. /**
  38340. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38341. */
  38342. keysRotationOffsetDecr: number[];
  38343. /**
  38344. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38345. */
  38346. keysRotationOffsetModifierAlt: boolean;
  38347. /**
  38348. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38349. */
  38350. keysRotationOffsetModifierCtrl: boolean;
  38351. /**
  38352. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38353. */
  38354. keysRotationOffsetModifierShift: boolean;
  38355. /**
  38356. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38357. */
  38358. keysRadiusIncr: number[];
  38359. /**
  38360. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38361. */
  38362. keysRadiusDecr: number[];
  38363. /**
  38364. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38365. */
  38366. keysRadiusModifierAlt: boolean;
  38367. /**
  38368. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38369. */
  38370. keysRadiusModifierCtrl: boolean;
  38371. /**
  38372. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38373. */
  38374. keysRadiusModifierShift: boolean;
  38375. /**
  38376. * Defines the rate of change of heightOffset.
  38377. */
  38378. heightSensibility: number;
  38379. /**
  38380. * Defines the rate of change of rotationOffset.
  38381. */
  38382. rotationSensibility: number;
  38383. /**
  38384. * Defines the rate of change of radius.
  38385. */
  38386. radiusSensibility: number;
  38387. private _keys;
  38388. private _ctrlPressed;
  38389. private _altPressed;
  38390. private _shiftPressed;
  38391. private _onCanvasBlurObserver;
  38392. private _onKeyboardObserver;
  38393. private _engine;
  38394. private _scene;
  38395. /**
  38396. * Attach the input controls to a specific dom element to get the input from.
  38397. * @param element Defines the element the controls should be listened from
  38398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38399. */
  38400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38401. /**
  38402. * Detach the current controls from the specified dom element.
  38403. * @param element Defines the element to stop listening the inputs from
  38404. */
  38405. detachControl(element: Nullable<HTMLElement>): void;
  38406. /**
  38407. * Update the current camera state depending on the inputs that have been used this frame.
  38408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38409. */
  38410. checkInputs(): void;
  38411. /**
  38412. * Gets the class name of the current input.
  38413. * @returns the class name
  38414. */
  38415. getClassName(): string;
  38416. /**
  38417. * Get the friendly name associated with the input class.
  38418. * @returns the input friendly name
  38419. */
  38420. getSimpleName(): string;
  38421. /**
  38422. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38423. * allow modification of the heightOffset value.
  38424. */
  38425. private _modifierHeightOffset;
  38426. /**
  38427. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38428. * allow modification of the rotationOffset value.
  38429. */
  38430. private _modifierRotationOffset;
  38431. /**
  38432. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38433. * allow modification of the radius value.
  38434. */
  38435. private _modifierRadius;
  38436. }
  38437. }
  38438. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38439. import { Nullable } from "babylonjs/types";
  38440. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38441. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38442. import { Observable } from "babylonjs/Misc/observable";
  38443. module "babylonjs/Cameras/freeCameraInputsManager" {
  38444. interface FreeCameraInputsManager {
  38445. /**
  38446. * @hidden
  38447. */
  38448. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38449. /**
  38450. * Add orientation input support to the input manager.
  38451. * @returns the current input manager
  38452. */
  38453. addDeviceOrientation(): FreeCameraInputsManager;
  38454. }
  38455. }
  38456. /**
  38457. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38458. * Screen rotation is taken into account.
  38459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38460. */
  38461. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38462. private _camera;
  38463. private _screenOrientationAngle;
  38464. private _constantTranform;
  38465. private _screenQuaternion;
  38466. private _alpha;
  38467. private _beta;
  38468. private _gamma;
  38469. /**
  38470. * @hidden
  38471. */
  38472. _onDeviceOrientationChangedObservable: Observable<void>;
  38473. /**
  38474. * Instantiates a new input
  38475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38476. */
  38477. constructor();
  38478. /**
  38479. * Define the camera controlled by the input.
  38480. */
  38481. camera: FreeCamera;
  38482. /**
  38483. * Attach the input controls to a specific dom element to get the input from.
  38484. * @param element Defines the element the controls should be listened from
  38485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38486. */
  38487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38488. private _orientationChanged;
  38489. private _deviceOrientation;
  38490. /**
  38491. * Detach the current controls from the specified dom element.
  38492. * @param element Defines the element to stop listening the inputs from
  38493. */
  38494. detachControl(element: Nullable<HTMLElement>): void;
  38495. /**
  38496. * Update the current camera state depending on the inputs that have been used this frame.
  38497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38498. */
  38499. checkInputs(): void;
  38500. /**
  38501. * Gets the class name of the current intput.
  38502. * @returns the class name
  38503. */
  38504. getClassName(): string;
  38505. /**
  38506. * Get the friendly name associated with the input class.
  38507. * @returns the input friendly name
  38508. */
  38509. getSimpleName(): string;
  38510. }
  38511. }
  38512. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38513. import { Nullable } from "babylonjs/types";
  38514. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38516. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38517. /**
  38518. * Manage the gamepad inputs to control a free camera.
  38519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38520. */
  38521. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38522. /**
  38523. * Define the camera the input is attached to.
  38524. */
  38525. camera: FreeCamera;
  38526. /**
  38527. * Define the Gamepad controlling the input
  38528. */
  38529. gamepad: Nullable<Gamepad>;
  38530. /**
  38531. * Defines the gamepad rotation sensiblity.
  38532. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38533. */
  38534. gamepadAngularSensibility: number;
  38535. /**
  38536. * Defines the gamepad move sensiblity.
  38537. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38538. */
  38539. gamepadMoveSensibility: number;
  38540. private _onGamepadConnectedObserver;
  38541. private _onGamepadDisconnectedObserver;
  38542. private _cameraTransform;
  38543. private _deltaTransform;
  38544. private _vector3;
  38545. private _vector2;
  38546. /**
  38547. * Attach the input controls to a specific dom element to get the input from.
  38548. * @param element Defines the element the controls should be listened from
  38549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38550. */
  38551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38552. /**
  38553. * Detach the current controls from the specified dom element.
  38554. * @param element Defines the element to stop listening the inputs from
  38555. */
  38556. detachControl(element: Nullable<HTMLElement>): void;
  38557. /**
  38558. * Update the current camera state depending on the inputs that have been used this frame.
  38559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38560. */
  38561. checkInputs(): void;
  38562. /**
  38563. * Gets the class name of the current intput.
  38564. * @returns the class name
  38565. */
  38566. getClassName(): string;
  38567. /**
  38568. * Get the friendly name associated with the input class.
  38569. * @returns the input friendly name
  38570. */
  38571. getSimpleName(): string;
  38572. }
  38573. }
  38574. declare module "babylonjs/Misc/virtualJoystick" {
  38575. import { Nullable } from "babylonjs/types";
  38576. import { Vector3 } from "babylonjs/Maths/math";
  38577. /**
  38578. * Defines the potential axis of a Joystick
  38579. */
  38580. export enum JoystickAxis {
  38581. /** X axis */
  38582. X = 0,
  38583. /** Y axis */
  38584. Y = 1,
  38585. /** Z axis */
  38586. Z = 2
  38587. }
  38588. /**
  38589. * Class used to define virtual joystick (used in touch mode)
  38590. */
  38591. export class VirtualJoystick {
  38592. /**
  38593. * Gets or sets a boolean indicating that left and right values must be inverted
  38594. */
  38595. reverseLeftRight: boolean;
  38596. /**
  38597. * Gets or sets a boolean indicating that up and down values must be inverted
  38598. */
  38599. reverseUpDown: boolean;
  38600. /**
  38601. * Gets the offset value for the position (ie. the change of the position value)
  38602. */
  38603. deltaPosition: Vector3;
  38604. /**
  38605. * Gets a boolean indicating if the virtual joystick was pressed
  38606. */
  38607. pressed: boolean;
  38608. /**
  38609. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38610. */
  38611. static Canvas: Nullable<HTMLCanvasElement>;
  38612. private static _globalJoystickIndex;
  38613. private static vjCanvasContext;
  38614. private static vjCanvasWidth;
  38615. private static vjCanvasHeight;
  38616. private static halfWidth;
  38617. private _action;
  38618. private _axisTargetedByLeftAndRight;
  38619. private _axisTargetedByUpAndDown;
  38620. private _joystickSensibility;
  38621. private _inversedSensibility;
  38622. private _joystickPointerID;
  38623. private _joystickColor;
  38624. private _joystickPointerPos;
  38625. private _joystickPreviousPointerPos;
  38626. private _joystickPointerStartPos;
  38627. private _deltaJoystickVector;
  38628. private _leftJoystick;
  38629. private _touches;
  38630. private _onPointerDownHandlerRef;
  38631. private _onPointerMoveHandlerRef;
  38632. private _onPointerUpHandlerRef;
  38633. private _onResize;
  38634. /**
  38635. * Creates a new virtual joystick
  38636. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38637. */
  38638. constructor(leftJoystick?: boolean);
  38639. /**
  38640. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38641. * @param newJoystickSensibility defines the new sensibility
  38642. */
  38643. setJoystickSensibility(newJoystickSensibility: number): void;
  38644. private _onPointerDown;
  38645. private _onPointerMove;
  38646. private _onPointerUp;
  38647. /**
  38648. * Change the color of the virtual joystick
  38649. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38650. */
  38651. setJoystickColor(newColor: string): void;
  38652. /**
  38653. * Defines a callback to call when the joystick is touched
  38654. * @param action defines the callback
  38655. */
  38656. setActionOnTouch(action: () => any): void;
  38657. /**
  38658. * Defines which axis you'd like to control for left & right
  38659. * @param axis defines the axis to use
  38660. */
  38661. setAxisForLeftRight(axis: JoystickAxis): void;
  38662. /**
  38663. * Defines which axis you'd like to control for up & down
  38664. * @param axis defines the axis to use
  38665. */
  38666. setAxisForUpDown(axis: JoystickAxis): void;
  38667. private _drawVirtualJoystick;
  38668. /**
  38669. * Release internal HTML canvas
  38670. */
  38671. releaseCanvas(): void;
  38672. }
  38673. }
  38674. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38675. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38676. import { Nullable } from "babylonjs/types";
  38677. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38678. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38679. module "babylonjs/Cameras/freeCameraInputsManager" {
  38680. interface FreeCameraInputsManager {
  38681. /**
  38682. * Add virtual joystick input support to the input manager.
  38683. * @returns the current input manager
  38684. */
  38685. addVirtualJoystick(): FreeCameraInputsManager;
  38686. }
  38687. }
  38688. /**
  38689. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38693. /**
  38694. * Defines the camera the input is attached to.
  38695. */
  38696. camera: FreeCamera;
  38697. private _leftjoystick;
  38698. private _rightjoystick;
  38699. /**
  38700. * Gets the left stick of the virtual joystick.
  38701. * @returns The virtual Joystick
  38702. */
  38703. getLeftJoystick(): VirtualJoystick;
  38704. /**
  38705. * Gets the right stick of the virtual joystick.
  38706. * @returns The virtual Joystick
  38707. */
  38708. getRightJoystick(): VirtualJoystick;
  38709. /**
  38710. * Update the current camera state depending on the inputs that have been used this frame.
  38711. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38712. */
  38713. checkInputs(): void;
  38714. /**
  38715. * Attach the input controls to a specific dom element to get the input from.
  38716. * @param element Defines the element the controls should be listened from
  38717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38718. */
  38719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38720. /**
  38721. * Detach the current controls from the specified dom element.
  38722. * @param element Defines the element to stop listening the inputs from
  38723. */
  38724. detachControl(element: Nullable<HTMLElement>): void;
  38725. /**
  38726. * Gets the class name of the current intput.
  38727. * @returns the class name
  38728. */
  38729. getClassName(): string;
  38730. /**
  38731. * Get the friendly name associated with the input class.
  38732. * @returns the input friendly name
  38733. */
  38734. getSimpleName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/index" {
  38738. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38739. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38740. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38741. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38742. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38743. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38744. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38745. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38746. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38747. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38748. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38749. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38750. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38751. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38752. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38753. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38754. }
  38755. declare module "babylonjs/Cameras/touchCamera" {
  38756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38757. import { Scene } from "babylonjs/scene";
  38758. import { Vector3 } from "babylonjs/Maths/math";
  38759. /**
  38760. * This represents a FPS type of camera controlled by touch.
  38761. * This is like a universal camera minus the Gamepad controls.
  38762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38763. */
  38764. export class TouchCamera extends FreeCamera {
  38765. /**
  38766. * Defines the touch sensibility for rotation.
  38767. * The higher the faster.
  38768. */
  38769. touchAngularSensibility: number;
  38770. /**
  38771. * Defines the touch sensibility for move.
  38772. * The higher the faster.
  38773. */
  38774. touchMoveSensibility: number;
  38775. /**
  38776. * Instantiates a new touch camera.
  38777. * This represents a FPS type of camera controlled by touch.
  38778. * This is like a universal camera minus the Gamepad controls.
  38779. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38780. * @param name Define the name of the camera in the scene
  38781. * @param position Define the start position of the camera in the scene
  38782. * @param scene Define the scene the camera belongs to
  38783. */
  38784. constructor(name: string, position: Vector3, scene: Scene);
  38785. /**
  38786. * Gets the current object class name.
  38787. * @return the class name
  38788. */
  38789. getClassName(): string;
  38790. /** @hidden */
  38791. _setupInputs(): void;
  38792. }
  38793. }
  38794. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38796. import { Scene } from "babylonjs/scene";
  38797. import { Vector3, Axis } from "babylonjs/Maths/math";
  38798. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38799. /**
  38800. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38801. * being tilted forward or back and left or right.
  38802. */
  38803. export class DeviceOrientationCamera extends FreeCamera {
  38804. private _initialQuaternion;
  38805. private _quaternionCache;
  38806. private _tmpDragQuaternion;
  38807. /**
  38808. * Creates a new device orientation camera
  38809. * @param name The name of the camera
  38810. * @param position The start position camera
  38811. * @param scene The scene the camera belongs to
  38812. */
  38813. constructor(name: string, position: Vector3, scene: Scene);
  38814. /**
  38815. * @hidden
  38816. * Disabled pointer input on first orientation sensor update (Default: true)
  38817. */
  38818. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38819. private _dragFactor;
  38820. /**
  38821. * Enabled turning on the y axis when the orientation sensor is active
  38822. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38823. */
  38824. enableHorizontalDragging(dragFactor?: number): void;
  38825. /**
  38826. * Gets the current instance class name ("DeviceOrientationCamera").
  38827. * This helps avoiding instanceof at run time.
  38828. * @returns the class name
  38829. */
  38830. getClassName(): string;
  38831. /**
  38832. * @hidden
  38833. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38834. */
  38835. _checkInputs(): void;
  38836. /**
  38837. * Reset the camera to its default orientation on the specified axis only.
  38838. * @param axis The axis to reset
  38839. */
  38840. resetToCurrentRotation(axis?: Axis): void;
  38841. }
  38842. }
  38843. declare module "babylonjs/Gamepads/xboxGamepad" {
  38844. import { Observable } from "babylonjs/Misc/observable";
  38845. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38846. /**
  38847. * Defines supported buttons for XBox360 compatible gamepads
  38848. */
  38849. export enum Xbox360Button {
  38850. /** A */
  38851. A = 0,
  38852. /** B */
  38853. B = 1,
  38854. /** X */
  38855. X = 2,
  38856. /** Y */
  38857. Y = 3,
  38858. /** Start */
  38859. Start = 4,
  38860. /** Back */
  38861. Back = 5,
  38862. /** Left button */
  38863. LB = 6,
  38864. /** Right button */
  38865. RB = 7,
  38866. /** Left stick */
  38867. LeftStick = 8,
  38868. /** Right stick */
  38869. RightStick = 9
  38870. }
  38871. /** Defines values for XBox360 DPad */
  38872. export enum Xbox360Dpad {
  38873. /** Up */
  38874. Up = 0,
  38875. /** Down */
  38876. Down = 1,
  38877. /** Left */
  38878. Left = 2,
  38879. /** Right */
  38880. Right = 3
  38881. }
  38882. /**
  38883. * Defines a XBox360 gamepad
  38884. */
  38885. export class Xbox360Pad extends Gamepad {
  38886. private _leftTrigger;
  38887. private _rightTrigger;
  38888. private _onlefttriggerchanged;
  38889. private _onrighttriggerchanged;
  38890. private _onbuttondown;
  38891. private _onbuttonup;
  38892. private _ondpaddown;
  38893. private _ondpadup;
  38894. /** Observable raised when a button is pressed */
  38895. onButtonDownObservable: Observable<Xbox360Button>;
  38896. /** Observable raised when a button is released */
  38897. onButtonUpObservable: Observable<Xbox360Button>;
  38898. /** Observable raised when a pad is pressed */
  38899. onPadDownObservable: Observable<Xbox360Dpad>;
  38900. /** Observable raised when a pad is released */
  38901. onPadUpObservable: Observable<Xbox360Dpad>;
  38902. private _buttonA;
  38903. private _buttonB;
  38904. private _buttonX;
  38905. private _buttonY;
  38906. private _buttonBack;
  38907. private _buttonStart;
  38908. private _buttonLB;
  38909. private _buttonRB;
  38910. private _buttonLeftStick;
  38911. private _buttonRightStick;
  38912. private _dPadUp;
  38913. private _dPadDown;
  38914. private _dPadLeft;
  38915. private _dPadRight;
  38916. private _isXboxOnePad;
  38917. /**
  38918. * Creates a new XBox360 gamepad object
  38919. * @param id defines the id of this gamepad
  38920. * @param index defines its index
  38921. * @param gamepad defines the internal HTML gamepad object
  38922. * @param xboxOne defines if it is a XBox One gamepad
  38923. */
  38924. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38925. /**
  38926. * Defines the callback to call when left trigger is pressed
  38927. * @param callback defines the callback to use
  38928. */
  38929. onlefttriggerchanged(callback: (value: number) => void): void;
  38930. /**
  38931. * Defines the callback to call when right trigger is pressed
  38932. * @param callback defines the callback to use
  38933. */
  38934. onrighttriggerchanged(callback: (value: number) => void): void;
  38935. /**
  38936. * Gets the left trigger value
  38937. */
  38938. /**
  38939. * Sets the left trigger value
  38940. */
  38941. leftTrigger: number;
  38942. /**
  38943. * Gets the right trigger value
  38944. */
  38945. /**
  38946. * Sets the right trigger value
  38947. */
  38948. rightTrigger: number;
  38949. /**
  38950. * Defines the callback to call when a button is pressed
  38951. * @param callback defines the callback to use
  38952. */
  38953. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38954. /**
  38955. * Defines the callback to call when a button is released
  38956. * @param callback defines the callback to use
  38957. */
  38958. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38959. /**
  38960. * Defines the callback to call when a pad is pressed
  38961. * @param callback defines the callback to use
  38962. */
  38963. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38964. /**
  38965. * Defines the callback to call when a pad is released
  38966. * @param callback defines the callback to use
  38967. */
  38968. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38969. private _setButtonValue;
  38970. private _setDPadValue;
  38971. /**
  38972. * Gets the value of the `A` button
  38973. */
  38974. /**
  38975. * Sets the value of the `A` button
  38976. */
  38977. buttonA: number;
  38978. /**
  38979. * Gets the value of the `B` button
  38980. */
  38981. /**
  38982. * Sets the value of the `B` button
  38983. */
  38984. buttonB: number;
  38985. /**
  38986. * Gets the value of the `X` button
  38987. */
  38988. /**
  38989. * Sets the value of the `X` button
  38990. */
  38991. buttonX: number;
  38992. /**
  38993. * Gets the value of the `Y` button
  38994. */
  38995. /**
  38996. * Sets the value of the `Y` button
  38997. */
  38998. buttonY: number;
  38999. /**
  39000. * Gets the value of the `Start` button
  39001. */
  39002. /**
  39003. * Sets the value of the `Start` button
  39004. */
  39005. buttonStart: number;
  39006. /**
  39007. * Gets the value of the `Back` button
  39008. */
  39009. /**
  39010. * Sets the value of the `Back` button
  39011. */
  39012. buttonBack: number;
  39013. /**
  39014. * Gets the value of the `Left` button
  39015. */
  39016. /**
  39017. * Sets the value of the `Left` button
  39018. */
  39019. buttonLB: number;
  39020. /**
  39021. * Gets the value of the `Right` button
  39022. */
  39023. /**
  39024. * Sets the value of the `Right` button
  39025. */
  39026. buttonRB: number;
  39027. /**
  39028. * Gets the value of the Left joystick
  39029. */
  39030. /**
  39031. * Sets the value of the Left joystick
  39032. */
  39033. buttonLeftStick: number;
  39034. /**
  39035. * Gets the value of the Right joystick
  39036. */
  39037. /**
  39038. * Sets the value of the Right joystick
  39039. */
  39040. buttonRightStick: number;
  39041. /**
  39042. * Gets the value of D-pad up
  39043. */
  39044. /**
  39045. * Sets the value of D-pad up
  39046. */
  39047. dPadUp: number;
  39048. /**
  39049. * Gets the value of D-pad down
  39050. */
  39051. /**
  39052. * Sets the value of D-pad down
  39053. */
  39054. dPadDown: number;
  39055. /**
  39056. * Gets the value of D-pad left
  39057. */
  39058. /**
  39059. * Sets the value of D-pad left
  39060. */
  39061. dPadLeft: number;
  39062. /**
  39063. * Gets the value of D-pad right
  39064. */
  39065. /**
  39066. * Sets the value of D-pad right
  39067. */
  39068. dPadRight: number;
  39069. /**
  39070. * Force the gamepad to synchronize with device values
  39071. */
  39072. update(): void;
  39073. /**
  39074. * Disposes the gamepad
  39075. */
  39076. dispose(): void;
  39077. }
  39078. }
  39079. declare module "babylonjs/Gamepads/gamepadManager" {
  39080. import { Observable } from "babylonjs/Misc/observable";
  39081. import { Nullable } from "babylonjs/types";
  39082. import { Scene } from "babylonjs/scene";
  39083. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39084. /**
  39085. * Manager for handling gamepads
  39086. */
  39087. export class GamepadManager {
  39088. private _scene?;
  39089. private _babylonGamepads;
  39090. private _oneGamepadConnected;
  39091. /** @hidden */
  39092. _isMonitoring: boolean;
  39093. private _gamepadEventSupported;
  39094. private _gamepadSupport;
  39095. /**
  39096. * observable to be triggered when the gamepad controller has been connected
  39097. */
  39098. onGamepadConnectedObservable: Observable<Gamepad>;
  39099. /**
  39100. * observable to be triggered when the gamepad controller has been disconnected
  39101. */
  39102. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39103. private _onGamepadConnectedEvent;
  39104. private _onGamepadDisconnectedEvent;
  39105. /**
  39106. * Initializes the gamepad manager
  39107. * @param _scene BabylonJS scene
  39108. */
  39109. constructor(_scene?: Scene | undefined);
  39110. /**
  39111. * The gamepads in the game pad manager
  39112. */
  39113. readonly gamepads: Gamepad[];
  39114. /**
  39115. * Get the gamepad controllers based on type
  39116. * @param type The type of gamepad controller
  39117. * @returns Nullable gamepad
  39118. */
  39119. getGamepadByType(type?: number): Nullable<Gamepad>;
  39120. /**
  39121. * Disposes the gamepad manager
  39122. */
  39123. dispose(): void;
  39124. private _addNewGamepad;
  39125. private _startMonitoringGamepads;
  39126. private _stopMonitoringGamepads;
  39127. /** @hidden */
  39128. _checkGamepadsStatus(): void;
  39129. private _updateGamepadObjects;
  39130. }
  39131. }
  39132. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39133. import { Nullable } from "babylonjs/types";
  39134. import { Scene } from "babylonjs/scene";
  39135. import { ISceneComponent } from "babylonjs/sceneComponent";
  39136. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39137. module "babylonjs/scene" {
  39138. interface Scene {
  39139. /** @hidden */
  39140. _gamepadManager: Nullable<GamepadManager>;
  39141. /**
  39142. * Gets the gamepad manager associated with the scene
  39143. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39144. */
  39145. gamepadManager: GamepadManager;
  39146. }
  39147. }
  39148. module "babylonjs/Cameras/freeCameraInputsManager" {
  39149. /**
  39150. * Interface representing a free camera inputs manager
  39151. */
  39152. interface FreeCameraInputsManager {
  39153. /**
  39154. * Adds gamepad input support to the FreeCameraInputsManager.
  39155. * @returns the FreeCameraInputsManager
  39156. */
  39157. addGamepad(): FreeCameraInputsManager;
  39158. }
  39159. }
  39160. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39161. /**
  39162. * Interface representing an arc rotate camera inputs manager
  39163. */
  39164. interface ArcRotateCameraInputsManager {
  39165. /**
  39166. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39167. * @returns the camera inputs manager
  39168. */
  39169. addGamepad(): ArcRotateCameraInputsManager;
  39170. }
  39171. }
  39172. /**
  39173. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39174. */
  39175. export class GamepadSystemSceneComponent implements ISceneComponent {
  39176. /**
  39177. * The component name helpfull to identify the component in the list of scene components.
  39178. */
  39179. readonly name: string;
  39180. /**
  39181. * The scene the component belongs to.
  39182. */
  39183. scene: Scene;
  39184. /**
  39185. * Creates a new instance of the component for the given scene
  39186. * @param scene Defines the scene to register the component in
  39187. */
  39188. constructor(scene: Scene);
  39189. /**
  39190. * Registers the component in a given scene
  39191. */
  39192. register(): void;
  39193. /**
  39194. * Rebuilds the elements related to this component in case of
  39195. * context lost for instance.
  39196. */
  39197. rebuild(): void;
  39198. /**
  39199. * Disposes the component and the associated ressources
  39200. */
  39201. dispose(): void;
  39202. private _beforeCameraUpdate;
  39203. }
  39204. }
  39205. declare module "babylonjs/Cameras/universalCamera" {
  39206. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39207. import { Scene } from "babylonjs/scene";
  39208. import { Vector3 } from "babylonjs/Maths/math";
  39209. import "babylonjs/Gamepads/gamepadSceneComponent";
  39210. /**
  39211. * 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,
  39212. * which still works and will still be found in many Playgrounds.
  39213. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39214. */
  39215. export class UniversalCamera extends TouchCamera {
  39216. /**
  39217. * Defines the gamepad rotation sensiblity.
  39218. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39219. */
  39220. gamepadAngularSensibility: number;
  39221. /**
  39222. * Defines the gamepad move sensiblity.
  39223. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39224. */
  39225. gamepadMoveSensibility: number;
  39226. /**
  39227. * 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,
  39228. * which still works and will still be found in many Playgrounds.
  39229. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39230. * @param name Define the name of the camera in the scene
  39231. * @param position Define the start position of the camera in the scene
  39232. * @param scene Define the scene the camera belongs to
  39233. */
  39234. constructor(name: string, position: Vector3, scene: Scene);
  39235. /**
  39236. * Gets the current object class name.
  39237. * @return the class name
  39238. */
  39239. getClassName(): string;
  39240. }
  39241. }
  39242. declare module "babylonjs/Cameras/gamepadCamera" {
  39243. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39244. import { Scene } from "babylonjs/scene";
  39245. import { Vector3 } from "babylonjs/Maths/math";
  39246. /**
  39247. * This represents a FPS type of camera. This is only here for back compat purpose.
  39248. * Please use the UniversalCamera instead as both are identical.
  39249. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39250. */
  39251. export class GamepadCamera extends UniversalCamera {
  39252. /**
  39253. * Instantiates a new Gamepad Camera
  39254. * This represents a FPS type of camera. This is only here for back compat purpose.
  39255. * Please use the UniversalCamera instead as both are identical.
  39256. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39257. * @param name Define the name of the camera in the scene
  39258. * @param position Define the start position of the camera in the scene
  39259. * @param scene Define the scene the camera belongs to
  39260. */
  39261. constructor(name: string, position: Vector3, scene: Scene);
  39262. /**
  39263. * Gets the current object class name.
  39264. * @return the class name
  39265. */
  39266. getClassName(): string;
  39267. }
  39268. }
  39269. declare module "babylonjs/Shaders/pass.fragment" {
  39270. /** @hidden */
  39271. export var passPixelShader: {
  39272. name: string;
  39273. shader: string;
  39274. };
  39275. }
  39276. declare module "babylonjs/Shaders/passCube.fragment" {
  39277. /** @hidden */
  39278. export var passCubePixelShader: {
  39279. name: string;
  39280. shader: string;
  39281. };
  39282. }
  39283. declare module "babylonjs/PostProcesses/passPostProcess" {
  39284. import { Nullable } from "babylonjs/types";
  39285. import { Camera } from "babylonjs/Cameras/camera";
  39286. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39287. import { Engine } from "babylonjs/Engines/engine";
  39288. import "babylonjs/Shaders/pass.fragment";
  39289. import "babylonjs/Shaders/passCube.fragment";
  39290. /**
  39291. * PassPostProcess which produces an output the same as it's input
  39292. */
  39293. export class PassPostProcess extends PostProcess {
  39294. /**
  39295. * Creates the PassPostProcess
  39296. * @param name The name of the effect.
  39297. * @param options The required width/height ratio to downsize to before computing the render pass.
  39298. * @param camera The camera to apply the render pass to.
  39299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39300. * @param engine The engine which the post process will be applied. (default: current engine)
  39301. * @param reusable If the post process can be reused on the same frame. (default: false)
  39302. * @param textureType The type of texture to be used when performing the post processing.
  39303. * @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)
  39304. */
  39305. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39306. }
  39307. /**
  39308. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39309. */
  39310. export class PassCubePostProcess extends PostProcess {
  39311. private _face;
  39312. /**
  39313. * Gets or sets the cube face to display.
  39314. * * 0 is +X
  39315. * * 1 is -X
  39316. * * 2 is +Y
  39317. * * 3 is -Y
  39318. * * 4 is +Z
  39319. * * 5 is -Z
  39320. */
  39321. face: number;
  39322. /**
  39323. * Creates the PassCubePostProcess
  39324. * @param name The name of the effect.
  39325. * @param options The required width/height ratio to downsize to before computing the render pass.
  39326. * @param camera The camera to apply the render pass to.
  39327. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39328. * @param engine The engine which the post process will be applied. (default: current engine)
  39329. * @param reusable If the post process can be reused on the same frame. (default: false)
  39330. * @param textureType The type of texture to be used when performing the post processing.
  39331. * @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)
  39332. */
  39333. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39334. }
  39335. }
  39336. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39337. /** @hidden */
  39338. export var anaglyphPixelShader: {
  39339. name: string;
  39340. shader: string;
  39341. };
  39342. }
  39343. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39344. import { Engine } from "babylonjs/Engines/engine";
  39345. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39346. import { Camera } from "babylonjs/Cameras/camera";
  39347. import "babylonjs/Shaders/anaglyph.fragment";
  39348. /**
  39349. * Postprocess used to generate anaglyphic rendering
  39350. */
  39351. export class AnaglyphPostProcess extends PostProcess {
  39352. private _passedProcess;
  39353. /**
  39354. * Creates a new AnaglyphPostProcess
  39355. * @param name defines postprocess name
  39356. * @param options defines creation options or target ratio scale
  39357. * @param rigCameras defines cameras using this postprocess
  39358. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39359. * @param engine defines hosting engine
  39360. * @param reusable defines if the postprocess will be reused multiple times per frame
  39361. */
  39362. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39363. }
  39364. }
  39365. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39366. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39367. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39368. import { Scene } from "babylonjs/scene";
  39369. import { Vector3 } from "babylonjs/Maths/math";
  39370. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39371. /**
  39372. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39373. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39374. */
  39375. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39376. /**
  39377. * Creates a new AnaglyphArcRotateCamera
  39378. * @param name defines camera name
  39379. * @param alpha defines alpha angle (in radians)
  39380. * @param beta defines beta angle (in radians)
  39381. * @param radius defines radius
  39382. * @param target defines camera target
  39383. * @param interaxialDistance defines distance between each color axis
  39384. * @param scene defines the hosting scene
  39385. */
  39386. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39387. /**
  39388. * Gets camera class name
  39389. * @returns AnaglyphArcRotateCamera
  39390. */
  39391. getClassName(): string;
  39392. }
  39393. }
  39394. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39395. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39396. import { Scene } from "babylonjs/scene";
  39397. import { Vector3 } from "babylonjs/Maths/math";
  39398. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39399. /**
  39400. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39401. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39402. */
  39403. export class AnaglyphFreeCamera extends FreeCamera {
  39404. /**
  39405. * Creates a new AnaglyphFreeCamera
  39406. * @param name defines camera name
  39407. * @param position defines initial position
  39408. * @param interaxialDistance defines distance between each color axis
  39409. * @param scene defines the hosting scene
  39410. */
  39411. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39412. /**
  39413. * Gets camera class name
  39414. * @returns AnaglyphFreeCamera
  39415. */
  39416. getClassName(): string;
  39417. }
  39418. }
  39419. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39420. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39421. import { Scene } from "babylonjs/scene";
  39422. import { Vector3 } from "babylonjs/Maths/math";
  39423. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39424. /**
  39425. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39426. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39427. */
  39428. export class AnaglyphGamepadCamera extends GamepadCamera {
  39429. /**
  39430. * Creates a new AnaglyphGamepadCamera
  39431. * @param name defines camera name
  39432. * @param position defines initial position
  39433. * @param interaxialDistance defines distance between each color axis
  39434. * @param scene defines the hosting scene
  39435. */
  39436. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39437. /**
  39438. * Gets camera class name
  39439. * @returns AnaglyphGamepadCamera
  39440. */
  39441. getClassName(): string;
  39442. }
  39443. }
  39444. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39445. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39446. import { Scene } from "babylonjs/scene";
  39447. import { Vector3 } from "babylonjs/Maths/math";
  39448. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39449. /**
  39450. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39452. */
  39453. export class AnaglyphUniversalCamera extends UniversalCamera {
  39454. /**
  39455. * Creates a new AnaglyphUniversalCamera
  39456. * @param name defines camera name
  39457. * @param position defines initial position
  39458. * @param interaxialDistance defines distance between each color axis
  39459. * @param scene defines the hosting scene
  39460. */
  39461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39462. /**
  39463. * Gets camera class name
  39464. * @returns AnaglyphUniversalCamera
  39465. */
  39466. getClassName(): string;
  39467. }
  39468. }
  39469. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39470. /** @hidden */
  39471. export var stereoscopicInterlacePixelShader: {
  39472. name: string;
  39473. shader: string;
  39474. };
  39475. }
  39476. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39477. import { Camera } from "babylonjs/Cameras/camera";
  39478. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39479. import { Engine } from "babylonjs/Engines/engine";
  39480. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39481. /**
  39482. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39483. */
  39484. export class StereoscopicInterlacePostProcess extends PostProcess {
  39485. private _stepSize;
  39486. private _passedProcess;
  39487. /**
  39488. * Initializes a StereoscopicInterlacePostProcess
  39489. * @param name The name of the effect.
  39490. * @param rigCameras The rig cameras to be appled to the post process
  39491. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39492. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39493. * @param engine The engine which the post process will be applied. (default: current engine)
  39494. * @param reusable If the post process can be reused on the same frame. (default: false)
  39495. */
  39496. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39497. }
  39498. }
  39499. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39500. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39501. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39502. import { Scene } from "babylonjs/scene";
  39503. import { Vector3 } from "babylonjs/Maths/math";
  39504. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39505. /**
  39506. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39507. * @see http://doc.babylonjs.com/features/cameras
  39508. */
  39509. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39510. /**
  39511. * Creates a new StereoscopicArcRotateCamera
  39512. * @param name defines camera name
  39513. * @param alpha defines alpha angle (in radians)
  39514. * @param beta defines beta angle (in radians)
  39515. * @param radius defines radius
  39516. * @param target defines camera target
  39517. * @param interaxialDistance defines distance between each color axis
  39518. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39519. * @param scene defines the hosting scene
  39520. */
  39521. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39522. /**
  39523. * Gets camera class name
  39524. * @returns StereoscopicArcRotateCamera
  39525. */
  39526. getClassName(): string;
  39527. }
  39528. }
  39529. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39531. import { Scene } from "babylonjs/scene";
  39532. import { Vector3 } from "babylonjs/Maths/math";
  39533. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39534. /**
  39535. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39536. * @see http://doc.babylonjs.com/features/cameras
  39537. */
  39538. export class StereoscopicFreeCamera extends FreeCamera {
  39539. /**
  39540. * Creates a new StereoscopicFreeCamera
  39541. * @param name defines camera name
  39542. * @param position defines initial position
  39543. * @param interaxialDistance defines distance between each color axis
  39544. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39545. * @param scene defines the hosting scene
  39546. */
  39547. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39548. /**
  39549. * Gets camera class name
  39550. * @returns StereoscopicFreeCamera
  39551. */
  39552. getClassName(): string;
  39553. }
  39554. }
  39555. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39556. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39557. import { Scene } from "babylonjs/scene";
  39558. import { Vector3 } from "babylonjs/Maths/math";
  39559. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39560. /**
  39561. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39562. * @see http://doc.babylonjs.com/features/cameras
  39563. */
  39564. export class StereoscopicGamepadCamera extends GamepadCamera {
  39565. /**
  39566. * Creates a new StereoscopicGamepadCamera
  39567. * @param name defines camera name
  39568. * @param position defines initial position
  39569. * @param interaxialDistance defines distance between each color axis
  39570. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39571. * @param scene defines the hosting scene
  39572. */
  39573. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39574. /**
  39575. * Gets camera class name
  39576. * @returns StereoscopicGamepadCamera
  39577. */
  39578. getClassName(): string;
  39579. }
  39580. }
  39581. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39582. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39583. import { Scene } from "babylonjs/scene";
  39584. import { Vector3 } from "babylonjs/Maths/math";
  39585. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39586. /**
  39587. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39588. * @see http://doc.babylonjs.com/features/cameras
  39589. */
  39590. export class StereoscopicUniversalCamera extends UniversalCamera {
  39591. /**
  39592. * Creates a new StereoscopicUniversalCamera
  39593. * @param name defines camera name
  39594. * @param position defines initial position
  39595. * @param interaxialDistance defines distance between each color axis
  39596. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39597. * @param scene defines the hosting scene
  39598. */
  39599. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39600. /**
  39601. * Gets camera class name
  39602. * @returns StereoscopicUniversalCamera
  39603. */
  39604. getClassName(): string;
  39605. }
  39606. }
  39607. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39608. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39609. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39610. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39611. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39612. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39613. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39614. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39615. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39616. }
  39617. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39618. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39619. import { Scene } from "babylonjs/scene";
  39620. import { Vector3 } from "babylonjs/Maths/math";
  39621. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39622. /**
  39623. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39624. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39625. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39626. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39627. */
  39628. export class VirtualJoysticksCamera extends FreeCamera {
  39629. /**
  39630. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39631. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39632. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39633. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39634. * @param name Define the name of the camera in the scene
  39635. * @param position Define the start position of the camera in the scene
  39636. * @param scene Define the scene the camera belongs to
  39637. */
  39638. constructor(name: string, position: Vector3, scene: Scene);
  39639. /**
  39640. * Gets the current object class name.
  39641. * @return the class name
  39642. */
  39643. getClassName(): string;
  39644. }
  39645. }
  39646. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39647. import { Matrix } from "babylonjs/Maths/math";
  39648. /**
  39649. * This represents all the required metrics to create a VR camera.
  39650. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39651. */
  39652. export class VRCameraMetrics {
  39653. /**
  39654. * Define the horizontal resolution off the screen.
  39655. */
  39656. hResolution: number;
  39657. /**
  39658. * Define the vertical resolution off the screen.
  39659. */
  39660. vResolution: number;
  39661. /**
  39662. * Define the horizontal screen size.
  39663. */
  39664. hScreenSize: number;
  39665. /**
  39666. * Define the vertical screen size.
  39667. */
  39668. vScreenSize: number;
  39669. /**
  39670. * Define the vertical screen center position.
  39671. */
  39672. vScreenCenter: number;
  39673. /**
  39674. * Define the distance of the eyes to the screen.
  39675. */
  39676. eyeToScreenDistance: number;
  39677. /**
  39678. * Define the distance between both lenses
  39679. */
  39680. lensSeparationDistance: number;
  39681. /**
  39682. * Define the distance between both viewer's eyes.
  39683. */
  39684. interpupillaryDistance: number;
  39685. /**
  39686. * Define the distortion factor of the VR postprocess.
  39687. * Please, touch with care.
  39688. */
  39689. distortionK: number[];
  39690. /**
  39691. * Define the chromatic aberration correction factors for the VR post process.
  39692. */
  39693. chromaAbCorrection: number[];
  39694. /**
  39695. * Define the scale factor of the post process.
  39696. * The smaller the better but the slower.
  39697. */
  39698. postProcessScaleFactor: number;
  39699. /**
  39700. * Define an offset for the lens center.
  39701. */
  39702. lensCenterOffset: number;
  39703. /**
  39704. * Define if the current vr camera should compensate the distortion of the lense or not.
  39705. */
  39706. compensateDistortion: boolean;
  39707. /**
  39708. * Defines if multiview should be enabled when rendering (Default: false)
  39709. */
  39710. multiviewEnabled: boolean;
  39711. /**
  39712. * Gets the rendering aspect ratio based on the provided resolutions.
  39713. */
  39714. readonly aspectRatio: number;
  39715. /**
  39716. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39717. */
  39718. readonly aspectRatioFov: number;
  39719. /**
  39720. * @hidden
  39721. */
  39722. readonly leftHMatrix: Matrix;
  39723. /**
  39724. * @hidden
  39725. */
  39726. readonly rightHMatrix: Matrix;
  39727. /**
  39728. * @hidden
  39729. */
  39730. readonly leftPreViewMatrix: Matrix;
  39731. /**
  39732. * @hidden
  39733. */
  39734. readonly rightPreViewMatrix: Matrix;
  39735. /**
  39736. * Get the default VRMetrics based on the most generic setup.
  39737. * @returns the default vr metrics
  39738. */
  39739. static GetDefault(): VRCameraMetrics;
  39740. }
  39741. }
  39742. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39743. /** @hidden */
  39744. export var vrDistortionCorrectionPixelShader: {
  39745. name: string;
  39746. shader: string;
  39747. };
  39748. }
  39749. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39750. import { Camera } from "babylonjs/Cameras/camera";
  39751. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39752. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39753. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39754. /**
  39755. * VRDistortionCorrectionPostProcess used for mobile VR
  39756. */
  39757. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39758. private _isRightEye;
  39759. private _distortionFactors;
  39760. private _postProcessScaleFactor;
  39761. private _lensCenterOffset;
  39762. private _scaleIn;
  39763. private _scaleFactor;
  39764. private _lensCenter;
  39765. /**
  39766. * Initializes the VRDistortionCorrectionPostProcess
  39767. * @param name The name of the effect.
  39768. * @param camera The camera to apply the render pass to.
  39769. * @param isRightEye If this is for the right eye distortion
  39770. * @param vrMetrics All the required metrics for the VR camera
  39771. */
  39772. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39773. }
  39774. }
  39775. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39776. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39777. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39778. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39779. import { Scene } from "babylonjs/scene";
  39780. import { Vector3 } from "babylonjs/Maths/math";
  39781. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39782. import "babylonjs/Cameras/RigModes/vrRigMode";
  39783. /**
  39784. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39785. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39786. */
  39787. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39788. /**
  39789. * Creates a new VRDeviceOrientationArcRotateCamera
  39790. * @param name defines camera name
  39791. * @param alpha defines the camera rotation along the logitudinal axis
  39792. * @param beta defines the camera rotation along the latitudinal axis
  39793. * @param radius defines the camera distance from its target
  39794. * @param target defines the camera target
  39795. * @param scene defines the scene the camera belongs to
  39796. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39797. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39798. */
  39799. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39800. /**
  39801. * Gets camera class name
  39802. * @returns VRDeviceOrientationArcRotateCamera
  39803. */
  39804. getClassName(): string;
  39805. }
  39806. }
  39807. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39808. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39809. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39810. import { Scene } from "babylonjs/scene";
  39811. import { Vector3 } from "babylonjs/Maths/math";
  39812. import "babylonjs/Cameras/RigModes/vrRigMode";
  39813. /**
  39814. * Camera used to simulate VR rendering (based on FreeCamera)
  39815. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39816. */
  39817. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39818. /**
  39819. * Creates a new VRDeviceOrientationFreeCamera
  39820. * @param name defines camera name
  39821. * @param position defines the start position of the camera
  39822. * @param scene defines the scene the camera belongs to
  39823. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39824. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39825. */
  39826. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39827. /**
  39828. * Gets camera class name
  39829. * @returns VRDeviceOrientationFreeCamera
  39830. */
  39831. getClassName(): string;
  39832. }
  39833. }
  39834. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39835. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39836. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39837. import { Scene } from "babylonjs/scene";
  39838. import { Vector3 } from "babylonjs/Maths/math";
  39839. import "babylonjs/Gamepads/gamepadSceneComponent";
  39840. /**
  39841. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39842. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39843. */
  39844. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39845. /**
  39846. * Creates a new VRDeviceOrientationGamepadCamera
  39847. * @param name defines camera name
  39848. * @param position defines the start position of the camera
  39849. * @param scene defines the scene the camera belongs to
  39850. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39851. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39852. */
  39853. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39854. /**
  39855. * Gets camera class name
  39856. * @returns VRDeviceOrientationGamepadCamera
  39857. */
  39858. getClassName(): string;
  39859. }
  39860. }
  39861. declare module "babylonjs/Materials/pushMaterial" {
  39862. import { Nullable } from "babylonjs/types";
  39863. import { Scene } from "babylonjs/scene";
  39864. import { Matrix } from "babylonjs/Maths/math";
  39865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39866. import { Mesh } from "babylonjs/Meshes/mesh";
  39867. import { Material } from "babylonjs/Materials/material";
  39868. import { Effect } from "babylonjs/Materials/effect";
  39869. /**
  39870. * Base class of materials working in push mode in babylon JS
  39871. * @hidden
  39872. */
  39873. export class PushMaterial extends Material {
  39874. protected _activeEffect: Effect;
  39875. protected _normalMatrix: Matrix;
  39876. /**
  39877. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39878. * This means that the material can keep using a previous shader while a new one is being compiled.
  39879. * This is mostly used when shader parallel compilation is supported (true by default)
  39880. */
  39881. allowShaderHotSwapping: boolean;
  39882. constructor(name: string, scene: Scene);
  39883. getEffect(): Effect;
  39884. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39885. /**
  39886. * Binds the given world matrix to the active effect
  39887. *
  39888. * @param world the matrix to bind
  39889. */
  39890. bindOnlyWorldMatrix(world: Matrix): void;
  39891. /**
  39892. * Binds the given normal matrix to the active effect
  39893. *
  39894. * @param normalMatrix the matrix to bind
  39895. */
  39896. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39897. bind(world: Matrix, mesh?: Mesh): void;
  39898. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39899. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39900. }
  39901. }
  39902. declare module "babylonjs/Materials/materialFlags" {
  39903. /**
  39904. * This groups all the flags used to control the materials channel.
  39905. */
  39906. export class MaterialFlags {
  39907. private static _DiffuseTextureEnabled;
  39908. /**
  39909. * Are diffuse textures enabled in the application.
  39910. */
  39911. static DiffuseTextureEnabled: boolean;
  39912. private static _AmbientTextureEnabled;
  39913. /**
  39914. * Are ambient textures enabled in the application.
  39915. */
  39916. static AmbientTextureEnabled: boolean;
  39917. private static _OpacityTextureEnabled;
  39918. /**
  39919. * Are opacity textures enabled in the application.
  39920. */
  39921. static OpacityTextureEnabled: boolean;
  39922. private static _ReflectionTextureEnabled;
  39923. /**
  39924. * Are reflection textures enabled in the application.
  39925. */
  39926. static ReflectionTextureEnabled: boolean;
  39927. private static _EmissiveTextureEnabled;
  39928. /**
  39929. * Are emissive textures enabled in the application.
  39930. */
  39931. static EmissiveTextureEnabled: boolean;
  39932. private static _SpecularTextureEnabled;
  39933. /**
  39934. * Are specular textures enabled in the application.
  39935. */
  39936. static SpecularTextureEnabled: boolean;
  39937. private static _BumpTextureEnabled;
  39938. /**
  39939. * Are bump textures enabled in the application.
  39940. */
  39941. static BumpTextureEnabled: boolean;
  39942. private static _LightmapTextureEnabled;
  39943. /**
  39944. * Are lightmap textures enabled in the application.
  39945. */
  39946. static LightmapTextureEnabled: boolean;
  39947. private static _RefractionTextureEnabled;
  39948. /**
  39949. * Are refraction textures enabled in the application.
  39950. */
  39951. static RefractionTextureEnabled: boolean;
  39952. private static _ColorGradingTextureEnabled;
  39953. /**
  39954. * Are color grading textures enabled in the application.
  39955. */
  39956. static ColorGradingTextureEnabled: boolean;
  39957. private static _FresnelEnabled;
  39958. /**
  39959. * Are fresnels enabled in the application.
  39960. */
  39961. static FresnelEnabled: boolean;
  39962. private static _ClearCoatTextureEnabled;
  39963. /**
  39964. * Are clear coat textures enabled in the application.
  39965. */
  39966. static ClearCoatTextureEnabled: boolean;
  39967. private static _ClearCoatBumpTextureEnabled;
  39968. /**
  39969. * Are clear coat bump textures enabled in the application.
  39970. */
  39971. static ClearCoatBumpTextureEnabled: boolean;
  39972. private static _ClearCoatTintTextureEnabled;
  39973. /**
  39974. * Are clear coat tint textures enabled in the application.
  39975. */
  39976. static ClearCoatTintTextureEnabled: boolean;
  39977. private static _SheenTextureEnabled;
  39978. /**
  39979. * Are sheen textures enabled in the application.
  39980. */
  39981. static SheenTextureEnabled: boolean;
  39982. private static _AnisotropicTextureEnabled;
  39983. /**
  39984. * Are anisotropic textures enabled in the application.
  39985. */
  39986. static AnisotropicTextureEnabled: boolean;
  39987. private static _ThicknessTextureEnabled;
  39988. /**
  39989. * Are thickness textures enabled in the application.
  39990. */
  39991. static ThicknessTextureEnabled: boolean;
  39992. }
  39993. }
  39994. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39995. /** @hidden */
  39996. export var defaultFragmentDeclaration: {
  39997. name: string;
  39998. shader: string;
  39999. };
  40000. }
  40001. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40002. /** @hidden */
  40003. export var defaultUboDeclaration: {
  40004. name: string;
  40005. shader: string;
  40006. };
  40007. }
  40008. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40009. /** @hidden */
  40010. export var lightFragmentDeclaration: {
  40011. name: string;
  40012. shader: string;
  40013. };
  40014. }
  40015. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40016. /** @hidden */
  40017. export var lightUboDeclaration: {
  40018. name: string;
  40019. shader: string;
  40020. };
  40021. }
  40022. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40023. /** @hidden */
  40024. export var lightsFragmentFunctions: {
  40025. name: string;
  40026. shader: string;
  40027. };
  40028. }
  40029. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40030. /** @hidden */
  40031. export var shadowsFragmentFunctions: {
  40032. name: string;
  40033. shader: string;
  40034. };
  40035. }
  40036. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40037. /** @hidden */
  40038. export var fresnelFunction: {
  40039. name: string;
  40040. shader: string;
  40041. };
  40042. }
  40043. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40044. /** @hidden */
  40045. export var reflectionFunction: {
  40046. name: string;
  40047. shader: string;
  40048. };
  40049. }
  40050. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40051. /** @hidden */
  40052. export var bumpFragmentFunctions: {
  40053. name: string;
  40054. shader: string;
  40055. };
  40056. }
  40057. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40058. /** @hidden */
  40059. export var logDepthDeclaration: {
  40060. name: string;
  40061. shader: string;
  40062. };
  40063. }
  40064. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40065. /** @hidden */
  40066. export var bumpFragment: {
  40067. name: string;
  40068. shader: string;
  40069. };
  40070. }
  40071. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40072. /** @hidden */
  40073. export var depthPrePass: {
  40074. name: string;
  40075. shader: string;
  40076. };
  40077. }
  40078. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40079. /** @hidden */
  40080. export var lightFragment: {
  40081. name: string;
  40082. shader: string;
  40083. };
  40084. }
  40085. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40086. /** @hidden */
  40087. export var logDepthFragment: {
  40088. name: string;
  40089. shader: string;
  40090. };
  40091. }
  40092. declare module "babylonjs/Shaders/default.fragment" {
  40093. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40094. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40095. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40096. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40097. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40098. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40099. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40100. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40101. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40102. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40103. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40104. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40105. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40106. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40107. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40108. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40109. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40110. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40111. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40112. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40113. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40114. /** @hidden */
  40115. export var defaultPixelShader: {
  40116. name: string;
  40117. shader: string;
  40118. };
  40119. }
  40120. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40121. /** @hidden */
  40122. export var defaultVertexDeclaration: {
  40123. name: string;
  40124. shader: string;
  40125. };
  40126. }
  40127. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40128. /** @hidden */
  40129. export var bumpVertexDeclaration: {
  40130. name: string;
  40131. shader: string;
  40132. };
  40133. }
  40134. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40135. /** @hidden */
  40136. export var bumpVertex: {
  40137. name: string;
  40138. shader: string;
  40139. };
  40140. }
  40141. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40142. /** @hidden */
  40143. export var fogVertex: {
  40144. name: string;
  40145. shader: string;
  40146. };
  40147. }
  40148. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40149. /** @hidden */
  40150. export var shadowsVertex: {
  40151. name: string;
  40152. shader: string;
  40153. };
  40154. }
  40155. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40156. /** @hidden */
  40157. export var pointCloudVertex: {
  40158. name: string;
  40159. shader: string;
  40160. };
  40161. }
  40162. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40163. /** @hidden */
  40164. export var logDepthVertex: {
  40165. name: string;
  40166. shader: string;
  40167. };
  40168. }
  40169. declare module "babylonjs/Shaders/default.vertex" {
  40170. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40171. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40172. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40173. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40174. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40175. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40176. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40177. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40180. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40181. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40182. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40183. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40184. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40185. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40186. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40187. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40188. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40189. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40190. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40191. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40192. /** @hidden */
  40193. export var defaultVertexShader: {
  40194. name: string;
  40195. shader: string;
  40196. };
  40197. }
  40198. declare module "babylonjs/Materials/standardMaterial" {
  40199. import { SmartArray } from "babylonjs/Misc/smartArray";
  40200. import { IAnimatable } from "babylonjs/Misc/tools";
  40201. import { Nullable } from "babylonjs/types";
  40202. import { Scene } from "babylonjs/scene";
  40203. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40204. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40206. import { Mesh } from "babylonjs/Meshes/mesh";
  40207. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40208. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40209. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40210. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40211. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40213. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40214. import "babylonjs/Shaders/default.fragment";
  40215. import "babylonjs/Shaders/default.vertex";
  40216. /** @hidden */
  40217. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40218. MAINUV1: boolean;
  40219. MAINUV2: boolean;
  40220. DIFFUSE: boolean;
  40221. DIFFUSEDIRECTUV: number;
  40222. AMBIENT: boolean;
  40223. AMBIENTDIRECTUV: number;
  40224. OPACITY: boolean;
  40225. OPACITYDIRECTUV: number;
  40226. OPACITYRGB: boolean;
  40227. REFLECTION: boolean;
  40228. EMISSIVE: boolean;
  40229. EMISSIVEDIRECTUV: number;
  40230. SPECULAR: boolean;
  40231. SPECULARDIRECTUV: number;
  40232. BUMP: boolean;
  40233. BUMPDIRECTUV: number;
  40234. PARALLAX: boolean;
  40235. PARALLAXOCCLUSION: boolean;
  40236. SPECULAROVERALPHA: boolean;
  40237. CLIPPLANE: boolean;
  40238. CLIPPLANE2: boolean;
  40239. CLIPPLANE3: boolean;
  40240. CLIPPLANE4: boolean;
  40241. ALPHATEST: boolean;
  40242. DEPTHPREPASS: boolean;
  40243. ALPHAFROMDIFFUSE: boolean;
  40244. POINTSIZE: boolean;
  40245. FOG: boolean;
  40246. SPECULARTERM: boolean;
  40247. DIFFUSEFRESNEL: boolean;
  40248. OPACITYFRESNEL: boolean;
  40249. REFLECTIONFRESNEL: boolean;
  40250. REFRACTIONFRESNEL: boolean;
  40251. EMISSIVEFRESNEL: boolean;
  40252. FRESNEL: boolean;
  40253. NORMAL: boolean;
  40254. UV1: boolean;
  40255. UV2: boolean;
  40256. VERTEXCOLOR: boolean;
  40257. VERTEXALPHA: boolean;
  40258. NUM_BONE_INFLUENCERS: number;
  40259. BonesPerMesh: number;
  40260. BONETEXTURE: boolean;
  40261. INSTANCES: boolean;
  40262. GLOSSINESS: boolean;
  40263. ROUGHNESS: boolean;
  40264. EMISSIVEASILLUMINATION: boolean;
  40265. LINKEMISSIVEWITHDIFFUSE: boolean;
  40266. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40267. LIGHTMAP: boolean;
  40268. LIGHTMAPDIRECTUV: number;
  40269. OBJECTSPACE_NORMALMAP: boolean;
  40270. USELIGHTMAPASSHADOWMAP: boolean;
  40271. REFLECTIONMAP_3D: boolean;
  40272. REFLECTIONMAP_SPHERICAL: boolean;
  40273. REFLECTIONMAP_PLANAR: boolean;
  40274. REFLECTIONMAP_CUBIC: boolean;
  40275. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40276. REFLECTIONMAP_PROJECTION: boolean;
  40277. REFLECTIONMAP_SKYBOX: boolean;
  40278. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40279. REFLECTIONMAP_EXPLICIT: boolean;
  40280. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40281. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40282. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40283. INVERTCUBICMAP: boolean;
  40284. LOGARITHMICDEPTH: boolean;
  40285. REFRACTION: boolean;
  40286. REFRACTIONMAP_3D: boolean;
  40287. REFLECTIONOVERALPHA: boolean;
  40288. TWOSIDEDLIGHTING: boolean;
  40289. SHADOWFLOAT: boolean;
  40290. MORPHTARGETS: boolean;
  40291. MORPHTARGETS_NORMAL: boolean;
  40292. MORPHTARGETS_TANGENT: boolean;
  40293. NUM_MORPH_INFLUENCERS: number;
  40294. NONUNIFORMSCALING: boolean;
  40295. PREMULTIPLYALPHA: boolean;
  40296. IMAGEPROCESSING: boolean;
  40297. VIGNETTE: boolean;
  40298. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40299. VIGNETTEBLENDMODEOPAQUE: boolean;
  40300. TONEMAPPING: boolean;
  40301. TONEMAPPING_ACES: boolean;
  40302. CONTRAST: boolean;
  40303. COLORCURVES: boolean;
  40304. COLORGRADING: boolean;
  40305. COLORGRADING3D: boolean;
  40306. SAMPLER3DGREENDEPTH: boolean;
  40307. SAMPLER3DBGRMAP: boolean;
  40308. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40309. MULTIVIEW: boolean;
  40310. /**
  40311. * If the reflection texture on this material is in linear color space
  40312. * @hidden
  40313. */
  40314. IS_REFLECTION_LINEAR: boolean;
  40315. /**
  40316. * If the refraction texture on this material is in linear color space
  40317. * @hidden
  40318. */
  40319. IS_REFRACTION_LINEAR: boolean;
  40320. EXPOSURE: boolean;
  40321. constructor();
  40322. setReflectionMode(modeToEnable: string): void;
  40323. }
  40324. /**
  40325. * This is the default material used in Babylon. It is the best trade off between quality
  40326. * and performances.
  40327. * @see http://doc.babylonjs.com/babylon101/materials
  40328. */
  40329. export class StandardMaterial extends PushMaterial {
  40330. private _diffuseTexture;
  40331. /**
  40332. * The basic texture of the material as viewed under a light.
  40333. */
  40334. diffuseTexture: Nullable<BaseTexture>;
  40335. private _ambientTexture;
  40336. /**
  40337. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40338. */
  40339. ambientTexture: Nullable<BaseTexture>;
  40340. private _opacityTexture;
  40341. /**
  40342. * Define the transparency of the material from a texture.
  40343. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40344. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40345. */
  40346. opacityTexture: Nullable<BaseTexture>;
  40347. private _reflectionTexture;
  40348. /**
  40349. * Define the texture used to display the reflection.
  40350. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40351. */
  40352. reflectionTexture: Nullable<BaseTexture>;
  40353. private _emissiveTexture;
  40354. /**
  40355. * Define texture of the material as if self lit.
  40356. * This will be mixed in the final result even in the absence of light.
  40357. */
  40358. emissiveTexture: Nullable<BaseTexture>;
  40359. private _specularTexture;
  40360. /**
  40361. * Define how the color and intensity of the highlight given by the light in the material.
  40362. */
  40363. specularTexture: Nullable<BaseTexture>;
  40364. private _bumpTexture;
  40365. /**
  40366. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40367. * 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.
  40368. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40369. */
  40370. bumpTexture: Nullable<BaseTexture>;
  40371. private _lightmapTexture;
  40372. /**
  40373. * Complex lighting can be computationally expensive to compute at runtime.
  40374. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40375. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40376. */
  40377. lightmapTexture: Nullable<BaseTexture>;
  40378. private _refractionTexture;
  40379. /**
  40380. * Define the texture used to display the refraction.
  40381. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40382. */
  40383. refractionTexture: Nullable<BaseTexture>;
  40384. /**
  40385. * The color of the material lit by the environmental background lighting.
  40386. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40387. */
  40388. ambientColor: Color3;
  40389. /**
  40390. * The basic color of the material as viewed under a light.
  40391. */
  40392. diffuseColor: Color3;
  40393. /**
  40394. * Define how the color and intensity of the highlight given by the light in the material.
  40395. */
  40396. specularColor: Color3;
  40397. /**
  40398. * Define the color of the material as if self lit.
  40399. * This will be mixed in the final result even in the absence of light.
  40400. */
  40401. emissiveColor: Color3;
  40402. /**
  40403. * Defines how sharp are the highlights in the material.
  40404. * The bigger the value the sharper giving a more glossy feeling to the result.
  40405. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40406. */
  40407. specularPower: number;
  40408. private _useAlphaFromDiffuseTexture;
  40409. /**
  40410. * Does the transparency come from the diffuse texture alpha channel.
  40411. */
  40412. useAlphaFromDiffuseTexture: boolean;
  40413. private _useEmissiveAsIllumination;
  40414. /**
  40415. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40416. */
  40417. useEmissiveAsIllumination: boolean;
  40418. private _linkEmissiveWithDiffuse;
  40419. /**
  40420. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40421. * the emissive level when the final color is close to one.
  40422. */
  40423. linkEmissiveWithDiffuse: boolean;
  40424. private _useSpecularOverAlpha;
  40425. /**
  40426. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40427. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40428. */
  40429. useSpecularOverAlpha: boolean;
  40430. private _useReflectionOverAlpha;
  40431. /**
  40432. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40433. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40434. */
  40435. useReflectionOverAlpha: boolean;
  40436. private _disableLighting;
  40437. /**
  40438. * Does lights from the scene impacts this material.
  40439. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40440. */
  40441. disableLighting: boolean;
  40442. private _useObjectSpaceNormalMap;
  40443. /**
  40444. * Allows using an object space normal map (instead of tangent space).
  40445. */
  40446. useObjectSpaceNormalMap: boolean;
  40447. private _useParallax;
  40448. /**
  40449. * Is parallax enabled or not.
  40450. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40451. */
  40452. useParallax: boolean;
  40453. private _useParallaxOcclusion;
  40454. /**
  40455. * Is parallax occlusion enabled or not.
  40456. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40457. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40458. */
  40459. useParallaxOcclusion: boolean;
  40460. /**
  40461. * 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.
  40462. */
  40463. parallaxScaleBias: number;
  40464. private _roughness;
  40465. /**
  40466. * Helps to define how blurry the reflections should appears in the material.
  40467. */
  40468. roughness: number;
  40469. /**
  40470. * In case of refraction, define the value of the indice of refraction.
  40471. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40472. */
  40473. indexOfRefraction: number;
  40474. /**
  40475. * Invert the refraction texture alongside the y axis.
  40476. * It can be useful with procedural textures or probe for instance.
  40477. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40478. */
  40479. invertRefractionY: boolean;
  40480. /**
  40481. * Defines the alpha limits in alpha test mode.
  40482. */
  40483. alphaCutOff: number;
  40484. private _useLightmapAsShadowmap;
  40485. /**
  40486. * In case of light mapping, define whether the map contains light or shadow informations.
  40487. */
  40488. useLightmapAsShadowmap: boolean;
  40489. private _diffuseFresnelParameters;
  40490. /**
  40491. * Define the diffuse fresnel parameters of the material.
  40492. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40493. */
  40494. diffuseFresnelParameters: FresnelParameters;
  40495. private _opacityFresnelParameters;
  40496. /**
  40497. * Define the opacity fresnel parameters of the material.
  40498. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40499. */
  40500. opacityFresnelParameters: FresnelParameters;
  40501. private _reflectionFresnelParameters;
  40502. /**
  40503. * Define the reflection fresnel parameters of the material.
  40504. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40505. */
  40506. reflectionFresnelParameters: FresnelParameters;
  40507. private _refractionFresnelParameters;
  40508. /**
  40509. * Define the refraction fresnel parameters of the material.
  40510. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40511. */
  40512. refractionFresnelParameters: FresnelParameters;
  40513. private _emissiveFresnelParameters;
  40514. /**
  40515. * Define the emissive fresnel parameters of the material.
  40516. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40517. */
  40518. emissiveFresnelParameters: FresnelParameters;
  40519. private _useReflectionFresnelFromSpecular;
  40520. /**
  40521. * If true automatically deducts the fresnels values from the material specularity.
  40522. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40523. */
  40524. useReflectionFresnelFromSpecular: boolean;
  40525. private _useGlossinessFromSpecularMapAlpha;
  40526. /**
  40527. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40528. */
  40529. useGlossinessFromSpecularMapAlpha: boolean;
  40530. private _maxSimultaneousLights;
  40531. /**
  40532. * Defines the maximum number of lights that can be used in the material
  40533. */
  40534. maxSimultaneousLights: number;
  40535. private _invertNormalMapX;
  40536. /**
  40537. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40538. */
  40539. invertNormalMapX: boolean;
  40540. private _invertNormalMapY;
  40541. /**
  40542. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40543. */
  40544. invertNormalMapY: boolean;
  40545. private _twoSidedLighting;
  40546. /**
  40547. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40548. */
  40549. twoSidedLighting: boolean;
  40550. /**
  40551. * Default configuration related to image processing available in the standard Material.
  40552. */
  40553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40554. /**
  40555. * Gets the image processing configuration used either in this material.
  40556. */
  40557. /**
  40558. * Sets the Default image processing configuration used either in the this material.
  40559. *
  40560. * If sets to null, the scene one is in use.
  40561. */
  40562. imageProcessingConfiguration: ImageProcessingConfiguration;
  40563. /**
  40564. * Keep track of the image processing observer to allow dispose and replace.
  40565. */
  40566. private _imageProcessingObserver;
  40567. /**
  40568. * Attaches a new image processing configuration to the Standard Material.
  40569. * @param configuration
  40570. */
  40571. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40572. /**
  40573. * Gets wether the color curves effect is enabled.
  40574. */
  40575. /**
  40576. * Sets wether the color curves effect is enabled.
  40577. */
  40578. cameraColorCurvesEnabled: boolean;
  40579. /**
  40580. * Gets wether the color grading effect is enabled.
  40581. */
  40582. /**
  40583. * Gets wether the color grading effect is enabled.
  40584. */
  40585. cameraColorGradingEnabled: boolean;
  40586. /**
  40587. * Gets wether tonemapping is enabled or not.
  40588. */
  40589. /**
  40590. * Sets wether tonemapping is enabled or not
  40591. */
  40592. cameraToneMappingEnabled: boolean;
  40593. /**
  40594. * The camera exposure used on this material.
  40595. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40596. * This corresponds to a photographic exposure.
  40597. */
  40598. /**
  40599. * The camera exposure used on this material.
  40600. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40601. * This corresponds to a photographic exposure.
  40602. */
  40603. cameraExposure: number;
  40604. /**
  40605. * Gets The camera contrast used on this material.
  40606. */
  40607. /**
  40608. * Sets The camera contrast used on this material.
  40609. */
  40610. cameraContrast: number;
  40611. /**
  40612. * Gets the Color Grading 2D Lookup Texture.
  40613. */
  40614. /**
  40615. * Sets the Color Grading 2D Lookup Texture.
  40616. */
  40617. cameraColorGradingTexture: Nullable<BaseTexture>;
  40618. /**
  40619. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40620. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40621. * 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;
  40622. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40623. */
  40624. /**
  40625. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40626. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40627. * 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;
  40628. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40629. */
  40630. cameraColorCurves: Nullable<ColorCurves>;
  40631. /**
  40632. * Custom callback helping to override the default shader used in the material.
  40633. */
  40634. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40635. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40636. protected _worldViewProjectionMatrix: Matrix;
  40637. protected _globalAmbientColor: Color3;
  40638. protected _useLogarithmicDepth: boolean;
  40639. /**
  40640. * Instantiates a new standard material.
  40641. * This is the default material used in Babylon. It is the best trade off between quality
  40642. * and performances.
  40643. * @see http://doc.babylonjs.com/babylon101/materials
  40644. * @param name Define the name of the material in the scene
  40645. * @param scene Define the scene the material belong to
  40646. */
  40647. constructor(name: string, scene: Scene);
  40648. /**
  40649. * Gets a boolean indicating that current material needs to register RTT
  40650. */
  40651. readonly hasRenderTargetTextures: boolean;
  40652. /**
  40653. * Gets the current class name of the material e.g. "StandardMaterial"
  40654. * Mainly use in serialization.
  40655. * @returns the class name
  40656. */
  40657. getClassName(): string;
  40658. /**
  40659. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40660. * You can try switching to logarithmic depth.
  40661. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40662. */
  40663. useLogarithmicDepth: boolean;
  40664. /**
  40665. * Specifies if the material will require alpha blending
  40666. * @returns a boolean specifying if alpha blending is needed
  40667. */
  40668. needAlphaBlending(): boolean;
  40669. /**
  40670. * Specifies if this material should be rendered in alpha test mode
  40671. * @returns a boolean specifying if an alpha test is needed.
  40672. */
  40673. needAlphaTesting(): boolean;
  40674. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40675. /**
  40676. * Get the texture used for alpha test purpose.
  40677. * @returns the diffuse texture in case of the standard material.
  40678. */
  40679. getAlphaTestTexture(): Nullable<BaseTexture>;
  40680. /**
  40681. * Get if the submesh is ready to be used and all its information available.
  40682. * Child classes can use it to update shaders
  40683. * @param mesh defines the mesh to check
  40684. * @param subMesh defines which submesh to check
  40685. * @param useInstances specifies that instances should be used
  40686. * @returns a boolean indicating that the submesh is ready or not
  40687. */
  40688. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40689. /**
  40690. * Builds the material UBO layouts.
  40691. * Used internally during the effect preparation.
  40692. */
  40693. buildUniformLayout(): void;
  40694. /**
  40695. * Unbinds the material from the mesh
  40696. */
  40697. unbind(): void;
  40698. /**
  40699. * Binds the submesh to this material by preparing the effect and shader to draw
  40700. * @param world defines the world transformation matrix
  40701. * @param mesh defines the mesh containing the submesh
  40702. * @param subMesh defines the submesh to bind the material to
  40703. */
  40704. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40705. /**
  40706. * Get the list of animatables in the material.
  40707. * @returns the list of animatables object used in the material
  40708. */
  40709. getAnimatables(): IAnimatable[];
  40710. /**
  40711. * Gets the active textures from the material
  40712. * @returns an array of textures
  40713. */
  40714. getActiveTextures(): BaseTexture[];
  40715. /**
  40716. * Specifies if the material uses a texture
  40717. * @param texture defines the texture to check against the material
  40718. * @returns a boolean specifying if the material uses the texture
  40719. */
  40720. hasTexture(texture: BaseTexture): boolean;
  40721. /**
  40722. * Disposes the material
  40723. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40724. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40725. */
  40726. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40727. /**
  40728. * Makes a duplicate of the material, and gives it a new name
  40729. * @param name defines the new name for the duplicated material
  40730. * @returns the cloned material
  40731. */
  40732. clone(name: string): StandardMaterial;
  40733. /**
  40734. * Serializes this material in a JSON representation
  40735. * @returns the serialized material object
  40736. */
  40737. serialize(): any;
  40738. /**
  40739. * Creates a standard material from parsed material data
  40740. * @param source defines the JSON representation of the material
  40741. * @param scene defines the hosting scene
  40742. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40743. * @returns a new standard material
  40744. */
  40745. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40746. /**
  40747. * Are diffuse textures enabled in the application.
  40748. */
  40749. static DiffuseTextureEnabled: boolean;
  40750. /**
  40751. * Are ambient textures enabled in the application.
  40752. */
  40753. static AmbientTextureEnabled: boolean;
  40754. /**
  40755. * Are opacity textures enabled in the application.
  40756. */
  40757. static OpacityTextureEnabled: boolean;
  40758. /**
  40759. * Are reflection textures enabled in the application.
  40760. */
  40761. static ReflectionTextureEnabled: boolean;
  40762. /**
  40763. * Are emissive textures enabled in the application.
  40764. */
  40765. static EmissiveTextureEnabled: boolean;
  40766. /**
  40767. * Are specular textures enabled in the application.
  40768. */
  40769. static SpecularTextureEnabled: boolean;
  40770. /**
  40771. * Are bump textures enabled in the application.
  40772. */
  40773. static BumpTextureEnabled: boolean;
  40774. /**
  40775. * Are lightmap textures enabled in the application.
  40776. */
  40777. static LightmapTextureEnabled: boolean;
  40778. /**
  40779. * Are refraction textures enabled in the application.
  40780. */
  40781. static RefractionTextureEnabled: boolean;
  40782. /**
  40783. * Are color grading textures enabled in the application.
  40784. */
  40785. static ColorGradingTextureEnabled: boolean;
  40786. /**
  40787. * Are fresnels enabled in the application.
  40788. */
  40789. static FresnelEnabled: boolean;
  40790. }
  40791. }
  40792. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40793. import { Scene } from "babylonjs/scene";
  40794. import { Texture } from "babylonjs/Materials/Textures/texture";
  40795. /**
  40796. * A class extending Texture allowing drawing on a texture
  40797. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40798. */
  40799. export class DynamicTexture extends Texture {
  40800. private _generateMipMaps;
  40801. private _canvas;
  40802. private _context;
  40803. private _engine;
  40804. /**
  40805. * Creates a DynamicTexture
  40806. * @param name defines the name of the texture
  40807. * @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
  40808. * @param scene defines the scene where you want the texture
  40809. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40810. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40811. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40812. */
  40813. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40814. /**
  40815. * Get the current class name of the texture useful for serialization or dynamic coding.
  40816. * @returns "DynamicTexture"
  40817. */
  40818. getClassName(): string;
  40819. /**
  40820. * Gets the current state of canRescale
  40821. */
  40822. readonly canRescale: boolean;
  40823. private _recreate;
  40824. /**
  40825. * Scales the texture
  40826. * @param ratio the scale factor to apply to both width and height
  40827. */
  40828. scale(ratio: number): void;
  40829. /**
  40830. * Resizes the texture
  40831. * @param width the new width
  40832. * @param height the new height
  40833. */
  40834. scaleTo(width: number, height: number): void;
  40835. /**
  40836. * Gets the context of the canvas used by the texture
  40837. * @returns the canvas context of the dynamic texture
  40838. */
  40839. getContext(): CanvasRenderingContext2D;
  40840. /**
  40841. * Clears the texture
  40842. */
  40843. clear(): void;
  40844. /**
  40845. * Updates the texture
  40846. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40847. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40848. */
  40849. update(invertY?: boolean, premulAlpha?: boolean): void;
  40850. /**
  40851. * Draws text onto the texture
  40852. * @param text defines the text to be drawn
  40853. * @param x defines the placement of the text from the left
  40854. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40855. * @param font defines the font to be used with font-style, font-size, font-name
  40856. * @param color defines the color used for the text
  40857. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40858. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40859. * @param update defines whether texture is immediately update (default is true)
  40860. */
  40861. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40862. /**
  40863. * Clones the texture
  40864. * @returns the clone of the texture.
  40865. */
  40866. clone(): DynamicTexture;
  40867. /**
  40868. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40869. * @returns a serialized dynamic texture object
  40870. */
  40871. serialize(): any;
  40872. /** @hidden */
  40873. _rebuild(): void;
  40874. }
  40875. }
  40876. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40877. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40878. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40879. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40880. /** @hidden */
  40881. export var imageProcessingPixelShader: {
  40882. name: string;
  40883. shader: string;
  40884. };
  40885. }
  40886. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40887. import { Nullable } from "babylonjs/types";
  40888. import { Color4 } from "babylonjs/Maths/math";
  40889. import { Camera } from "babylonjs/Cameras/camera";
  40890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40891. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40892. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40893. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40894. import { Engine } from "babylonjs/Engines/engine";
  40895. import "babylonjs/Shaders/imageProcessing.fragment";
  40896. import "babylonjs/Shaders/postprocess.vertex";
  40897. /**
  40898. * ImageProcessingPostProcess
  40899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40900. */
  40901. export class ImageProcessingPostProcess extends PostProcess {
  40902. /**
  40903. * Default configuration related to image processing available in the PBR Material.
  40904. */
  40905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40906. /**
  40907. * Gets the image processing configuration used either in this material.
  40908. */
  40909. /**
  40910. * Sets the Default image processing configuration used either in the this material.
  40911. *
  40912. * If sets to null, the scene one is in use.
  40913. */
  40914. imageProcessingConfiguration: ImageProcessingConfiguration;
  40915. /**
  40916. * Keep track of the image processing observer to allow dispose and replace.
  40917. */
  40918. private _imageProcessingObserver;
  40919. /**
  40920. * Attaches a new image processing configuration to the PBR Material.
  40921. * @param configuration
  40922. */
  40923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40924. /**
  40925. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40926. */
  40927. /**
  40928. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40929. */
  40930. colorCurves: Nullable<ColorCurves>;
  40931. /**
  40932. * Gets wether the color curves effect is enabled.
  40933. */
  40934. /**
  40935. * Sets wether the color curves effect is enabled.
  40936. */
  40937. colorCurvesEnabled: boolean;
  40938. /**
  40939. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40940. */
  40941. /**
  40942. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40943. */
  40944. colorGradingTexture: Nullable<BaseTexture>;
  40945. /**
  40946. * Gets wether the color grading effect is enabled.
  40947. */
  40948. /**
  40949. * Gets wether the color grading effect is enabled.
  40950. */
  40951. colorGradingEnabled: boolean;
  40952. /**
  40953. * Gets exposure used in the effect.
  40954. */
  40955. /**
  40956. * Sets exposure used in the effect.
  40957. */
  40958. exposure: number;
  40959. /**
  40960. * Gets wether tonemapping is enabled or not.
  40961. */
  40962. /**
  40963. * Sets wether tonemapping is enabled or not
  40964. */
  40965. toneMappingEnabled: boolean;
  40966. /**
  40967. * Gets the type of tone mapping effect.
  40968. */
  40969. /**
  40970. * Sets the type of tone mapping effect.
  40971. */
  40972. toneMappingType: number;
  40973. /**
  40974. * Gets contrast used in the effect.
  40975. */
  40976. /**
  40977. * Sets contrast used in the effect.
  40978. */
  40979. contrast: number;
  40980. /**
  40981. * Gets Vignette stretch size.
  40982. */
  40983. /**
  40984. * Sets Vignette stretch size.
  40985. */
  40986. vignetteStretch: number;
  40987. /**
  40988. * Gets Vignette centre X Offset.
  40989. */
  40990. /**
  40991. * Sets Vignette centre X Offset.
  40992. */
  40993. vignetteCentreX: number;
  40994. /**
  40995. * Gets Vignette centre Y Offset.
  40996. */
  40997. /**
  40998. * Sets Vignette centre Y Offset.
  40999. */
  41000. vignetteCentreY: number;
  41001. /**
  41002. * Gets Vignette weight or intensity of the vignette effect.
  41003. */
  41004. /**
  41005. * Sets Vignette weight or intensity of the vignette effect.
  41006. */
  41007. vignetteWeight: number;
  41008. /**
  41009. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41010. * if vignetteEnabled is set to true.
  41011. */
  41012. /**
  41013. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41014. * if vignetteEnabled is set to true.
  41015. */
  41016. vignetteColor: Color4;
  41017. /**
  41018. * Gets Camera field of view used by the Vignette effect.
  41019. */
  41020. /**
  41021. * Sets Camera field of view used by the Vignette effect.
  41022. */
  41023. vignetteCameraFov: number;
  41024. /**
  41025. * Gets the vignette blend mode allowing different kind of effect.
  41026. */
  41027. /**
  41028. * Sets the vignette blend mode allowing different kind of effect.
  41029. */
  41030. vignetteBlendMode: number;
  41031. /**
  41032. * Gets wether the vignette effect is enabled.
  41033. */
  41034. /**
  41035. * Sets wether the vignette effect is enabled.
  41036. */
  41037. vignetteEnabled: boolean;
  41038. private _fromLinearSpace;
  41039. /**
  41040. * Gets wether the input of the processing is in Gamma or Linear Space.
  41041. */
  41042. /**
  41043. * Sets wether the input of the processing is in Gamma or Linear Space.
  41044. */
  41045. fromLinearSpace: boolean;
  41046. /**
  41047. * Defines cache preventing GC.
  41048. */
  41049. private _defines;
  41050. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41051. /**
  41052. * "ImageProcessingPostProcess"
  41053. * @returns "ImageProcessingPostProcess"
  41054. */
  41055. getClassName(): string;
  41056. protected _updateParameters(): void;
  41057. dispose(camera?: Camera): void;
  41058. }
  41059. }
  41060. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41061. import { Scene } from "babylonjs/scene";
  41062. import { Color3 } from "babylonjs/Maths/math";
  41063. import { Mesh } from "babylonjs/Meshes/mesh";
  41064. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41065. import { Nullable } from "babylonjs/types";
  41066. /**
  41067. * Class containing static functions to help procedurally build meshes
  41068. */
  41069. export class GroundBuilder {
  41070. /**
  41071. * Creates a ground mesh
  41072. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41073. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41075. * @param name defines the name of the mesh
  41076. * @param options defines the options used to create the mesh
  41077. * @param scene defines the hosting scene
  41078. * @returns the ground mesh
  41079. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41080. */
  41081. static CreateGround(name: string, options: {
  41082. width?: number;
  41083. height?: number;
  41084. subdivisions?: number;
  41085. subdivisionsX?: number;
  41086. subdivisionsY?: number;
  41087. updatable?: boolean;
  41088. }, scene: any): Mesh;
  41089. /**
  41090. * Creates a tiled ground mesh
  41091. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41092. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41093. * * 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
  41094. * * 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
  41095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41096. * @param name defines the name of the mesh
  41097. * @param options defines the options used to create the mesh
  41098. * @param scene defines the hosting scene
  41099. * @returns the tiled ground mesh
  41100. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41101. */
  41102. static CreateTiledGround(name: string, options: {
  41103. xmin: number;
  41104. zmin: number;
  41105. xmax: number;
  41106. zmax: number;
  41107. subdivisions?: {
  41108. w: number;
  41109. h: number;
  41110. };
  41111. precision?: {
  41112. w: number;
  41113. h: number;
  41114. };
  41115. updatable?: boolean;
  41116. }, scene?: Nullable<Scene>): Mesh;
  41117. /**
  41118. * Creates a ground mesh from a height map
  41119. * * The parameter `url` sets the URL of the height map image resource.
  41120. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41121. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41122. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41123. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41124. * * 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.
  41125. * * 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).
  41126. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41128. * @param name defines the name of the mesh
  41129. * @param url defines the url to the height map
  41130. * @param options defines the options used to create the mesh
  41131. * @param scene defines the hosting scene
  41132. * @returns the ground mesh
  41133. * @see https://doc.babylonjs.com/babylon101/height_map
  41134. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41135. */
  41136. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41137. width?: number;
  41138. height?: number;
  41139. subdivisions?: number;
  41140. minHeight?: number;
  41141. maxHeight?: number;
  41142. colorFilter?: Color3;
  41143. alphaFilter?: number;
  41144. updatable?: boolean;
  41145. onReady?: (mesh: GroundMesh) => void;
  41146. }, scene?: Nullable<Scene>): GroundMesh;
  41147. }
  41148. }
  41149. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41150. import { Vector4 } from "babylonjs/Maths/math";
  41151. import { Mesh } from "babylonjs/Meshes/mesh";
  41152. /**
  41153. * Class containing static functions to help procedurally build meshes
  41154. */
  41155. export class TorusBuilder {
  41156. /**
  41157. * Creates a torus mesh
  41158. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41159. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41160. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41164. * @param name defines the name of the mesh
  41165. * @param options defines the options used to create the mesh
  41166. * @param scene defines the hosting scene
  41167. * @returns the torus mesh
  41168. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41169. */
  41170. static CreateTorus(name: string, options: {
  41171. diameter?: number;
  41172. thickness?: number;
  41173. tessellation?: number;
  41174. updatable?: boolean;
  41175. sideOrientation?: number;
  41176. frontUVs?: Vector4;
  41177. backUVs?: Vector4;
  41178. }, scene: any): Mesh;
  41179. }
  41180. }
  41181. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41182. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41183. import { Mesh } from "babylonjs/Meshes/mesh";
  41184. /**
  41185. * Class containing static functions to help procedurally build meshes
  41186. */
  41187. export class CylinderBuilder {
  41188. /**
  41189. * Creates a cylinder or a cone mesh
  41190. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41191. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41192. * * 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.
  41193. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41194. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41195. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41196. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41197. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  41198. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41199. * * 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).
  41200. * * 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
  41201. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41202. * * 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
  41203. * * 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.
  41204. * * If `enclose` is false, a ring surface is one element.
  41205. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41206. * * 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
  41207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41210. * @param name defines the name of the mesh
  41211. * @param options defines the options used to create the mesh
  41212. * @param scene defines the hosting scene
  41213. * @returns the cylinder mesh
  41214. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41215. */
  41216. static CreateCylinder(name: string, options: {
  41217. height?: number;
  41218. diameterTop?: number;
  41219. diameterBottom?: number;
  41220. diameter?: number;
  41221. tessellation?: number;
  41222. subdivisions?: number;
  41223. arc?: number;
  41224. faceColors?: Color4[];
  41225. faceUV?: Vector4[];
  41226. updatable?: boolean;
  41227. hasRings?: boolean;
  41228. enclose?: boolean;
  41229. cap?: number;
  41230. sideOrientation?: number;
  41231. frontUVs?: Vector4;
  41232. backUVs?: Vector4;
  41233. }, scene: any): Mesh;
  41234. }
  41235. }
  41236. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41237. import { Observable } from "babylonjs/Misc/observable";
  41238. import { Nullable } from "babylonjs/types";
  41239. import { Camera } from "babylonjs/Cameras/camera";
  41240. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41241. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41242. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41243. import { Scene } from "babylonjs/scene";
  41244. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41245. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41247. import { Mesh } from "babylonjs/Meshes/mesh";
  41248. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41249. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41250. import "babylonjs/Meshes/Builders/groundBuilder";
  41251. import "babylonjs/Meshes/Builders/torusBuilder";
  41252. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41253. import "babylonjs/Gamepads/gamepadSceneComponent";
  41254. import "babylonjs/Animations/animatable";
  41255. /**
  41256. * Options to modify the vr teleportation behavior.
  41257. */
  41258. export interface VRTeleportationOptions {
  41259. /**
  41260. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41261. */
  41262. floorMeshName?: string;
  41263. /**
  41264. * A list of meshes to be used as the teleportation floor. (default: empty)
  41265. */
  41266. floorMeshes?: Mesh[];
  41267. }
  41268. /**
  41269. * Options to modify the vr experience helper's behavior.
  41270. */
  41271. export interface VRExperienceHelperOptions extends WebVROptions {
  41272. /**
  41273. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41274. */
  41275. createDeviceOrientationCamera?: boolean;
  41276. /**
  41277. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41278. */
  41279. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41280. /**
  41281. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41282. */
  41283. laserToggle?: boolean;
  41284. /**
  41285. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41286. */
  41287. floorMeshes?: Mesh[];
  41288. /**
  41289. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41290. */
  41291. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41292. }
  41293. /**
  41294. * Event containing information after VR has been entered
  41295. */
  41296. export class OnAfterEnteringVRObservableEvent {
  41297. /**
  41298. * If entering vr was successful
  41299. */
  41300. success: boolean;
  41301. }
  41302. /**
  41303. * Helps to quickly add VR support to an existing scene.
  41304. * See http://doc.babylonjs.com/how_to/webvr_helper
  41305. */
  41306. export class VRExperienceHelper {
  41307. /** Options to modify the vr experience helper's behavior. */
  41308. webVROptions: VRExperienceHelperOptions;
  41309. private _scene;
  41310. private _position;
  41311. private _btnVR;
  41312. private _btnVRDisplayed;
  41313. private _webVRsupported;
  41314. private _webVRready;
  41315. private _webVRrequesting;
  41316. private _webVRpresenting;
  41317. private _hasEnteredVR;
  41318. private _fullscreenVRpresenting;
  41319. private _canvas;
  41320. private _webVRCamera;
  41321. private _vrDeviceOrientationCamera;
  41322. private _deviceOrientationCamera;
  41323. private _existingCamera;
  41324. private _onKeyDown;
  41325. private _onVrDisplayPresentChange;
  41326. private _onVRDisplayChanged;
  41327. private _onVRRequestPresentStart;
  41328. private _onVRRequestPresentComplete;
  41329. /**
  41330. * Observable raised right before entering VR.
  41331. */
  41332. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41333. /**
  41334. * Observable raised when entering VR has completed.
  41335. */
  41336. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41337. /**
  41338. * Observable raised when exiting VR.
  41339. */
  41340. onExitingVRObservable: Observable<VRExperienceHelper>;
  41341. /**
  41342. * Observable raised when controller mesh is loaded.
  41343. */
  41344. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41345. /** Return this.onEnteringVRObservable
  41346. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41347. */
  41348. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41349. /** Return this.onExitingVRObservable
  41350. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41351. */
  41352. readonly onExitingVR: Observable<VRExperienceHelper>;
  41353. /** Return this.onControllerMeshLoadedObservable
  41354. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41355. */
  41356. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41357. private _rayLength;
  41358. private _useCustomVRButton;
  41359. private _teleportationRequested;
  41360. private _teleportActive;
  41361. private _floorMeshName;
  41362. private _floorMeshesCollection;
  41363. private _rotationAllowed;
  41364. private _teleportBackwardsVector;
  41365. private _teleportationTarget;
  41366. private _isDefaultTeleportationTarget;
  41367. private _postProcessMove;
  41368. private _teleportationFillColor;
  41369. private _teleportationBorderColor;
  41370. private _rotationAngle;
  41371. private _haloCenter;
  41372. private _cameraGazer;
  41373. private _padSensibilityUp;
  41374. private _padSensibilityDown;
  41375. private _leftController;
  41376. private _rightController;
  41377. /**
  41378. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41379. */
  41380. onNewMeshSelected: Observable<AbstractMesh>;
  41381. /**
  41382. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41383. */
  41384. onNewMeshPicked: Observable<PickingInfo>;
  41385. private _circleEase;
  41386. /**
  41387. * Observable raised before camera teleportation
  41388. */
  41389. onBeforeCameraTeleport: Observable<Vector3>;
  41390. /**
  41391. * Observable raised after camera teleportation
  41392. */
  41393. onAfterCameraTeleport: Observable<Vector3>;
  41394. /**
  41395. * Observable raised when current selected mesh gets unselected
  41396. */
  41397. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41398. private _raySelectionPredicate;
  41399. /**
  41400. * To be optionaly changed by user to define custom ray selection
  41401. */
  41402. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41403. /**
  41404. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41405. */
  41406. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41407. /**
  41408. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41409. */
  41410. teleportationEnabled: boolean;
  41411. private _defaultHeight;
  41412. private _teleportationInitialized;
  41413. private _interactionsEnabled;
  41414. private _interactionsRequested;
  41415. private _displayGaze;
  41416. private _displayLaserPointer;
  41417. /**
  41418. * The mesh used to display where the user is going to teleport.
  41419. */
  41420. /**
  41421. * Sets the mesh to be used to display where the user is going to teleport.
  41422. */
  41423. teleportationTarget: Mesh;
  41424. /**
  41425. * 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
  41426. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41427. * See http://doc.babylonjs.com/resources/baking_transformations
  41428. */
  41429. gazeTrackerMesh: Mesh;
  41430. /**
  41431. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41432. */
  41433. updateGazeTrackerScale: boolean;
  41434. /**
  41435. * If the gaze trackers color should be updated when selecting meshes
  41436. */
  41437. updateGazeTrackerColor: boolean;
  41438. /**
  41439. * The gaze tracking mesh corresponding to the left controller
  41440. */
  41441. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41442. /**
  41443. * The gaze tracking mesh corresponding to the right controller
  41444. */
  41445. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41446. /**
  41447. * If the ray of the gaze should be displayed.
  41448. */
  41449. /**
  41450. * Sets if the ray of the gaze should be displayed.
  41451. */
  41452. displayGaze: boolean;
  41453. /**
  41454. * If the ray of the LaserPointer should be displayed.
  41455. */
  41456. /**
  41457. * Sets if the ray of the LaserPointer should be displayed.
  41458. */
  41459. displayLaserPointer: boolean;
  41460. /**
  41461. * The deviceOrientationCamera used as the camera when not in VR.
  41462. */
  41463. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41464. /**
  41465. * Based on the current WebVR support, returns the current VR camera used.
  41466. */
  41467. readonly currentVRCamera: Nullable<Camera>;
  41468. /**
  41469. * The webVRCamera which is used when in VR.
  41470. */
  41471. readonly webVRCamera: WebVRFreeCamera;
  41472. /**
  41473. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41474. */
  41475. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41476. private readonly _teleportationRequestInitiated;
  41477. /**
  41478. * Defines wether or not Pointer lock should be requested when switching to
  41479. * full screen.
  41480. */
  41481. requestPointerLockOnFullScreen: boolean;
  41482. /**
  41483. * Instantiates a VRExperienceHelper.
  41484. * Helps to quickly add VR support to an existing scene.
  41485. * @param scene The scene the VRExperienceHelper belongs to.
  41486. * @param webVROptions Options to modify the vr experience helper's behavior.
  41487. */
  41488. constructor(scene: Scene,
  41489. /** Options to modify the vr experience helper's behavior. */
  41490. webVROptions?: VRExperienceHelperOptions);
  41491. private _onDefaultMeshLoaded;
  41492. private _onResize;
  41493. private _onFullscreenChange;
  41494. /**
  41495. * Gets a value indicating if we are currently in VR mode.
  41496. */
  41497. readonly isInVRMode: boolean;
  41498. private onVrDisplayPresentChange;
  41499. private onVRDisplayChanged;
  41500. private moveButtonToBottomRight;
  41501. private displayVRButton;
  41502. private updateButtonVisibility;
  41503. private _cachedAngularSensibility;
  41504. /**
  41505. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41506. * Otherwise, will use the fullscreen API.
  41507. */
  41508. enterVR(): void;
  41509. /**
  41510. * Attempt to exit VR, or fullscreen.
  41511. */
  41512. exitVR(): void;
  41513. /**
  41514. * The position of the vr experience helper.
  41515. */
  41516. /**
  41517. * Sets the position of the vr experience helper.
  41518. */
  41519. position: Vector3;
  41520. /**
  41521. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41522. */
  41523. enableInteractions(): void;
  41524. private readonly _noControllerIsActive;
  41525. private beforeRender;
  41526. private _isTeleportationFloor;
  41527. /**
  41528. * Adds a floor mesh to be used for teleportation.
  41529. * @param floorMesh the mesh to be used for teleportation.
  41530. */
  41531. addFloorMesh(floorMesh: Mesh): void;
  41532. /**
  41533. * Removes a floor mesh from being used for teleportation.
  41534. * @param floorMesh the mesh to be removed.
  41535. */
  41536. removeFloorMesh(floorMesh: Mesh): void;
  41537. /**
  41538. * Enables interactions and teleportation using the VR controllers and gaze.
  41539. * @param vrTeleportationOptions options to modify teleportation behavior.
  41540. */
  41541. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41542. private _onNewGamepadConnected;
  41543. private _tryEnableInteractionOnController;
  41544. private _onNewGamepadDisconnected;
  41545. private _enableInteractionOnController;
  41546. private _checkTeleportWithRay;
  41547. private _checkRotate;
  41548. private _checkTeleportBackwards;
  41549. private _enableTeleportationOnController;
  41550. private _createTeleportationCircles;
  41551. private _displayTeleportationTarget;
  41552. private _hideTeleportationTarget;
  41553. private _rotateCamera;
  41554. private _moveTeleportationSelectorTo;
  41555. private _workingVector;
  41556. private _workingQuaternion;
  41557. private _workingMatrix;
  41558. /**
  41559. * Teleports the users feet to the desired location
  41560. * @param location The location where the user's feet should be placed
  41561. */
  41562. teleportCamera(location: Vector3): void;
  41563. private _convertNormalToDirectionOfRay;
  41564. private _castRayAndSelectObject;
  41565. private _notifySelectedMeshUnselected;
  41566. /**
  41567. * Sets the color of the laser ray from the vr controllers.
  41568. * @param color new color for the ray.
  41569. */
  41570. changeLaserColor(color: Color3): void;
  41571. /**
  41572. * Sets the color of the ray from the vr headsets gaze.
  41573. * @param color new color for the ray.
  41574. */
  41575. changeGazeColor(color: Color3): void;
  41576. /**
  41577. * Exits VR and disposes of the vr experience helper
  41578. */
  41579. dispose(): void;
  41580. /**
  41581. * Gets the name of the VRExperienceHelper class
  41582. * @returns "VRExperienceHelper"
  41583. */
  41584. getClassName(): string;
  41585. }
  41586. }
  41587. declare module "babylonjs/Cameras/VR/index" {
  41588. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41589. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41590. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41591. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41592. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41593. export * from "babylonjs/Cameras/VR/webVRCamera";
  41594. }
  41595. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41596. import { Observable } from "babylonjs/Misc/observable";
  41597. import { Nullable } from "babylonjs/types";
  41598. import { IDisposable, Scene } from "babylonjs/scene";
  41599. import { Vector3 } from "babylonjs/Maths/math";
  41600. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41601. import { Ray } from "babylonjs/Culling/ray";
  41602. /**
  41603. * Manages an XRSession
  41604. * @see https://doc.babylonjs.com/how_to/webxr
  41605. */
  41606. export class WebXRSessionManager implements IDisposable {
  41607. private scene;
  41608. /**
  41609. * Fires every time a new xrFrame arrives which can be used to update the camera
  41610. */
  41611. onXRFrameObservable: Observable<any>;
  41612. /**
  41613. * Fires when the xr session is ended either by the device or manually done
  41614. */
  41615. onXRSessionEnded: Observable<any>;
  41616. /** @hidden */
  41617. _xrSession: XRSession;
  41618. /** @hidden */
  41619. _frameOfReference: XRFrameOfReference;
  41620. /** @hidden */
  41621. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41622. /** @hidden */
  41623. _currentXRFrame: Nullable<XRFrame>;
  41624. private _xrNavigator;
  41625. private _xrDevice;
  41626. private _tmpMatrix;
  41627. /**
  41628. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41629. * @param scene The scene which the session should be created for
  41630. */
  41631. constructor(scene: Scene);
  41632. /**
  41633. * Initializes the manager
  41634. * After initialization enterXR can be called to start an XR session
  41635. * @returns Promise which resolves after it is initialized
  41636. */
  41637. initializeAsync(): Promise<void>;
  41638. /**
  41639. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41640. * @param sessionCreationOptions xr options to create the session with
  41641. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41642. * @returns Promise which resolves after it enters XR
  41643. */
  41644. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41645. /**
  41646. * Stops the xrSession and restores the renderloop
  41647. * @returns Promise which resolves after it exits XR
  41648. */
  41649. exitXRAsync(): Promise<void>;
  41650. /**
  41651. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41652. * @param ray ray to cast into the environment
  41653. * @returns Promise which resolves with a collision point in the environment if it exists
  41654. */
  41655. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41656. /**
  41657. * Checks if a session would be supported for the creation options specified
  41658. * @param options creation options to check if they are supported
  41659. * @returns true if supported
  41660. */
  41661. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41662. /**
  41663. * @hidden
  41664. * Converts the render layer of xrSession to a render target
  41665. * @param session session to create render target for
  41666. * @param scene scene the new render target should be created for
  41667. */
  41668. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41669. /**
  41670. * Disposes of the session manager
  41671. */
  41672. dispose(): void;
  41673. }
  41674. }
  41675. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41676. import { Scene } from "babylonjs/scene";
  41677. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41678. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41679. /**
  41680. * WebXR Camera which holds the views for the xrSession
  41681. * @see https://doc.babylonjs.com/how_to/webxr
  41682. */
  41683. export class WebXRCamera extends FreeCamera {
  41684. private static _TmpMatrix;
  41685. /**
  41686. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41687. * @param name the name of the camera
  41688. * @param scene the scene to add the camera to
  41689. */
  41690. constructor(name: string, scene: Scene);
  41691. private _updateNumberOfRigCameras;
  41692. /** @hidden */
  41693. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41694. /**
  41695. * Updates the cameras position from the current pose information of the XR session
  41696. * @param xrSessionManager the session containing pose information
  41697. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41698. */
  41699. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41700. }
  41701. }
  41702. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41703. import { Nullable } from "babylonjs/types";
  41704. import { Observable } from "babylonjs/Misc/observable";
  41705. import { IDisposable, Scene } from "babylonjs/scene";
  41706. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41708. import { Ray } from "babylonjs/Culling/ray";
  41709. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41710. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41711. /**
  41712. * States of the webXR experience
  41713. */
  41714. export enum WebXRState {
  41715. /**
  41716. * Transitioning to being in XR mode
  41717. */
  41718. ENTERING_XR = 0,
  41719. /**
  41720. * Transitioning to non XR mode
  41721. */
  41722. EXITING_XR = 1,
  41723. /**
  41724. * In XR mode and presenting
  41725. */
  41726. IN_XR = 2,
  41727. /**
  41728. * Not entered XR mode
  41729. */
  41730. NOT_IN_XR = 3
  41731. }
  41732. /**
  41733. * Helper class used to enable XR
  41734. * @see https://doc.babylonjs.com/how_to/webxr
  41735. */
  41736. export class WebXRExperienceHelper implements IDisposable {
  41737. private scene;
  41738. /**
  41739. * 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
  41740. */
  41741. container: AbstractMesh;
  41742. /**
  41743. * Camera used to render xr content
  41744. */
  41745. camera: WebXRCamera;
  41746. /**
  41747. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41748. */
  41749. state: WebXRState;
  41750. private _setState;
  41751. private static _TmpVector;
  41752. /**
  41753. * Fires when the state of the experience helper has changed
  41754. */
  41755. onStateChangedObservable: Observable<WebXRState>;
  41756. /** @hidden */
  41757. _sessionManager: WebXRSessionManager;
  41758. private _nonVRCamera;
  41759. private _originalSceneAutoClear;
  41760. private _supported;
  41761. /**
  41762. * Creates the experience helper
  41763. * @param scene the scene to attach the experience helper to
  41764. * @returns a promise for the experience helper
  41765. */
  41766. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41767. /**
  41768. * Creates a WebXRExperienceHelper
  41769. * @param scene The scene the helper should be created in
  41770. */
  41771. private constructor();
  41772. /**
  41773. * Exits XR mode and returns the scene to its original state
  41774. * @returns promise that resolves after xr mode has exited
  41775. */
  41776. exitXRAsync(): Promise<void>;
  41777. /**
  41778. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41779. * @param sessionCreationOptions options for the XR session
  41780. * @param frameOfReference frame of reference of the XR session
  41781. * @returns promise that resolves after xr mode has entered
  41782. */
  41783. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41784. /**
  41785. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41786. * @param ray ray to cast into the environment
  41787. * @returns Promise which resolves with a collision point in the environment if it exists
  41788. */
  41789. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41790. /**
  41791. * Updates the global position of the camera by moving the camera's container
  41792. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41793. * @param position The desired global position of the camera
  41794. */
  41795. setPositionOfCameraUsingContainer(position: Vector3): void;
  41796. /**
  41797. * Rotates the xr camera by rotating the camera's container around the camera's position
  41798. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41799. * @param rotation the desired quaternion rotation to apply to the camera
  41800. */
  41801. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41802. /**
  41803. * Checks if the creation options are supported by the xr session
  41804. * @param options creation options
  41805. * @returns true if supported
  41806. */
  41807. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41808. /**
  41809. * Disposes of the experience helper
  41810. */
  41811. dispose(): void;
  41812. }
  41813. }
  41814. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41815. import { Nullable } from "babylonjs/types";
  41816. import { Observable } from "babylonjs/Misc/observable";
  41817. import { IDisposable, Scene } from "babylonjs/scene";
  41818. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41819. /**
  41820. * Button which can be used to enter a different mode of XR
  41821. */
  41822. export class WebXREnterExitUIButton {
  41823. /** button element */
  41824. element: HTMLElement;
  41825. /** XR initialization options for the button */
  41826. initializationOptions: XRSessionCreationOptions;
  41827. /**
  41828. * Creates a WebXREnterExitUIButton
  41829. * @param element button element
  41830. * @param initializationOptions XR initialization options for the button
  41831. */
  41832. constructor(
  41833. /** button element */
  41834. element: HTMLElement,
  41835. /** XR initialization options for the button */
  41836. initializationOptions: XRSessionCreationOptions);
  41837. /**
  41838. * Overwritable function which can be used to update the button's visuals when the state changes
  41839. * @param activeButton the current active button in the UI
  41840. */
  41841. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41842. }
  41843. /**
  41844. * Options to create the webXR UI
  41845. */
  41846. export class WebXREnterExitUIOptions {
  41847. /**
  41848. * Context to enter xr with
  41849. */
  41850. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41851. /**
  41852. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41853. */
  41854. customButtons?: Array<WebXREnterExitUIButton>;
  41855. }
  41856. /**
  41857. * UI to allow the user to enter/exit XR mode
  41858. */
  41859. export class WebXREnterExitUI implements IDisposable {
  41860. private scene;
  41861. private _overlay;
  41862. private _buttons;
  41863. private _activeButton;
  41864. /**
  41865. * Fired every time the active button is changed.
  41866. *
  41867. * When xr is entered via a button that launches xr that button will be the callback parameter
  41868. *
  41869. * When exiting xr the callback parameter will be null)
  41870. */
  41871. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41872. /**
  41873. * Creates UI to allow the user to enter/exit XR mode
  41874. * @param scene the scene to add the ui to
  41875. * @param helper the xr experience helper to enter/exit xr with
  41876. * @param options options to configure the UI
  41877. * @returns the created ui
  41878. */
  41879. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41880. private constructor();
  41881. private _updateButtons;
  41882. /**
  41883. * Disposes of the object
  41884. */
  41885. dispose(): void;
  41886. }
  41887. }
  41888. declare module "babylonjs/Cameras/XR/webXRInput" {
  41889. import { IDisposable, Scene } from "babylonjs/scene";
  41890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41891. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41892. /**
  41893. * Represents an XR input
  41894. */
  41895. export class WebXRController {
  41896. /**
  41897. * 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
  41898. */
  41899. grip?: AbstractMesh;
  41900. /**
  41901. * Pointer which can be used to select objects or attach a visible laser to
  41902. */
  41903. pointer: AbstractMesh;
  41904. /**
  41905. * Creates the controller
  41906. * @see https://doc.babylonjs.com/how_to/webxr
  41907. * @param scene the scene which the controller should be associated to
  41908. */
  41909. constructor(scene: Scene);
  41910. /**
  41911. * Disposes of the object
  41912. */
  41913. dispose(): void;
  41914. }
  41915. /**
  41916. * XR input used to track XR inputs such as controllers/rays
  41917. */
  41918. export class WebXRInput implements IDisposable {
  41919. private helper;
  41920. /**
  41921. * XR controllers being tracked
  41922. */
  41923. controllers: Array<WebXRController>;
  41924. private _tmpMatrix;
  41925. private _frameObserver;
  41926. /**
  41927. * Initializes the WebXRInput
  41928. * @param helper experience helper which the input should be created for
  41929. */
  41930. constructor(helper: WebXRExperienceHelper);
  41931. /**
  41932. * Disposes of the object
  41933. */
  41934. dispose(): void;
  41935. }
  41936. }
  41937. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41938. import { Nullable } from "babylonjs/types";
  41939. import { IDisposable } from "babylonjs/scene";
  41940. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41941. /**
  41942. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41943. */
  41944. export class WebXRManagedOutputCanvas implements IDisposable {
  41945. private _canvas;
  41946. /**
  41947. * xrpresent context of the canvas which can be used to display/mirror xr content
  41948. */
  41949. canvasContext: Nullable<WebGLRenderingContext>;
  41950. /**
  41951. * Initializes the canvas to be added/removed upon entering/exiting xr
  41952. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41953. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41954. */
  41955. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41956. /**
  41957. * Disposes of the object
  41958. */
  41959. dispose(): void;
  41960. private _setManagedOutputCanvas;
  41961. private _addCanvas;
  41962. private _removeCanvas;
  41963. }
  41964. }
  41965. declare module "babylonjs/Cameras/XR/index" {
  41966. export * from "babylonjs/Cameras/XR/webXRCamera";
  41967. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41968. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41969. export * from "babylonjs/Cameras/XR/webXRInput";
  41970. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41971. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41972. }
  41973. declare module "babylonjs/Cameras/RigModes/index" {
  41974. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41975. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41976. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41977. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41978. }
  41979. declare module "babylonjs/Cameras/index" {
  41980. export * from "babylonjs/Cameras/Inputs/index";
  41981. export * from "babylonjs/Cameras/cameraInputsManager";
  41982. export * from "babylonjs/Cameras/camera";
  41983. export * from "babylonjs/Cameras/targetCamera";
  41984. export * from "babylonjs/Cameras/freeCamera";
  41985. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41986. export * from "babylonjs/Cameras/touchCamera";
  41987. export * from "babylonjs/Cameras/arcRotateCamera";
  41988. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41989. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41990. export * from "babylonjs/Cameras/flyCamera";
  41991. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41992. export * from "babylonjs/Cameras/followCamera";
  41993. export * from "babylonjs/Cameras/gamepadCamera";
  41994. export * from "babylonjs/Cameras/Stereoscopic/index";
  41995. export * from "babylonjs/Cameras/universalCamera";
  41996. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41997. export * from "babylonjs/Cameras/VR/index";
  41998. export * from "babylonjs/Cameras/XR/index";
  41999. export * from "babylonjs/Cameras/RigModes/index";
  42000. }
  42001. declare module "babylonjs/Collisions/index" {
  42002. export * from "babylonjs/Collisions/collider";
  42003. export * from "babylonjs/Collisions/collisionCoordinator";
  42004. export * from "babylonjs/Collisions/pickingInfo";
  42005. export * from "babylonjs/Collisions/intersectionInfo";
  42006. export * from "babylonjs/Collisions/meshCollisionData";
  42007. }
  42008. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42009. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42010. import { Vector3, Plane } from "babylonjs/Maths/math";
  42011. import { Ray } from "babylonjs/Culling/ray";
  42012. /**
  42013. * Contains an array of blocks representing the octree
  42014. */
  42015. export interface IOctreeContainer<T> {
  42016. /**
  42017. * Blocks within the octree
  42018. */
  42019. blocks: Array<OctreeBlock<T>>;
  42020. }
  42021. /**
  42022. * Class used to store a cell in an octree
  42023. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42024. */
  42025. export class OctreeBlock<T> {
  42026. /**
  42027. * Gets the content of the current block
  42028. */
  42029. entries: T[];
  42030. /**
  42031. * Gets the list of block children
  42032. */
  42033. blocks: Array<OctreeBlock<T>>;
  42034. private _depth;
  42035. private _maxDepth;
  42036. private _capacity;
  42037. private _minPoint;
  42038. private _maxPoint;
  42039. private _boundingVectors;
  42040. private _creationFunc;
  42041. /**
  42042. * Creates a new block
  42043. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42044. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42045. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42046. * @param depth defines the current depth of this block in the octree
  42047. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42048. * @param creationFunc defines a callback to call when an element is added to the block
  42049. */
  42050. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42051. /**
  42052. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42053. */
  42054. readonly capacity: number;
  42055. /**
  42056. * Gets the minimum vector (in world space) of the block's bounding box
  42057. */
  42058. readonly minPoint: Vector3;
  42059. /**
  42060. * Gets the maximum vector (in world space) of the block's bounding box
  42061. */
  42062. readonly maxPoint: Vector3;
  42063. /**
  42064. * Add a new element to this block
  42065. * @param entry defines the element to add
  42066. */
  42067. addEntry(entry: T): void;
  42068. /**
  42069. * Remove an element from this block
  42070. * @param entry defines the element to remove
  42071. */
  42072. removeEntry(entry: T): void;
  42073. /**
  42074. * Add an array of elements to this block
  42075. * @param entries defines the array of elements to add
  42076. */
  42077. addEntries(entries: T[]): void;
  42078. /**
  42079. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42080. * @param frustumPlanes defines the frustum planes to test
  42081. * @param selection defines the array to store current content if selection is positive
  42082. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42083. */
  42084. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42085. /**
  42086. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42087. * @param sphereCenter defines the bounding sphere center
  42088. * @param sphereRadius defines the bounding sphere radius
  42089. * @param selection defines the array to store current content if selection is positive
  42090. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42091. */
  42092. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42093. /**
  42094. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42095. * @param ray defines the ray to test with
  42096. * @param selection defines the array to store current content if selection is positive
  42097. */
  42098. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42099. /**
  42100. * Subdivide the content into child blocks (this block will then be empty)
  42101. */
  42102. createInnerBlocks(): void;
  42103. /**
  42104. * @hidden
  42105. */
  42106. 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;
  42107. }
  42108. }
  42109. declare module "babylonjs/Culling/Octrees/octree" {
  42110. import { SmartArray } from "babylonjs/Misc/smartArray";
  42111. import { Vector3, Plane } from "babylonjs/Maths/math";
  42112. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42114. import { Ray } from "babylonjs/Culling/ray";
  42115. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42116. /**
  42117. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42119. */
  42120. export class Octree<T> {
  42121. /** 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.) */
  42122. maxDepth: number;
  42123. /**
  42124. * Blocks within the octree containing objects
  42125. */
  42126. blocks: Array<OctreeBlock<T>>;
  42127. /**
  42128. * Content stored in the octree
  42129. */
  42130. dynamicContent: T[];
  42131. private _maxBlockCapacity;
  42132. private _selectionContent;
  42133. private _creationFunc;
  42134. /**
  42135. * Creates a octree
  42136. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42137. * @param creationFunc function to be used to instatiate the octree
  42138. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42139. * @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.)
  42140. */
  42141. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42142. /** 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.) */
  42143. maxDepth?: number);
  42144. /**
  42145. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42146. * @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);
  42147. * @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);
  42148. * @param entries meshes to be added to the octree blocks
  42149. */
  42150. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42151. /**
  42152. * Adds a mesh to the octree
  42153. * @param entry Mesh to add to the octree
  42154. */
  42155. addMesh(entry: T): void;
  42156. /**
  42157. * Remove an element from the octree
  42158. * @param entry defines the element to remove
  42159. */
  42160. removeMesh(entry: T): void;
  42161. /**
  42162. * Selects an array of meshes within the frustum
  42163. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42164. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42165. * @returns array of meshes within the frustum
  42166. */
  42167. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42168. /**
  42169. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42170. * @param sphereCenter defines the bounding sphere center
  42171. * @param sphereRadius defines the bounding sphere radius
  42172. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42173. * @returns an array of objects that intersect the sphere
  42174. */
  42175. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42176. /**
  42177. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42178. * @param ray defines the ray to test with
  42179. * @returns array of intersected objects
  42180. */
  42181. intersectsRay(ray: Ray): SmartArray<T>;
  42182. /**
  42183. * Adds a mesh into the octree block if it intersects the block
  42184. */
  42185. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42186. /**
  42187. * Adds a submesh into the octree block if it intersects the block
  42188. */
  42189. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42190. }
  42191. }
  42192. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42193. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42194. import { Scene } from "babylonjs/scene";
  42195. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42197. import { Ray } from "babylonjs/Culling/ray";
  42198. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42199. import { Collider } from "babylonjs/Collisions/collider";
  42200. module "babylonjs/scene" {
  42201. interface Scene {
  42202. /**
  42203. * @hidden
  42204. * Backing Filed
  42205. */
  42206. _selectionOctree: Octree<AbstractMesh>;
  42207. /**
  42208. * Gets the octree used to boost mesh selection (picking)
  42209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42210. */
  42211. selectionOctree: Octree<AbstractMesh>;
  42212. /**
  42213. * Creates or updates the octree used to boost selection (picking)
  42214. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42215. * @param maxCapacity defines the maximum capacity per leaf
  42216. * @param maxDepth defines the maximum depth of the octree
  42217. * @returns an octree of AbstractMesh
  42218. */
  42219. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42220. }
  42221. }
  42222. module "babylonjs/Meshes/abstractMesh" {
  42223. interface AbstractMesh {
  42224. /**
  42225. * @hidden
  42226. * Backing Field
  42227. */
  42228. _submeshesOctree: Octree<SubMesh>;
  42229. /**
  42230. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42231. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42232. * @param maxCapacity defines the maximum size of each block (64 by default)
  42233. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42234. * @returns the new octree
  42235. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42237. */
  42238. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42239. }
  42240. }
  42241. /**
  42242. * Defines the octree scene component responsible to manage any octrees
  42243. * in a given scene.
  42244. */
  42245. export class OctreeSceneComponent {
  42246. /**
  42247. * The component name help to identify the component in the list of scene components.
  42248. */
  42249. readonly name: string;
  42250. /**
  42251. * The scene the component belongs to.
  42252. */
  42253. scene: Scene;
  42254. /**
  42255. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42256. */
  42257. readonly checksIsEnabled: boolean;
  42258. /**
  42259. * Creates a new instance of the component for the given scene
  42260. * @param scene Defines the scene to register the component in
  42261. */
  42262. constructor(scene: Scene);
  42263. /**
  42264. * Registers the component in a given scene
  42265. */
  42266. register(): void;
  42267. /**
  42268. * Return the list of active meshes
  42269. * @returns the list of active meshes
  42270. */
  42271. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42272. /**
  42273. * Return the list of active sub meshes
  42274. * @param mesh The mesh to get the candidates sub meshes from
  42275. * @returns the list of active sub meshes
  42276. */
  42277. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42278. private _tempRay;
  42279. /**
  42280. * Return the list of sub meshes intersecting with a given local ray
  42281. * @param mesh defines the mesh to find the submesh for
  42282. * @param localRay defines the ray in local space
  42283. * @returns the list of intersecting sub meshes
  42284. */
  42285. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42286. /**
  42287. * Return the list of sub meshes colliding with a collider
  42288. * @param mesh defines the mesh to find the submesh for
  42289. * @param collider defines the collider to evaluate the collision against
  42290. * @returns the list of colliding sub meshes
  42291. */
  42292. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42293. /**
  42294. * Rebuilds the elements related to this component in case of
  42295. * context lost for instance.
  42296. */
  42297. rebuild(): void;
  42298. /**
  42299. * Disposes the component and the associated ressources.
  42300. */
  42301. dispose(): void;
  42302. }
  42303. }
  42304. declare module "babylonjs/Culling/Octrees/index" {
  42305. export * from "babylonjs/Culling/Octrees/octree";
  42306. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42307. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42308. }
  42309. declare module "babylonjs/Culling/index" {
  42310. export * from "babylonjs/Culling/boundingBox";
  42311. export * from "babylonjs/Culling/boundingInfo";
  42312. export * from "babylonjs/Culling/boundingSphere";
  42313. export * from "babylonjs/Culling/Octrees/index";
  42314. export * from "babylonjs/Culling/ray";
  42315. }
  42316. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42317. import { IDisposable, Scene } from "babylonjs/scene";
  42318. import { Nullable } from "babylonjs/types";
  42319. import { Observable } from "babylonjs/Misc/observable";
  42320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42321. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42322. import { Camera } from "babylonjs/Cameras/camera";
  42323. /**
  42324. * Renders a layer on top of an existing scene
  42325. */
  42326. export class UtilityLayerRenderer implements IDisposable {
  42327. /** the original scene that will be rendered on top of */
  42328. originalScene: Scene;
  42329. private _pointerCaptures;
  42330. private _lastPointerEvents;
  42331. private static _DefaultUtilityLayer;
  42332. private static _DefaultKeepDepthUtilityLayer;
  42333. private _sharedGizmoLight;
  42334. private _renderCamera;
  42335. /**
  42336. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42337. * @returns the camera that is used when rendering the utility layer
  42338. */
  42339. getRenderCamera(): Nullable<Camera>;
  42340. /**
  42341. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42342. * @param cam the camera that should be used when rendering the utility layer
  42343. */
  42344. setRenderCamera(cam: Nullable<Camera>): void;
  42345. /**
  42346. * @hidden
  42347. * Light which used by gizmos to get light shading
  42348. */
  42349. _getSharedGizmoLight(): HemisphericLight;
  42350. /**
  42351. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42352. */
  42353. pickUtilitySceneFirst: boolean;
  42354. /**
  42355. * 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)
  42356. */
  42357. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42358. /**
  42359. * 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)
  42360. */
  42361. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42362. /**
  42363. * The scene that is rendered on top of the original scene
  42364. */
  42365. utilityLayerScene: Scene;
  42366. /**
  42367. * If the utility layer should automatically be rendered on top of existing scene
  42368. */
  42369. shouldRender: boolean;
  42370. /**
  42371. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42372. */
  42373. onlyCheckPointerDownEvents: boolean;
  42374. /**
  42375. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42376. */
  42377. processAllEvents: boolean;
  42378. /**
  42379. * Observable raised when the pointer move from the utility layer scene to the main scene
  42380. */
  42381. onPointerOutObservable: Observable<number>;
  42382. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42383. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42384. private _afterRenderObserver;
  42385. private _sceneDisposeObserver;
  42386. private _originalPointerObserver;
  42387. /**
  42388. * Instantiates a UtilityLayerRenderer
  42389. * @param originalScene the original scene that will be rendered on top of
  42390. * @param handleEvents boolean indicating if the utility layer should handle events
  42391. */
  42392. constructor(
  42393. /** the original scene that will be rendered on top of */
  42394. originalScene: Scene, handleEvents?: boolean);
  42395. private _notifyObservers;
  42396. /**
  42397. * Renders the utility layers scene on top of the original scene
  42398. */
  42399. render(): void;
  42400. /**
  42401. * Disposes of the renderer
  42402. */
  42403. dispose(): void;
  42404. private _updateCamera;
  42405. }
  42406. }
  42407. declare module "babylonjs/Gizmos/gizmo" {
  42408. import { Nullable } from "babylonjs/types";
  42409. import { IDisposable } from "babylonjs/scene";
  42410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42411. import { Mesh } from "babylonjs/Meshes/mesh";
  42412. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42413. /**
  42414. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42415. */
  42416. export class Gizmo implements IDisposable {
  42417. /** The utility layer the gizmo will be added to */
  42418. gizmoLayer: UtilityLayerRenderer;
  42419. /**
  42420. * The root mesh of the gizmo
  42421. */
  42422. _rootMesh: Mesh;
  42423. private _attachedMesh;
  42424. /**
  42425. * Ratio for the scale of the gizmo (Default: 1)
  42426. */
  42427. scaleRatio: number;
  42428. /**
  42429. * If a custom mesh has been set (Default: false)
  42430. */
  42431. protected _customMeshSet: boolean;
  42432. /**
  42433. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42434. * * When set, interactions will be enabled
  42435. */
  42436. attachedMesh: Nullable<AbstractMesh>;
  42437. /**
  42438. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42439. * @param mesh The mesh to replace the default mesh of the gizmo
  42440. */
  42441. setCustomMesh(mesh: Mesh): void;
  42442. /**
  42443. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42444. */
  42445. updateGizmoRotationToMatchAttachedMesh: boolean;
  42446. /**
  42447. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42448. */
  42449. updateGizmoPositionToMatchAttachedMesh: boolean;
  42450. /**
  42451. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42452. */
  42453. protected _updateScale: boolean;
  42454. protected _interactionsEnabled: boolean;
  42455. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42456. private _beforeRenderObserver;
  42457. private _tempVector;
  42458. /**
  42459. * Creates a gizmo
  42460. * @param gizmoLayer The utility layer the gizmo will be added to
  42461. */
  42462. constructor(
  42463. /** The utility layer the gizmo will be added to */
  42464. gizmoLayer?: UtilityLayerRenderer);
  42465. /**
  42466. * Updates the gizmo to match the attached mesh's position/rotation
  42467. */
  42468. protected _update(): void;
  42469. /**
  42470. * Disposes of the gizmo
  42471. */
  42472. dispose(): void;
  42473. }
  42474. }
  42475. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42476. import { Observable } from "babylonjs/Misc/observable";
  42477. import { Nullable } from "babylonjs/types";
  42478. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42479. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42481. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42482. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42483. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42484. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42485. import { Scene } from "babylonjs/scene";
  42486. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42487. /**
  42488. * Single plane drag gizmo
  42489. */
  42490. export class PlaneDragGizmo extends Gizmo {
  42491. /**
  42492. * Drag behavior responsible for the gizmos dragging interactions
  42493. */
  42494. dragBehavior: PointerDragBehavior;
  42495. private _pointerObserver;
  42496. /**
  42497. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42498. */
  42499. snapDistance: number;
  42500. /**
  42501. * Event that fires each time the gizmo snaps to a new location.
  42502. * * snapDistance is the the change in distance
  42503. */
  42504. onSnapObservable: Observable<{
  42505. snapDistance: number;
  42506. }>;
  42507. private _plane;
  42508. private _coloredMaterial;
  42509. private _hoverMaterial;
  42510. private _isEnabled;
  42511. private _parent;
  42512. /** @hidden */
  42513. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42514. /** @hidden */
  42515. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42516. /**
  42517. * Creates a PlaneDragGizmo
  42518. * @param gizmoLayer The utility layer the gizmo will be added to
  42519. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42520. * @param color The color of the gizmo
  42521. */
  42522. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42523. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42524. /**
  42525. * If the gizmo is enabled
  42526. */
  42527. isEnabled: boolean;
  42528. /**
  42529. * Disposes of the gizmo
  42530. */
  42531. dispose(): void;
  42532. }
  42533. }
  42534. declare module "babylonjs/Gizmos/positionGizmo" {
  42535. import { Observable } from "babylonjs/Misc/observable";
  42536. import { Nullable } from "babylonjs/types";
  42537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42538. import { Mesh } from "babylonjs/Meshes/mesh";
  42539. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42540. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42541. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42542. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42543. /**
  42544. * Gizmo that enables dragging a mesh along 3 axis
  42545. */
  42546. export class PositionGizmo extends Gizmo {
  42547. /**
  42548. * Internal gizmo used for interactions on the x axis
  42549. */
  42550. xGizmo: AxisDragGizmo;
  42551. /**
  42552. * Internal gizmo used for interactions on the y axis
  42553. */
  42554. yGizmo: AxisDragGizmo;
  42555. /**
  42556. * Internal gizmo used for interactions on the z axis
  42557. */
  42558. zGizmo: AxisDragGizmo;
  42559. /**
  42560. * Internal gizmo used for interactions on the yz plane
  42561. */
  42562. xPlaneGizmo: PlaneDragGizmo;
  42563. /**
  42564. * Internal gizmo used for interactions on the xz plane
  42565. */
  42566. yPlaneGizmo: PlaneDragGizmo;
  42567. /**
  42568. * Internal gizmo used for interactions on the xy plane
  42569. */
  42570. zPlaneGizmo: PlaneDragGizmo;
  42571. /**
  42572. * private variables
  42573. */
  42574. private _meshAttached;
  42575. private _updateGizmoRotationToMatchAttachedMesh;
  42576. private _snapDistance;
  42577. private _scaleRatio;
  42578. /** Fires an event when any of it's sub gizmos are dragged */
  42579. onDragStartObservable: Observable<{}>;
  42580. /** Fires an event when any of it's sub gizmos are released from dragging */
  42581. onDragEndObservable: Observable<{}>;
  42582. /**
  42583. * If set to true, planar drag is enabled
  42584. */
  42585. private _planarGizmoEnabled;
  42586. attachedMesh: Nullable<AbstractMesh>;
  42587. /**
  42588. * Creates a PositionGizmo
  42589. * @param gizmoLayer The utility layer the gizmo will be added to
  42590. */
  42591. constructor(gizmoLayer?: UtilityLayerRenderer);
  42592. /**
  42593. * If the planar drag gizmo is enabled
  42594. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42595. */
  42596. planarGizmoEnabled: boolean;
  42597. updateGizmoRotationToMatchAttachedMesh: boolean;
  42598. /**
  42599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42600. */
  42601. snapDistance: number;
  42602. /**
  42603. * Ratio for the scale of the gizmo (Default: 1)
  42604. */
  42605. scaleRatio: number;
  42606. /**
  42607. * Disposes of the gizmo
  42608. */
  42609. dispose(): void;
  42610. /**
  42611. * CustomMeshes are not supported by this gizmo
  42612. * @param mesh The mesh to replace the default mesh of the gizmo
  42613. */
  42614. setCustomMesh(mesh: Mesh): void;
  42615. }
  42616. }
  42617. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42618. import { Observable } from "babylonjs/Misc/observable";
  42619. import { Nullable } from "babylonjs/types";
  42620. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42621. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42623. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42624. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42625. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42626. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42627. import { Scene } from "babylonjs/scene";
  42628. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42629. /**
  42630. * Single axis drag gizmo
  42631. */
  42632. export class AxisDragGizmo extends Gizmo {
  42633. /**
  42634. * Drag behavior responsible for the gizmos dragging interactions
  42635. */
  42636. dragBehavior: PointerDragBehavior;
  42637. private _pointerObserver;
  42638. /**
  42639. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42640. */
  42641. snapDistance: number;
  42642. /**
  42643. * Event that fires each time the gizmo snaps to a new location.
  42644. * * snapDistance is the the change in distance
  42645. */
  42646. onSnapObservable: Observable<{
  42647. snapDistance: number;
  42648. }>;
  42649. private _isEnabled;
  42650. private _parent;
  42651. private _arrow;
  42652. private _coloredMaterial;
  42653. private _hoverMaterial;
  42654. /** @hidden */
  42655. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42656. /** @hidden */
  42657. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42658. /**
  42659. * Creates an AxisDragGizmo
  42660. * @param gizmoLayer The utility layer the gizmo will be added to
  42661. * @param dragAxis The axis which the gizmo will be able to drag on
  42662. * @param color The color of the gizmo
  42663. */
  42664. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42665. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42666. /**
  42667. * If the gizmo is enabled
  42668. */
  42669. isEnabled: boolean;
  42670. /**
  42671. * Disposes of the gizmo
  42672. */
  42673. dispose(): void;
  42674. }
  42675. }
  42676. declare module "babylonjs/Debug/axesViewer" {
  42677. import { Vector3 } from "babylonjs/Maths/math";
  42678. import { Nullable } from "babylonjs/types";
  42679. import { Scene } from "babylonjs/scene";
  42680. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42681. /**
  42682. * The Axes viewer will show 3 axes in a specific point in space
  42683. */
  42684. export class AxesViewer {
  42685. private _xAxis;
  42686. private _yAxis;
  42687. private _zAxis;
  42688. private _scaleLinesFactor;
  42689. private _instanced;
  42690. /**
  42691. * Gets the hosting scene
  42692. */
  42693. scene: Scene;
  42694. /**
  42695. * Gets or sets a number used to scale line length
  42696. */
  42697. scaleLines: number;
  42698. /** Gets the node hierarchy used to render x-axis */
  42699. readonly xAxis: TransformNode;
  42700. /** Gets the node hierarchy used to render y-axis */
  42701. readonly yAxis: TransformNode;
  42702. /** Gets the node hierarchy used to render z-axis */
  42703. readonly zAxis: TransformNode;
  42704. /**
  42705. * Creates a new AxesViewer
  42706. * @param scene defines the hosting scene
  42707. * @param scaleLines defines a number used to scale line length (1 by default)
  42708. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42709. * @param xAxis defines the node hierarchy used to render the x-axis
  42710. * @param yAxis defines the node hierarchy used to render the y-axis
  42711. * @param zAxis defines the node hierarchy used to render the z-axis
  42712. */
  42713. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42714. /**
  42715. * Force the viewer to update
  42716. * @param position defines the position of the viewer
  42717. * @param xaxis defines the x axis of the viewer
  42718. * @param yaxis defines the y axis of the viewer
  42719. * @param zaxis defines the z axis of the viewer
  42720. */
  42721. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42722. /**
  42723. * Creates an instance of this axes viewer.
  42724. * @returns a new axes viewer with instanced meshes
  42725. */
  42726. createInstance(): AxesViewer;
  42727. /** Releases resources */
  42728. dispose(): void;
  42729. private static _SetRenderingGroupId;
  42730. }
  42731. }
  42732. declare module "babylonjs/Debug/boneAxesViewer" {
  42733. import { Nullable } from "babylonjs/types";
  42734. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42735. import { Vector3 } from "babylonjs/Maths/math";
  42736. import { Mesh } from "babylonjs/Meshes/mesh";
  42737. import { Bone } from "babylonjs/Bones/bone";
  42738. import { Scene } from "babylonjs/scene";
  42739. /**
  42740. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42741. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42742. */
  42743. export class BoneAxesViewer extends AxesViewer {
  42744. /**
  42745. * Gets or sets the target mesh where to display the axes viewer
  42746. */
  42747. mesh: Nullable<Mesh>;
  42748. /**
  42749. * Gets or sets the target bone where to display the axes viewer
  42750. */
  42751. bone: Nullable<Bone>;
  42752. /** Gets current position */
  42753. pos: Vector3;
  42754. /** Gets direction of X axis */
  42755. xaxis: Vector3;
  42756. /** Gets direction of Y axis */
  42757. yaxis: Vector3;
  42758. /** Gets direction of Z axis */
  42759. zaxis: Vector3;
  42760. /**
  42761. * Creates a new BoneAxesViewer
  42762. * @param scene defines the hosting scene
  42763. * @param bone defines the target bone
  42764. * @param mesh defines the target mesh
  42765. * @param scaleLines defines a scaling factor for line length (1 by default)
  42766. */
  42767. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42768. /**
  42769. * Force the viewer to update
  42770. */
  42771. update(): void;
  42772. /** Releases resources */
  42773. dispose(): void;
  42774. }
  42775. }
  42776. declare module "babylonjs/Debug/debugLayer" {
  42777. import { Observable } from "babylonjs/Misc/observable";
  42778. import { Scene } from "babylonjs/scene";
  42779. /**
  42780. * Interface used to define scene explorer extensibility option
  42781. */
  42782. export interface IExplorerExtensibilityOption {
  42783. /**
  42784. * Define the option label
  42785. */
  42786. label: string;
  42787. /**
  42788. * Defines the action to execute on click
  42789. */
  42790. action: (entity: any) => void;
  42791. }
  42792. /**
  42793. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42794. */
  42795. export interface IExplorerExtensibilityGroup {
  42796. /**
  42797. * Defines a predicate to test if a given type mut be extended
  42798. */
  42799. predicate: (entity: any) => boolean;
  42800. /**
  42801. * Gets the list of options added to a type
  42802. */
  42803. entries: IExplorerExtensibilityOption[];
  42804. }
  42805. /**
  42806. * Interface used to define the options to use to create the Inspector
  42807. */
  42808. export interface IInspectorOptions {
  42809. /**
  42810. * Display in overlay mode (default: false)
  42811. */
  42812. overlay?: boolean;
  42813. /**
  42814. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42815. */
  42816. globalRoot?: HTMLElement;
  42817. /**
  42818. * Display the Scene explorer
  42819. */
  42820. showExplorer?: boolean;
  42821. /**
  42822. * Display the property inspector
  42823. */
  42824. showInspector?: boolean;
  42825. /**
  42826. * Display in embed mode (both panes on the right)
  42827. */
  42828. embedMode?: boolean;
  42829. /**
  42830. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42831. */
  42832. handleResize?: boolean;
  42833. /**
  42834. * Allow the panes to popup (default: true)
  42835. */
  42836. enablePopup?: boolean;
  42837. /**
  42838. * Allow the panes to be closed by users (default: true)
  42839. */
  42840. enableClose?: boolean;
  42841. /**
  42842. * Optional list of extensibility entries
  42843. */
  42844. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42845. /**
  42846. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42847. */
  42848. inspectorURL?: string;
  42849. }
  42850. module "babylonjs/scene" {
  42851. interface Scene {
  42852. /**
  42853. * @hidden
  42854. * Backing field
  42855. */
  42856. _debugLayer: DebugLayer;
  42857. /**
  42858. * Gets the debug layer (aka Inspector) associated with the scene
  42859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42860. */
  42861. debugLayer: DebugLayer;
  42862. }
  42863. }
  42864. /**
  42865. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42866. * what is happening in your scene
  42867. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42868. */
  42869. export class DebugLayer {
  42870. /**
  42871. * Define the url to get the inspector script from.
  42872. * By default it uses the babylonjs CDN.
  42873. * @ignoreNaming
  42874. */
  42875. static InspectorURL: string;
  42876. private _scene;
  42877. private BJSINSPECTOR;
  42878. /**
  42879. * Observable triggered when a property is changed through the inspector.
  42880. */
  42881. onPropertyChangedObservable: Observable<{
  42882. object: any;
  42883. property: string;
  42884. value: any;
  42885. initialValue: any;
  42886. }>;
  42887. /**
  42888. * Instantiates a new debug layer.
  42889. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42890. * what is happening in your scene
  42891. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42892. * @param scene Defines the scene to inspect
  42893. */
  42894. constructor(scene: Scene);
  42895. /** Creates the inspector window. */
  42896. private _createInspector;
  42897. /**
  42898. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42899. * @param entity defines the entity to select
  42900. * @param lineContainerTitle defines the specific block to highlight
  42901. */
  42902. select(entity: any, lineContainerTitle?: string): void;
  42903. /** Get the inspector from bundle or global */
  42904. private _getGlobalInspector;
  42905. /**
  42906. * Get if the inspector is visible or not.
  42907. * @returns true if visible otherwise, false
  42908. */
  42909. isVisible(): boolean;
  42910. /**
  42911. * Hide the inspector and close its window.
  42912. */
  42913. hide(): void;
  42914. /**
  42915. * Launch the debugLayer.
  42916. * @param config Define the configuration of the inspector
  42917. * @return a promise fulfilled when the debug layer is visible
  42918. */
  42919. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42920. }
  42921. }
  42922. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42923. import { Nullable } from "babylonjs/types";
  42924. import { Scene } from "babylonjs/scene";
  42925. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42926. import { Mesh } from "babylonjs/Meshes/mesh";
  42927. /**
  42928. * Class containing static functions to help procedurally build meshes
  42929. */
  42930. export class BoxBuilder {
  42931. /**
  42932. * Creates a box mesh
  42933. * * The parameter `size` sets the size (float) of each box side (default 1)
  42934. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42935. * * 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)
  42936. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42940. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42941. * @param name defines the name of the mesh
  42942. * @param options defines the options used to create the mesh
  42943. * @param scene defines the hosting scene
  42944. * @returns the box mesh
  42945. */
  42946. static CreateBox(name: string, options: {
  42947. size?: number;
  42948. width?: number;
  42949. height?: number;
  42950. depth?: number;
  42951. faceUV?: Vector4[];
  42952. faceColors?: Color4[];
  42953. sideOrientation?: number;
  42954. frontUVs?: Vector4;
  42955. backUVs?: Vector4;
  42956. wrap?: boolean;
  42957. topBaseAt?: number;
  42958. bottomBaseAt?: number;
  42959. updatable?: boolean;
  42960. }, scene?: Nullable<Scene>): Mesh;
  42961. }
  42962. }
  42963. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42964. import { Vector4 } from "babylonjs/Maths/math";
  42965. import { Mesh } from "babylonjs/Meshes/mesh";
  42966. /**
  42967. * Class containing static functions to help procedurally build meshes
  42968. */
  42969. export class SphereBuilder {
  42970. /**
  42971. * Creates a sphere mesh
  42972. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42973. * * 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`)
  42974. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42975. * * 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
  42976. * * 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)
  42977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42980. * @param name defines the name of the mesh
  42981. * @param options defines the options used to create the mesh
  42982. * @param scene defines the hosting scene
  42983. * @returns the sphere mesh
  42984. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42985. */
  42986. static CreateSphere(name: string, options: {
  42987. segments?: number;
  42988. diameter?: number;
  42989. diameterX?: number;
  42990. diameterY?: number;
  42991. diameterZ?: number;
  42992. arc?: number;
  42993. slice?: number;
  42994. sideOrientation?: number;
  42995. frontUVs?: Vector4;
  42996. backUVs?: Vector4;
  42997. updatable?: boolean;
  42998. }, scene: any): Mesh;
  42999. }
  43000. }
  43001. declare module "babylonjs/Debug/physicsViewer" {
  43002. import { Nullable } from "babylonjs/types";
  43003. import { Scene } from "babylonjs/scene";
  43004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43005. import { Mesh } from "babylonjs/Meshes/mesh";
  43006. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43007. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43008. /**
  43009. * Used to show the physics impostor around the specific mesh
  43010. */
  43011. export class PhysicsViewer {
  43012. /** @hidden */
  43013. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43014. /** @hidden */
  43015. protected _meshes: Array<Nullable<AbstractMesh>>;
  43016. /** @hidden */
  43017. protected _scene: Nullable<Scene>;
  43018. /** @hidden */
  43019. protected _numMeshes: number;
  43020. /** @hidden */
  43021. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43022. private _renderFunction;
  43023. private _utilityLayer;
  43024. private _debugBoxMesh;
  43025. private _debugSphereMesh;
  43026. private _debugCylinderMesh;
  43027. private _debugMaterial;
  43028. private _debugMeshMeshes;
  43029. /**
  43030. * Creates a new PhysicsViewer
  43031. * @param scene defines the hosting scene
  43032. */
  43033. constructor(scene: Scene);
  43034. /** @hidden */
  43035. protected _updateDebugMeshes(): void;
  43036. /**
  43037. * Renders a specified physic impostor
  43038. * @param impostor defines the impostor to render
  43039. * @param targetMesh defines the mesh represented by the impostor
  43040. * @returns the new debug mesh used to render the impostor
  43041. */
  43042. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43043. /**
  43044. * Hides a specified physic impostor
  43045. * @param impostor defines the impostor to hide
  43046. */
  43047. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43048. private _getDebugMaterial;
  43049. private _getDebugBoxMesh;
  43050. private _getDebugSphereMesh;
  43051. private _getDebugCylinderMesh;
  43052. private _getDebugMeshMesh;
  43053. private _getDebugMesh;
  43054. /** Releases all resources */
  43055. dispose(): void;
  43056. }
  43057. }
  43058. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43059. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43060. import { Nullable } from "babylonjs/types";
  43061. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43062. import { Scene } from "babylonjs/scene";
  43063. /**
  43064. * Class containing static functions to help procedurally build meshes
  43065. */
  43066. export class LinesBuilder {
  43067. /**
  43068. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43069. * * 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
  43070. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43071. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43072. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43073. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43074. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43075. * * 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
  43076. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43078. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43079. * @param name defines the name of the new line system
  43080. * @param options defines the options used to create the line system
  43081. * @param scene defines the hosting scene
  43082. * @returns a new line system mesh
  43083. */
  43084. static CreateLineSystem(name: string, options: {
  43085. lines: Vector3[][];
  43086. updatable?: boolean;
  43087. instance?: Nullable<LinesMesh>;
  43088. colors?: Nullable<Color4[][]>;
  43089. useVertexAlpha?: boolean;
  43090. }, scene: Nullable<Scene>): LinesMesh;
  43091. /**
  43092. * Creates a line mesh
  43093. * 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
  43094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43095. * * The parameter `points` is an array successive Vector3
  43096. * * 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
  43097. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43098. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43099. * * When updating an instance, remember that only point positions can change, not the number of points
  43100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43102. * @param name defines the name of the new line system
  43103. * @param options defines the options used to create the line system
  43104. * @param scene defines the hosting scene
  43105. * @returns a new line mesh
  43106. */
  43107. static CreateLines(name: string, options: {
  43108. points: Vector3[];
  43109. updatable?: boolean;
  43110. instance?: Nullable<LinesMesh>;
  43111. colors?: Color4[];
  43112. useVertexAlpha?: boolean;
  43113. }, scene?: Nullable<Scene>): LinesMesh;
  43114. /**
  43115. * Creates a dashed line mesh
  43116. * * 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
  43117. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43118. * * The parameter `points` is an array successive Vector3
  43119. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43120. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43121. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43122. * * 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
  43123. * * When updating an instance, remember that only point positions can change, not the number of points
  43124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43125. * @param name defines the name of the mesh
  43126. * @param options defines the options used to create the mesh
  43127. * @param scene defines the hosting scene
  43128. * @returns the dashed line mesh
  43129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43130. */
  43131. static CreateDashedLines(name: string, options: {
  43132. points: Vector3[];
  43133. dashSize?: number;
  43134. gapSize?: number;
  43135. dashNb?: number;
  43136. updatable?: boolean;
  43137. instance?: LinesMesh;
  43138. }, scene?: Nullable<Scene>): LinesMesh;
  43139. }
  43140. }
  43141. declare module "babylonjs/Debug/rayHelper" {
  43142. import { Nullable } from "babylonjs/types";
  43143. import { Ray } from "babylonjs/Culling/ray";
  43144. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43145. import { Scene } from "babylonjs/scene";
  43146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43147. import "babylonjs/Meshes/Builders/linesBuilder";
  43148. /**
  43149. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43150. * in order to better appreciate the issue one might have.
  43151. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43152. */
  43153. export class RayHelper {
  43154. /**
  43155. * Defines the ray we are currently tryin to visualize.
  43156. */
  43157. ray: Nullable<Ray>;
  43158. private _renderPoints;
  43159. private _renderLine;
  43160. private _renderFunction;
  43161. private _scene;
  43162. private _updateToMeshFunction;
  43163. private _attachedToMesh;
  43164. private _meshSpaceDirection;
  43165. private _meshSpaceOrigin;
  43166. /**
  43167. * Helper function to create a colored helper in a scene in one line.
  43168. * @param ray Defines the ray we are currently tryin to visualize
  43169. * @param scene Defines the scene the ray is used in
  43170. * @param color Defines the color we want to see the ray in
  43171. * @returns The newly created ray helper.
  43172. */
  43173. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43174. /**
  43175. * Instantiate a new ray helper.
  43176. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43177. * in order to better appreciate the issue one might have.
  43178. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43179. * @param ray Defines the ray we are currently tryin to visualize
  43180. */
  43181. constructor(ray: Ray);
  43182. /**
  43183. * Shows the ray we are willing to debug.
  43184. * @param scene Defines the scene the ray needs to be rendered in
  43185. * @param color Defines the color the ray needs to be rendered in
  43186. */
  43187. show(scene: Scene, color?: Color3): void;
  43188. /**
  43189. * Hides the ray we are debugging.
  43190. */
  43191. hide(): void;
  43192. private _render;
  43193. /**
  43194. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43195. * @param mesh Defines the mesh we want the helper attached to
  43196. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43197. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43198. * @param length Defines the length of the ray
  43199. */
  43200. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43201. /**
  43202. * Detach the ray helper from the mesh it has previously been attached to.
  43203. */
  43204. detachFromMesh(): void;
  43205. private _updateToMesh;
  43206. /**
  43207. * Dispose the helper and release its associated resources.
  43208. */
  43209. dispose(): void;
  43210. }
  43211. }
  43212. declare module "babylonjs/Debug/skeletonViewer" {
  43213. import { Color3 } from "babylonjs/Maths/math";
  43214. import { Scene } from "babylonjs/scene";
  43215. import { Nullable } from "babylonjs/types";
  43216. import { Skeleton } from "babylonjs/Bones/skeleton";
  43217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43218. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43219. /**
  43220. * Class used to render a debug view of a given skeleton
  43221. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43222. */
  43223. export class SkeletonViewer {
  43224. /** defines the skeleton to render */
  43225. skeleton: Skeleton;
  43226. /** defines the mesh attached to the skeleton */
  43227. mesh: AbstractMesh;
  43228. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43229. autoUpdateBonesMatrices: boolean;
  43230. /** defines the rendering group id to use with the viewer */
  43231. renderingGroupId: number;
  43232. /** Gets or sets the color used to render the skeleton */
  43233. color: Color3;
  43234. private _scene;
  43235. private _debugLines;
  43236. private _debugMesh;
  43237. private _isEnabled;
  43238. private _renderFunction;
  43239. private _utilityLayer;
  43240. /**
  43241. * Returns the mesh used to render the bones
  43242. */
  43243. readonly debugMesh: Nullable<LinesMesh>;
  43244. /**
  43245. * Creates a new SkeletonViewer
  43246. * @param skeleton defines the skeleton to render
  43247. * @param mesh defines the mesh attached to the skeleton
  43248. * @param scene defines the hosting scene
  43249. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43250. * @param renderingGroupId defines the rendering group id to use with the viewer
  43251. */
  43252. constructor(
  43253. /** defines the skeleton to render */
  43254. skeleton: Skeleton,
  43255. /** defines the mesh attached to the skeleton */
  43256. mesh: AbstractMesh, scene: Scene,
  43257. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43258. autoUpdateBonesMatrices?: boolean,
  43259. /** defines the rendering group id to use with the viewer */
  43260. renderingGroupId?: number);
  43261. /** Gets or sets a boolean indicating if the viewer is enabled */
  43262. isEnabled: boolean;
  43263. private _getBonePosition;
  43264. private _getLinesForBonesWithLength;
  43265. private _getLinesForBonesNoLength;
  43266. /** Update the viewer to sync with current skeleton state */
  43267. update(): void;
  43268. /** Release associated resources */
  43269. dispose(): void;
  43270. }
  43271. }
  43272. declare module "babylonjs/Debug/index" {
  43273. export * from "babylonjs/Debug/axesViewer";
  43274. export * from "babylonjs/Debug/boneAxesViewer";
  43275. export * from "babylonjs/Debug/debugLayer";
  43276. export * from "babylonjs/Debug/physicsViewer";
  43277. export * from "babylonjs/Debug/rayHelper";
  43278. export * from "babylonjs/Debug/skeletonViewer";
  43279. }
  43280. declare module "babylonjs/Engines/nullEngine" {
  43281. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43282. import { Scene } from "babylonjs/scene";
  43283. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43284. import { Engine } from "babylonjs/Engines/engine";
  43285. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43286. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43288. import { Effect } from "babylonjs/Materials/effect";
  43289. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43291. /**
  43292. * Options to create the null engine
  43293. */
  43294. export class NullEngineOptions {
  43295. /**
  43296. * Render width (Default: 512)
  43297. */
  43298. renderWidth: number;
  43299. /**
  43300. * Render height (Default: 256)
  43301. */
  43302. renderHeight: number;
  43303. /**
  43304. * Texture size (Default: 512)
  43305. */
  43306. textureSize: number;
  43307. /**
  43308. * If delta time between frames should be constant
  43309. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43310. */
  43311. deterministicLockstep: boolean;
  43312. /**
  43313. * Maximum about of steps between frames (Default: 4)
  43314. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43315. */
  43316. lockstepMaxSteps: number;
  43317. }
  43318. /**
  43319. * The null engine class provides support for headless version of babylon.js.
  43320. * This can be used in server side scenario or for testing purposes
  43321. */
  43322. export class NullEngine extends Engine {
  43323. private _options;
  43324. /**
  43325. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43326. */
  43327. isDeterministicLockStep(): boolean;
  43328. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43329. getLockstepMaxSteps(): number;
  43330. /**
  43331. * Sets hardware scaling, used to save performance if needed
  43332. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43333. */
  43334. getHardwareScalingLevel(): number;
  43335. constructor(options?: NullEngineOptions);
  43336. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43337. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43338. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43339. getRenderWidth(useScreen?: boolean): number;
  43340. getRenderHeight(useScreen?: boolean): number;
  43341. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43342. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43343. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43344. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43345. bindSamplers(effect: Effect): void;
  43346. enableEffect(effect: Effect): void;
  43347. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43348. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43349. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43350. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43351. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43352. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43353. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43354. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43355. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43356. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43357. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43358. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43359. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43360. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43361. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43362. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43363. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43364. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43365. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43366. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43367. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43368. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43369. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43370. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43371. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43372. bindBuffers(vertexBuffers: {
  43373. [key: string]: VertexBuffer;
  43374. }, indexBuffer: DataBuffer, effect: Effect): void;
  43375. wipeCaches(bruteForce?: boolean): void;
  43376. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43377. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43378. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43379. /** @hidden */
  43380. _createTexture(): WebGLTexture;
  43381. /** @hidden */
  43382. _releaseTexture(texture: InternalTexture): void;
  43383. 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;
  43384. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43385. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43386. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43387. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43388. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43389. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43390. areAllEffectsReady(): boolean;
  43391. /**
  43392. * @hidden
  43393. * Get the current error code of the webGL context
  43394. * @returns the error code
  43395. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43396. */
  43397. getError(): number;
  43398. /** @hidden */
  43399. _getUnpackAlignement(): number;
  43400. /** @hidden */
  43401. _unpackFlipY(value: boolean): void;
  43402. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43403. /**
  43404. * Updates a dynamic vertex buffer.
  43405. * @param vertexBuffer the vertex buffer to update
  43406. * @param data the data used to update the vertex buffer
  43407. * @param byteOffset the byte offset of the data (optional)
  43408. * @param byteLength the byte length of the data (optional)
  43409. */
  43410. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43411. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43412. /** @hidden */
  43413. _bindTexture(channel: number, texture: InternalTexture): void;
  43414. /** @hidden */
  43415. _releaseBuffer(buffer: DataBuffer): boolean;
  43416. releaseEffects(): void;
  43417. displayLoadingUI(): void;
  43418. hideLoadingUI(): void;
  43419. /** @hidden */
  43420. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43421. /** @hidden */
  43422. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43423. /** @hidden */
  43424. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43425. /** @hidden */
  43426. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43427. }
  43428. }
  43429. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43430. import { Nullable, int } from "babylonjs/types";
  43431. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43432. /** @hidden */
  43433. export class _OcclusionDataStorage {
  43434. /** @hidden */
  43435. occlusionInternalRetryCounter: number;
  43436. /** @hidden */
  43437. isOcclusionQueryInProgress: boolean;
  43438. /** @hidden */
  43439. isOccluded: boolean;
  43440. /** @hidden */
  43441. occlusionRetryCount: number;
  43442. /** @hidden */
  43443. occlusionType: number;
  43444. /** @hidden */
  43445. occlusionQueryAlgorithmType: number;
  43446. }
  43447. module "babylonjs/Engines/engine" {
  43448. interface Engine {
  43449. /**
  43450. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43451. * @return the new query
  43452. */
  43453. createQuery(): WebGLQuery;
  43454. /**
  43455. * Delete and release a webGL query
  43456. * @param query defines the query to delete
  43457. * @return the current engine
  43458. */
  43459. deleteQuery(query: WebGLQuery): Engine;
  43460. /**
  43461. * Check if a given query has resolved and got its value
  43462. * @param query defines the query to check
  43463. * @returns true if the query got its value
  43464. */
  43465. isQueryResultAvailable(query: WebGLQuery): boolean;
  43466. /**
  43467. * Gets the value of a given query
  43468. * @param query defines the query to check
  43469. * @returns the value of the query
  43470. */
  43471. getQueryResult(query: WebGLQuery): number;
  43472. /**
  43473. * Initiates an occlusion query
  43474. * @param algorithmType defines the algorithm to use
  43475. * @param query defines the query to use
  43476. * @returns the current engine
  43477. * @see http://doc.babylonjs.com/features/occlusionquery
  43478. */
  43479. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43480. /**
  43481. * Ends an occlusion query
  43482. * @see http://doc.babylonjs.com/features/occlusionquery
  43483. * @param algorithmType defines the algorithm to use
  43484. * @returns the current engine
  43485. */
  43486. endOcclusionQuery(algorithmType: number): Engine;
  43487. /**
  43488. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43489. * Please note that only one query can be issued at a time
  43490. * @returns a time token used to track the time span
  43491. */
  43492. startTimeQuery(): Nullable<_TimeToken>;
  43493. /**
  43494. * Ends a time query
  43495. * @param token defines the token used to measure the time span
  43496. * @returns the time spent (in ns)
  43497. */
  43498. endTimeQuery(token: _TimeToken): int;
  43499. /** @hidden */
  43500. _currentNonTimestampToken: Nullable<_TimeToken>;
  43501. /** @hidden */
  43502. _createTimeQuery(): WebGLQuery;
  43503. /** @hidden */
  43504. _deleteTimeQuery(query: WebGLQuery): void;
  43505. /** @hidden */
  43506. _getGlAlgorithmType(algorithmType: number): number;
  43507. /** @hidden */
  43508. _getTimeQueryResult(query: WebGLQuery): any;
  43509. /** @hidden */
  43510. _getTimeQueryAvailability(query: WebGLQuery): any;
  43511. }
  43512. }
  43513. module "babylonjs/Meshes/abstractMesh" {
  43514. interface AbstractMesh {
  43515. /**
  43516. * Backing filed
  43517. * @hidden
  43518. */
  43519. __occlusionDataStorage: _OcclusionDataStorage;
  43520. /**
  43521. * Access property
  43522. * @hidden
  43523. */
  43524. _occlusionDataStorage: _OcclusionDataStorage;
  43525. /**
  43526. * 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.
  43527. * The default value is -1 which means don't break the query and wait till the result
  43528. * @see http://doc.babylonjs.com/features/occlusionquery
  43529. */
  43530. occlusionRetryCount: number;
  43531. /**
  43532. * 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:
  43533. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43534. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43535. * * 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.
  43536. * @see http://doc.babylonjs.com/features/occlusionquery
  43537. */
  43538. occlusionType: number;
  43539. /**
  43540. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43541. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43542. * * 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.
  43543. * @see http://doc.babylonjs.com/features/occlusionquery
  43544. */
  43545. occlusionQueryAlgorithmType: number;
  43546. /**
  43547. * 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
  43548. * @see http://doc.babylonjs.com/features/occlusionquery
  43549. */
  43550. isOccluded: boolean;
  43551. /**
  43552. * Flag to check the progress status of the query
  43553. * @see http://doc.babylonjs.com/features/occlusionquery
  43554. */
  43555. isOcclusionQueryInProgress: boolean;
  43556. }
  43557. }
  43558. }
  43559. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43560. import { Nullable } from "babylonjs/types";
  43561. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43562. /** @hidden */
  43563. export var _forceTransformFeedbackToBundle: boolean;
  43564. module "babylonjs/Engines/engine" {
  43565. interface Engine {
  43566. /**
  43567. * Creates a webGL transform feedback object
  43568. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43569. * @returns the webGL transform feedback object
  43570. */
  43571. createTransformFeedback(): WebGLTransformFeedback;
  43572. /**
  43573. * Delete a webGL transform feedback object
  43574. * @param value defines the webGL transform feedback object to delete
  43575. */
  43576. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43577. /**
  43578. * Bind a webGL transform feedback object to the webgl context
  43579. * @param value defines the webGL transform feedback object to bind
  43580. */
  43581. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43582. /**
  43583. * Begins a transform feedback operation
  43584. * @param usePoints defines if points or triangles must be used
  43585. */
  43586. beginTransformFeedback(usePoints: boolean): void;
  43587. /**
  43588. * Ends a transform feedback operation
  43589. */
  43590. endTransformFeedback(): void;
  43591. /**
  43592. * Specify the varyings to use with transform feedback
  43593. * @param program defines the associated webGL program
  43594. * @param value defines the list of strings representing the varying names
  43595. */
  43596. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43597. /**
  43598. * Bind a webGL buffer for a transform feedback operation
  43599. * @param value defines the webGL buffer to bind
  43600. */
  43601. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43602. }
  43603. }
  43604. }
  43605. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43606. import { Scene } from "babylonjs/scene";
  43607. import { Engine } from "babylonjs/Engines/engine";
  43608. import { Texture } from "babylonjs/Materials/Textures/texture";
  43609. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43610. import "babylonjs/Engines/Extensions/engine.multiRender";
  43611. /**
  43612. * Creation options of the multi render target texture.
  43613. */
  43614. export interface IMultiRenderTargetOptions {
  43615. /**
  43616. * Define if the texture needs to create mip maps after render.
  43617. */
  43618. generateMipMaps?: boolean;
  43619. /**
  43620. * Define the types of all the draw buffers we want to create
  43621. */
  43622. types?: number[];
  43623. /**
  43624. * Define the sampling modes of all the draw buffers we want to create
  43625. */
  43626. samplingModes?: number[];
  43627. /**
  43628. * Define if a depth buffer is required
  43629. */
  43630. generateDepthBuffer?: boolean;
  43631. /**
  43632. * Define if a stencil buffer is required
  43633. */
  43634. generateStencilBuffer?: boolean;
  43635. /**
  43636. * Define if a depth texture is required instead of a depth buffer
  43637. */
  43638. generateDepthTexture?: boolean;
  43639. /**
  43640. * Define the number of desired draw buffers
  43641. */
  43642. textureCount?: number;
  43643. /**
  43644. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43645. */
  43646. doNotChangeAspectRatio?: boolean;
  43647. /**
  43648. * Define the default type of the buffers we are creating
  43649. */
  43650. defaultType?: number;
  43651. }
  43652. /**
  43653. * A multi render target, like a render target provides the ability to render to a texture.
  43654. * Unlike the render target, it can render to several draw buffers in one draw.
  43655. * This is specially interesting in deferred rendering or for any effects requiring more than
  43656. * just one color from a single pass.
  43657. */
  43658. export class MultiRenderTarget extends RenderTargetTexture {
  43659. private _internalTextures;
  43660. private _textures;
  43661. private _multiRenderTargetOptions;
  43662. /**
  43663. * Get if draw buffers are currently supported by the used hardware and browser.
  43664. */
  43665. readonly isSupported: boolean;
  43666. /**
  43667. * Get the list of textures generated by the multi render target.
  43668. */
  43669. readonly textures: Texture[];
  43670. /**
  43671. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43672. */
  43673. readonly depthTexture: Texture;
  43674. /**
  43675. * Set the wrapping mode on U of all the textures we are rendering to.
  43676. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43677. */
  43678. wrapU: number;
  43679. /**
  43680. * Set the wrapping mode on V of all the textures we are rendering to.
  43681. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43682. */
  43683. wrapV: number;
  43684. /**
  43685. * Instantiate a new multi render target texture.
  43686. * A multi render target, like a render target provides the ability to render to a texture.
  43687. * Unlike the render target, it can render to several draw buffers in one draw.
  43688. * This is specially interesting in deferred rendering or for any effects requiring more than
  43689. * just one color from a single pass.
  43690. * @param name Define the name of the texture
  43691. * @param size Define the size of the buffers to render to
  43692. * @param count Define the number of target we are rendering into
  43693. * @param scene Define the scene the texture belongs to
  43694. * @param options Define the options used to create the multi render target
  43695. */
  43696. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43697. /** @hidden */
  43698. _rebuild(): void;
  43699. private _createInternalTextures;
  43700. private _createTextures;
  43701. /**
  43702. * Define the number of samples used if MSAA is enabled.
  43703. */
  43704. samples: number;
  43705. /**
  43706. * Resize all the textures in the multi render target.
  43707. * Be carrefull as it will recreate all the data in the new texture.
  43708. * @param size Define the new size
  43709. */
  43710. resize(size: any): void;
  43711. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43712. /**
  43713. * Dispose the render targets and their associated resources
  43714. */
  43715. dispose(): void;
  43716. /**
  43717. * Release all the underlying texture used as draw buffers.
  43718. */
  43719. releaseInternalTextures(): void;
  43720. }
  43721. }
  43722. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43723. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43724. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43725. import { Nullable } from "babylonjs/types";
  43726. module "babylonjs/Engines/engine" {
  43727. interface Engine {
  43728. /**
  43729. * Unbind a list of render target textures from the webGL context
  43730. * This is used only when drawBuffer extension or webGL2 are active
  43731. * @param textures defines the render target textures to unbind
  43732. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43733. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43734. */
  43735. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43736. /**
  43737. * Create a multi render target texture
  43738. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43739. * @param size defines the size of the texture
  43740. * @param options defines the creation options
  43741. * @returns the cube texture as an InternalTexture
  43742. */
  43743. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43744. /**
  43745. * Update the sample count for a given multiple render target texture
  43746. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43747. * @param textures defines the textures to update
  43748. * @param samples defines the sample count to set
  43749. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43750. */
  43751. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43752. }
  43753. }
  43754. }
  43755. declare module "babylonjs/Engines/Extensions/index" {
  43756. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43757. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43758. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43759. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43760. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43761. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43762. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43763. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43764. }
  43765. declare module "babylonjs/Engines/index" {
  43766. export * from "babylonjs/Engines/constants";
  43767. export * from "babylonjs/Engines/engine";
  43768. export * from "babylonjs/Engines/engineStore";
  43769. export * from "babylonjs/Engines/nullEngine";
  43770. export * from "babylonjs/Engines/Extensions/index";
  43771. export * from "babylonjs/Engines/IPipelineContext";
  43772. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43773. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43774. }
  43775. declare module "babylonjs/Events/clipboardEvents" {
  43776. /**
  43777. * Gather the list of clipboard event types as constants.
  43778. */
  43779. export class ClipboardEventTypes {
  43780. /**
  43781. * The clipboard event is fired when a copy command is active (pressed).
  43782. */
  43783. static readonly COPY: number;
  43784. /**
  43785. * The clipboard event is fired when a cut command is active (pressed).
  43786. */
  43787. static readonly CUT: number;
  43788. /**
  43789. * The clipboard event is fired when a paste command is active (pressed).
  43790. */
  43791. static readonly PASTE: number;
  43792. }
  43793. /**
  43794. * This class is used to store clipboard related info for the onClipboardObservable event.
  43795. */
  43796. export class ClipboardInfo {
  43797. /**
  43798. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43799. */
  43800. type: number;
  43801. /**
  43802. * Defines the related dom event
  43803. */
  43804. event: ClipboardEvent;
  43805. /**
  43806. *Creates an instance of ClipboardInfo.
  43807. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43808. * @param event Defines the related dom event
  43809. */
  43810. constructor(
  43811. /**
  43812. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43813. */
  43814. type: number,
  43815. /**
  43816. * Defines the related dom event
  43817. */
  43818. event: ClipboardEvent);
  43819. /**
  43820. * Get the clipboard event's type from the keycode.
  43821. * @param keyCode Defines the keyCode for the current keyboard event.
  43822. * @return {number}
  43823. */
  43824. static GetTypeFromCharacter(keyCode: number): number;
  43825. }
  43826. }
  43827. declare module "babylonjs/Events/index" {
  43828. export * from "babylonjs/Events/keyboardEvents";
  43829. export * from "babylonjs/Events/pointerEvents";
  43830. export * from "babylonjs/Events/clipboardEvents";
  43831. }
  43832. declare module "babylonjs/Loading/sceneLoader" {
  43833. import { Observable } from "babylonjs/Misc/observable";
  43834. import { Nullable } from "babylonjs/types";
  43835. import { Scene } from "babylonjs/scene";
  43836. import { Engine } from "babylonjs/Engines/engine";
  43837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43838. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43839. import { AssetContainer } from "babylonjs/assetContainer";
  43840. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43841. import { Skeleton } from "babylonjs/Bones/skeleton";
  43842. /**
  43843. * Class used to represent data loading progression
  43844. */
  43845. export class SceneLoaderProgressEvent {
  43846. /** defines if data length to load can be evaluated */
  43847. readonly lengthComputable: boolean;
  43848. /** defines the loaded data length */
  43849. readonly loaded: number;
  43850. /** defines the data length to load */
  43851. readonly total: number;
  43852. /**
  43853. * Create a new progress event
  43854. * @param lengthComputable defines if data length to load can be evaluated
  43855. * @param loaded defines the loaded data length
  43856. * @param total defines the data length to load
  43857. */
  43858. constructor(
  43859. /** defines if data length to load can be evaluated */
  43860. lengthComputable: boolean,
  43861. /** defines the loaded data length */
  43862. loaded: number,
  43863. /** defines the data length to load */
  43864. total: number);
  43865. /**
  43866. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43867. * @param event defines the source event
  43868. * @returns a new SceneLoaderProgressEvent
  43869. */
  43870. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43871. }
  43872. /**
  43873. * Interface used by SceneLoader plugins to define supported file extensions
  43874. */
  43875. export interface ISceneLoaderPluginExtensions {
  43876. /**
  43877. * Defines the list of supported extensions
  43878. */
  43879. [extension: string]: {
  43880. isBinary: boolean;
  43881. };
  43882. }
  43883. /**
  43884. * Interface used by SceneLoader plugin factory
  43885. */
  43886. export interface ISceneLoaderPluginFactory {
  43887. /**
  43888. * Defines the name of the factory
  43889. */
  43890. name: string;
  43891. /**
  43892. * Function called to create a new plugin
  43893. * @return the new plugin
  43894. */
  43895. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43896. /**
  43897. * Boolean indicating if the plugin can direct load specific data
  43898. */
  43899. canDirectLoad?: (data: string) => boolean;
  43900. }
  43901. /**
  43902. * Interface used to define a SceneLoader plugin
  43903. */
  43904. export interface ISceneLoaderPlugin {
  43905. /**
  43906. * The friendly name of this plugin.
  43907. */
  43908. name: string;
  43909. /**
  43910. * The file extensions supported by this plugin.
  43911. */
  43912. extensions: string | ISceneLoaderPluginExtensions;
  43913. /**
  43914. * Import meshes into a scene.
  43915. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43916. * @param scene The scene to import into
  43917. * @param data The data to import
  43918. * @param rootUrl The root url for scene and resources
  43919. * @param meshes The meshes array to import into
  43920. * @param particleSystems The particle systems array to import into
  43921. * @param skeletons The skeletons array to import into
  43922. * @param onError The callback when import fails
  43923. * @returns True if successful or false otherwise
  43924. */
  43925. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43926. /**
  43927. * Load into a scene.
  43928. * @param scene The scene to load into
  43929. * @param data The data to import
  43930. * @param rootUrl The root url for scene and resources
  43931. * @param onError The callback when import fails
  43932. * @returns true if successful or false otherwise
  43933. */
  43934. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43935. /**
  43936. * The callback that returns true if the data can be directly loaded.
  43937. */
  43938. canDirectLoad?: (data: string) => boolean;
  43939. /**
  43940. * The callback that allows custom handling of the root url based on the response url.
  43941. */
  43942. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43943. /**
  43944. * Load into an asset container.
  43945. * @param scene The scene to load into
  43946. * @param data The data to import
  43947. * @param rootUrl The root url for scene and resources
  43948. * @param onError The callback when import fails
  43949. * @returns The loaded asset container
  43950. */
  43951. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43952. }
  43953. /**
  43954. * Interface used to define an async SceneLoader plugin
  43955. */
  43956. export interface ISceneLoaderPluginAsync {
  43957. /**
  43958. * The friendly name of this plugin.
  43959. */
  43960. name: string;
  43961. /**
  43962. * The file extensions supported by this plugin.
  43963. */
  43964. extensions: string | ISceneLoaderPluginExtensions;
  43965. /**
  43966. * Import meshes into a scene.
  43967. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43968. * @param scene The scene to import into
  43969. * @param data The data to import
  43970. * @param rootUrl The root url for scene and resources
  43971. * @param onProgress The callback when the load progresses
  43972. * @param fileName Defines the name of the file to load
  43973. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43974. */
  43975. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43976. meshes: AbstractMesh[];
  43977. particleSystems: IParticleSystem[];
  43978. skeletons: Skeleton[];
  43979. animationGroups: AnimationGroup[];
  43980. }>;
  43981. /**
  43982. * Load into a scene.
  43983. * @param scene The scene to load into
  43984. * @param data The data to import
  43985. * @param rootUrl The root url for scene and resources
  43986. * @param onProgress The callback when the load progresses
  43987. * @param fileName Defines the name of the file to load
  43988. * @returns Nothing
  43989. */
  43990. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43991. /**
  43992. * The callback that returns true if the data can be directly loaded.
  43993. */
  43994. canDirectLoad?: (data: string) => boolean;
  43995. /**
  43996. * The callback that allows custom handling of the root url based on the response url.
  43997. */
  43998. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43999. /**
  44000. * Load into an asset container.
  44001. * @param scene The scene to load into
  44002. * @param data The data to import
  44003. * @param rootUrl The root url for scene and resources
  44004. * @param onProgress The callback when the load progresses
  44005. * @param fileName Defines the name of the file to load
  44006. * @returns The loaded asset container
  44007. */
  44008. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44009. }
  44010. /**
  44011. * Class used to load scene from various file formats using registered plugins
  44012. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44013. */
  44014. export class SceneLoader {
  44015. /**
  44016. * No logging while loading
  44017. */
  44018. static readonly NO_LOGGING: number;
  44019. /**
  44020. * Minimal logging while loading
  44021. */
  44022. static readonly MINIMAL_LOGGING: number;
  44023. /**
  44024. * Summary logging while loading
  44025. */
  44026. static readonly SUMMARY_LOGGING: number;
  44027. /**
  44028. * Detailled logging while loading
  44029. */
  44030. static readonly DETAILED_LOGGING: number;
  44031. /**
  44032. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44033. */
  44034. static ForceFullSceneLoadingForIncremental: boolean;
  44035. /**
  44036. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44037. */
  44038. static ShowLoadingScreen: boolean;
  44039. /**
  44040. * Defines the current logging level (while loading the scene)
  44041. * @ignorenaming
  44042. */
  44043. static loggingLevel: number;
  44044. /**
  44045. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44046. */
  44047. static CleanBoneMatrixWeights: boolean;
  44048. /**
  44049. * Event raised when a plugin is used to load a scene
  44050. */
  44051. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44052. private static _registeredPlugins;
  44053. private static _getDefaultPlugin;
  44054. private static _getPluginForExtension;
  44055. private static _getPluginForDirectLoad;
  44056. private static _getPluginForFilename;
  44057. private static _getDirectLoad;
  44058. private static _loadData;
  44059. private static _getFileInfo;
  44060. /**
  44061. * Gets a plugin that can load the given extension
  44062. * @param extension defines the extension to load
  44063. * @returns a plugin or null if none works
  44064. */
  44065. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44066. /**
  44067. * Gets a boolean indicating that the given extension can be loaded
  44068. * @param extension defines the extension to load
  44069. * @returns true if the extension is supported
  44070. */
  44071. static IsPluginForExtensionAvailable(extension: string): boolean;
  44072. /**
  44073. * Adds a new plugin to the list of registered plugins
  44074. * @param plugin defines the plugin to add
  44075. */
  44076. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44077. /**
  44078. * Import meshes into a scene
  44079. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44080. * @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)
  44081. * @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)
  44082. * @param scene the instance of BABYLON.Scene to append to
  44083. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44084. * @param onProgress a callback with a progress event for each file being loaded
  44085. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44086. * @param pluginExtension the extension used to determine the plugin
  44087. * @returns The loaded plugin
  44088. */
  44089. 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>;
  44090. /**
  44091. * Import meshes into a scene
  44092. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44093. * @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)
  44094. * @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)
  44095. * @param scene the instance of BABYLON.Scene to append to
  44096. * @param onProgress a callback with a progress event for each file being loaded
  44097. * @param pluginExtension the extension used to determine the plugin
  44098. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44099. */
  44100. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44101. meshes: AbstractMesh[];
  44102. particleSystems: IParticleSystem[];
  44103. skeletons: Skeleton[];
  44104. animationGroups: AnimationGroup[];
  44105. }>;
  44106. /**
  44107. * Load a scene
  44108. * @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)
  44109. * @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)
  44110. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44111. * @param onSuccess a callback with the scene when import succeeds
  44112. * @param onProgress a callback with a progress event for each file being loaded
  44113. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44114. * @param pluginExtension the extension used to determine the plugin
  44115. * @returns The loaded plugin
  44116. */
  44117. 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>;
  44118. /**
  44119. * Load a scene
  44120. * @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)
  44121. * @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)
  44122. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44123. * @param onProgress a callback with a progress event for each file being loaded
  44124. * @param pluginExtension the extension used to determine the plugin
  44125. * @returns The loaded scene
  44126. */
  44127. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44128. /**
  44129. * Append a scene
  44130. * @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)
  44131. * @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)
  44132. * @param scene is the instance of BABYLON.Scene to append to
  44133. * @param onSuccess a callback with the scene when import succeeds
  44134. * @param onProgress a callback with a progress event for each file being loaded
  44135. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44136. * @param pluginExtension the extension used to determine the plugin
  44137. * @returns The loaded plugin
  44138. */
  44139. 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>;
  44140. /**
  44141. * Append a scene
  44142. * @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)
  44143. * @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)
  44144. * @param scene is the instance of BABYLON.Scene to append to
  44145. * @param onProgress a callback with a progress event for each file being loaded
  44146. * @param pluginExtension the extension used to determine the plugin
  44147. * @returns The given scene
  44148. */
  44149. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44150. /**
  44151. * Load a scene into an asset container
  44152. * @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)
  44153. * @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)
  44154. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44155. * @param onSuccess a callback with the scene when import succeeds
  44156. * @param onProgress a callback with a progress event for each file being loaded
  44157. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44158. * @param pluginExtension the extension used to determine the plugin
  44159. * @returns The loaded plugin
  44160. */
  44161. 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>;
  44162. /**
  44163. * Load a scene into an asset container
  44164. * @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)
  44165. * @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)
  44166. * @param scene is the instance of Scene to append to
  44167. * @param onProgress a callback with a progress event for each file being loaded
  44168. * @param pluginExtension the extension used to determine the plugin
  44169. * @returns The loaded asset container
  44170. */
  44171. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44172. }
  44173. }
  44174. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44175. import { Scene } from "babylonjs/scene";
  44176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44177. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44178. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44179. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44180. /**
  44181. * Google Daydream controller
  44182. */
  44183. export class DaydreamController extends WebVRController {
  44184. /**
  44185. * Base Url for the controller model.
  44186. */
  44187. static MODEL_BASE_URL: string;
  44188. /**
  44189. * File name for the controller model.
  44190. */
  44191. static MODEL_FILENAME: string;
  44192. /**
  44193. * Gamepad Id prefix used to identify Daydream Controller.
  44194. */
  44195. static readonly GAMEPAD_ID_PREFIX: string;
  44196. /**
  44197. * Creates a new DaydreamController from a gamepad
  44198. * @param vrGamepad the gamepad that the controller should be created from
  44199. */
  44200. constructor(vrGamepad: any);
  44201. /**
  44202. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44203. * @param scene scene in which to add meshes
  44204. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44205. */
  44206. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44207. /**
  44208. * Called once for each button that changed state since the last frame
  44209. * @param buttonIdx Which button index changed
  44210. * @param state New state of the button
  44211. * @param changes Which properties on the state changed since last frame
  44212. */
  44213. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44214. }
  44215. }
  44216. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44217. import { Scene } from "babylonjs/scene";
  44218. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44219. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44220. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44221. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44222. /**
  44223. * Gear VR Controller
  44224. */
  44225. export class GearVRController extends WebVRController {
  44226. /**
  44227. * Base Url for the controller model.
  44228. */
  44229. static MODEL_BASE_URL: string;
  44230. /**
  44231. * File name for the controller model.
  44232. */
  44233. static MODEL_FILENAME: string;
  44234. /**
  44235. * Gamepad Id prefix used to identify this controller.
  44236. */
  44237. static readonly GAMEPAD_ID_PREFIX: string;
  44238. private readonly _buttonIndexToObservableNameMap;
  44239. /**
  44240. * Creates a new GearVRController from a gamepad
  44241. * @param vrGamepad the gamepad that the controller should be created from
  44242. */
  44243. constructor(vrGamepad: any);
  44244. /**
  44245. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44246. * @param scene scene in which to add meshes
  44247. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44248. */
  44249. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44250. /**
  44251. * Called once for each button that changed state since the last frame
  44252. * @param buttonIdx Which button index changed
  44253. * @param state New state of the button
  44254. * @param changes Which properties on the state changed since last frame
  44255. */
  44256. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44257. }
  44258. }
  44259. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44260. import { Scene } from "babylonjs/scene";
  44261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44262. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44263. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44264. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44265. /**
  44266. * Generic Controller
  44267. */
  44268. export class GenericController extends WebVRController {
  44269. /**
  44270. * Base Url for the controller model.
  44271. */
  44272. static readonly MODEL_BASE_URL: string;
  44273. /**
  44274. * File name for the controller model.
  44275. */
  44276. static readonly MODEL_FILENAME: string;
  44277. /**
  44278. * Creates a new GenericController from a gamepad
  44279. * @param vrGamepad the gamepad that the controller should be created from
  44280. */
  44281. constructor(vrGamepad: any);
  44282. /**
  44283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44284. * @param scene scene in which to add meshes
  44285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44286. */
  44287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44288. /**
  44289. * Called once for each button that changed state since the last frame
  44290. * @param buttonIdx Which button index changed
  44291. * @param state New state of the button
  44292. * @param changes Which properties on the state changed since last frame
  44293. */
  44294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44295. }
  44296. }
  44297. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44298. import { Observable } from "babylonjs/Misc/observable";
  44299. import { Scene } from "babylonjs/scene";
  44300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44301. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44302. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44303. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44304. /**
  44305. * Oculus Touch Controller
  44306. */
  44307. export class OculusTouchController extends WebVRController {
  44308. /**
  44309. * Base Url for the controller model.
  44310. */
  44311. static MODEL_BASE_URL: string;
  44312. /**
  44313. * File name for the left controller model.
  44314. */
  44315. static MODEL_LEFT_FILENAME: string;
  44316. /**
  44317. * File name for the right controller model.
  44318. */
  44319. static MODEL_RIGHT_FILENAME: string;
  44320. /**
  44321. * Fired when the secondary trigger on this controller is modified
  44322. */
  44323. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44324. /**
  44325. * Fired when the thumb rest on this controller is modified
  44326. */
  44327. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44328. /**
  44329. * Creates a new OculusTouchController from a gamepad
  44330. * @param vrGamepad the gamepad that the controller should be created from
  44331. */
  44332. constructor(vrGamepad: any);
  44333. /**
  44334. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44335. * @param scene scene in which to add meshes
  44336. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44337. */
  44338. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44339. /**
  44340. * Fired when the A button on this controller is modified
  44341. */
  44342. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44343. /**
  44344. * Fired when the B button on this controller is modified
  44345. */
  44346. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44347. /**
  44348. * Fired when the X button on this controller is modified
  44349. */
  44350. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44351. /**
  44352. * Fired when the Y button on this controller is modified
  44353. */
  44354. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44355. /**
  44356. * Called once for each button that changed state since the last frame
  44357. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44358. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44359. * 2) secondary trigger (same)
  44360. * 3) A (right) X (left), touch, pressed = value
  44361. * 4) B / Y
  44362. * 5) thumb rest
  44363. * @param buttonIdx Which button index changed
  44364. * @param state New state of the button
  44365. * @param changes Which properties on the state changed since last frame
  44366. */
  44367. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44368. }
  44369. }
  44370. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44371. import { Scene } from "babylonjs/scene";
  44372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44373. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44374. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44375. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44376. import { Observable } from "babylonjs/Misc/observable";
  44377. /**
  44378. * Vive Controller
  44379. */
  44380. export class ViveController extends WebVRController {
  44381. /**
  44382. * Base Url for the controller model.
  44383. */
  44384. static MODEL_BASE_URL: string;
  44385. /**
  44386. * File name for the controller model.
  44387. */
  44388. static MODEL_FILENAME: string;
  44389. /**
  44390. * Creates a new ViveController from a gamepad
  44391. * @param vrGamepad the gamepad that the controller should be created from
  44392. */
  44393. constructor(vrGamepad: any);
  44394. /**
  44395. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44396. * @param scene scene in which to add meshes
  44397. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44398. */
  44399. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44400. /**
  44401. * Fired when the left button on this controller is modified
  44402. */
  44403. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44404. /**
  44405. * Fired when the right button on this controller is modified
  44406. */
  44407. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44408. /**
  44409. * Fired when the menu button on this controller is modified
  44410. */
  44411. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44412. /**
  44413. * Called once for each button that changed state since the last frame
  44414. * Vive mapping:
  44415. * 0: touchpad
  44416. * 1: trigger
  44417. * 2: left AND right buttons
  44418. * 3: menu button
  44419. * @param buttonIdx Which button index changed
  44420. * @param state New state of the button
  44421. * @param changes Which properties on the state changed since last frame
  44422. */
  44423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44424. }
  44425. }
  44426. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44427. import { Observable } from "babylonjs/Misc/observable";
  44428. import { Scene } from "babylonjs/scene";
  44429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44430. import { Ray } from "babylonjs/Culling/ray";
  44431. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44432. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44433. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44434. /**
  44435. * Defines the WindowsMotionController object that the state of the windows motion controller
  44436. */
  44437. export class WindowsMotionController extends WebVRController {
  44438. /**
  44439. * The base url used to load the left and right controller models
  44440. */
  44441. static MODEL_BASE_URL: string;
  44442. /**
  44443. * The name of the left controller model file
  44444. */
  44445. static MODEL_LEFT_FILENAME: string;
  44446. /**
  44447. * The name of the right controller model file
  44448. */
  44449. static MODEL_RIGHT_FILENAME: string;
  44450. /**
  44451. * The controller name prefix for this controller type
  44452. */
  44453. static readonly GAMEPAD_ID_PREFIX: string;
  44454. /**
  44455. * The controller id pattern for this controller type
  44456. */
  44457. private static readonly GAMEPAD_ID_PATTERN;
  44458. private _loadedMeshInfo;
  44459. private readonly _mapping;
  44460. /**
  44461. * Fired when the trackpad on this controller is clicked
  44462. */
  44463. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44464. /**
  44465. * Fired when the trackpad on this controller is modified
  44466. */
  44467. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44468. /**
  44469. * The current x and y values of this controller's trackpad
  44470. */
  44471. trackpad: StickValues;
  44472. /**
  44473. * Creates a new WindowsMotionController from a gamepad
  44474. * @param vrGamepad the gamepad that the controller should be created from
  44475. */
  44476. constructor(vrGamepad: any);
  44477. /**
  44478. * Fired when the trigger on this controller is modified
  44479. */
  44480. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44481. /**
  44482. * Fired when the menu button on this controller is modified
  44483. */
  44484. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44485. /**
  44486. * Fired when the grip button on this controller is modified
  44487. */
  44488. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44489. /**
  44490. * Fired when the thumbstick button on this controller is modified
  44491. */
  44492. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44493. /**
  44494. * Fired when the touchpad button on this controller is modified
  44495. */
  44496. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44497. /**
  44498. * Fired when the touchpad values on this controller are modified
  44499. */
  44500. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44501. private _updateTrackpad;
  44502. /**
  44503. * Called once per frame by the engine.
  44504. */
  44505. update(): void;
  44506. /**
  44507. * Called once for each button that changed state since the last frame
  44508. * @param buttonIdx Which button index changed
  44509. * @param state New state of the button
  44510. * @param changes Which properties on the state changed since last frame
  44511. */
  44512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44513. /**
  44514. * Moves the buttons on the controller mesh based on their current state
  44515. * @param buttonName the name of the button to move
  44516. * @param buttonValue the value of the button which determines the buttons new position
  44517. */
  44518. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44519. /**
  44520. * Moves the axis on the controller mesh based on its current state
  44521. * @param axis the index of the axis
  44522. * @param axisValue the value of the axis which determines the meshes new position
  44523. * @hidden
  44524. */
  44525. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44526. /**
  44527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44528. * @param scene scene in which to add meshes
  44529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44530. */
  44531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44532. /**
  44533. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44534. * can be transformed by button presses and axes values, based on this._mapping.
  44535. *
  44536. * @param scene scene in which the meshes exist
  44537. * @param meshes list of meshes that make up the controller model to process
  44538. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44539. */
  44540. private processModel;
  44541. private createMeshInfo;
  44542. /**
  44543. * Gets the ray of the controller in the direction the controller is pointing
  44544. * @param length the length the resulting ray should be
  44545. * @returns a ray in the direction the controller is pointing
  44546. */
  44547. getForwardRay(length?: number): Ray;
  44548. /**
  44549. * Disposes of the controller
  44550. */
  44551. dispose(): void;
  44552. }
  44553. }
  44554. declare module "babylonjs/Gamepads/Controllers/index" {
  44555. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44556. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44557. export * from "babylonjs/Gamepads/Controllers/genericController";
  44558. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44559. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44560. export * from "babylonjs/Gamepads/Controllers/viveController";
  44561. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44562. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44563. }
  44564. declare module "babylonjs/Gamepads/index" {
  44565. export * from "babylonjs/Gamepads/Controllers/index";
  44566. export * from "babylonjs/Gamepads/gamepad";
  44567. export * from "babylonjs/Gamepads/gamepadManager";
  44568. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44569. export * from "babylonjs/Gamepads/xboxGamepad";
  44570. }
  44571. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44572. import { Scene } from "babylonjs/scene";
  44573. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44574. import { Mesh } from "babylonjs/Meshes/mesh";
  44575. import { Nullable } from "babylonjs/types";
  44576. /**
  44577. * Class containing static functions to help procedurally build meshes
  44578. */
  44579. export class PolyhedronBuilder {
  44580. /**
  44581. * Creates a polyhedron mesh
  44582. * * 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
  44583. * * The parameter `size` (positive float, default 1) sets the polygon size
  44584. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44585. * * 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`
  44586. * * 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
  44587. * * 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)`)
  44588. * * 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
  44589. * * 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
  44590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44593. * @param name defines the name of the mesh
  44594. * @param options defines the options used to create the mesh
  44595. * @param scene defines the hosting scene
  44596. * @returns the polyhedron mesh
  44597. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44598. */
  44599. static CreatePolyhedron(name: string, options: {
  44600. type?: number;
  44601. size?: number;
  44602. sizeX?: number;
  44603. sizeY?: number;
  44604. sizeZ?: number;
  44605. custom?: any;
  44606. faceUV?: Vector4[];
  44607. faceColors?: Color4[];
  44608. flat?: boolean;
  44609. updatable?: boolean;
  44610. sideOrientation?: number;
  44611. frontUVs?: Vector4;
  44612. backUVs?: Vector4;
  44613. }, scene?: Nullable<Scene>): Mesh;
  44614. }
  44615. }
  44616. declare module "babylonjs/Gizmos/scaleGizmo" {
  44617. import { Observable } from "babylonjs/Misc/observable";
  44618. import { Nullable } from "babylonjs/types";
  44619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44620. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44621. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44622. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44623. /**
  44624. * Gizmo that enables scaling a mesh along 3 axis
  44625. */
  44626. export class ScaleGizmo extends Gizmo {
  44627. /**
  44628. * Internal gizmo used for interactions on the x axis
  44629. */
  44630. xGizmo: AxisScaleGizmo;
  44631. /**
  44632. * Internal gizmo used for interactions on the y axis
  44633. */
  44634. yGizmo: AxisScaleGizmo;
  44635. /**
  44636. * Internal gizmo used for interactions on the z axis
  44637. */
  44638. zGizmo: AxisScaleGizmo;
  44639. /**
  44640. * Internal gizmo used to scale all axis equally
  44641. */
  44642. uniformScaleGizmo: AxisScaleGizmo;
  44643. private _meshAttached;
  44644. private _updateGizmoRotationToMatchAttachedMesh;
  44645. private _snapDistance;
  44646. private _scaleRatio;
  44647. private _uniformScalingMesh;
  44648. private _octahedron;
  44649. /** Fires an event when any of it's sub gizmos are dragged */
  44650. onDragStartObservable: Observable<{}>;
  44651. /** Fires an event when any of it's sub gizmos are released from dragging */
  44652. onDragEndObservable: Observable<{}>;
  44653. attachedMesh: Nullable<AbstractMesh>;
  44654. /**
  44655. * Creates a ScaleGizmo
  44656. * @param gizmoLayer The utility layer the gizmo will be added to
  44657. */
  44658. constructor(gizmoLayer?: UtilityLayerRenderer);
  44659. updateGizmoRotationToMatchAttachedMesh: boolean;
  44660. /**
  44661. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44662. */
  44663. snapDistance: number;
  44664. /**
  44665. * Ratio for the scale of the gizmo (Default: 1)
  44666. */
  44667. scaleRatio: number;
  44668. /**
  44669. * Disposes of the gizmo
  44670. */
  44671. dispose(): void;
  44672. }
  44673. }
  44674. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44675. import { Observable } from "babylonjs/Misc/observable";
  44676. import { Nullable } from "babylonjs/types";
  44677. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44679. import { Mesh } from "babylonjs/Meshes/mesh";
  44680. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44681. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44682. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44683. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44684. /**
  44685. * Single axis scale gizmo
  44686. */
  44687. export class AxisScaleGizmo extends Gizmo {
  44688. /**
  44689. * Drag behavior responsible for the gizmos dragging interactions
  44690. */
  44691. dragBehavior: PointerDragBehavior;
  44692. private _pointerObserver;
  44693. /**
  44694. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44695. */
  44696. snapDistance: number;
  44697. /**
  44698. * Event that fires each time the gizmo snaps to a new location.
  44699. * * snapDistance is the the change in distance
  44700. */
  44701. onSnapObservable: Observable<{
  44702. snapDistance: number;
  44703. }>;
  44704. /**
  44705. * If the scaling operation should be done on all axis (default: false)
  44706. */
  44707. uniformScaling: boolean;
  44708. private _isEnabled;
  44709. private _parent;
  44710. private _arrow;
  44711. private _coloredMaterial;
  44712. private _hoverMaterial;
  44713. /**
  44714. * Creates an AxisScaleGizmo
  44715. * @param gizmoLayer The utility layer the gizmo will be added to
  44716. * @param dragAxis The axis which the gizmo will be able to scale on
  44717. * @param color The color of the gizmo
  44718. */
  44719. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44720. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44721. /**
  44722. * If the gizmo is enabled
  44723. */
  44724. isEnabled: boolean;
  44725. /**
  44726. * Disposes of the gizmo
  44727. */
  44728. dispose(): void;
  44729. /**
  44730. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44731. * @param mesh The mesh to replace the default mesh of the gizmo
  44732. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44733. */
  44734. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44735. }
  44736. }
  44737. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44738. import { Observable } from "babylonjs/Misc/observable";
  44739. import { Nullable } from "babylonjs/types";
  44740. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44742. import { Mesh } from "babylonjs/Meshes/mesh";
  44743. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44744. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44745. import "babylonjs/Meshes/Builders/boxBuilder";
  44746. /**
  44747. * Bounding box gizmo
  44748. */
  44749. export class BoundingBoxGizmo extends Gizmo {
  44750. private _lineBoundingBox;
  44751. private _rotateSpheresParent;
  44752. private _scaleBoxesParent;
  44753. private _boundingDimensions;
  44754. private _renderObserver;
  44755. private _pointerObserver;
  44756. private _scaleDragSpeed;
  44757. private _tmpQuaternion;
  44758. private _tmpVector;
  44759. private _tmpRotationMatrix;
  44760. /**
  44761. * 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)
  44762. */
  44763. ignoreChildren: boolean;
  44764. /**
  44765. * 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)
  44766. */
  44767. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44768. /**
  44769. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44770. */
  44771. rotationSphereSize: number;
  44772. /**
  44773. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44774. */
  44775. scaleBoxSize: number;
  44776. /**
  44777. * 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)
  44778. */
  44779. fixedDragMeshScreenSize: boolean;
  44780. /**
  44781. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44782. */
  44783. fixedDragMeshScreenSizeDistanceFactor: number;
  44784. /**
  44785. * Fired when a rotation sphere or scale box is dragged
  44786. */
  44787. onDragStartObservable: Observable<{}>;
  44788. /**
  44789. * Fired when a scale box is dragged
  44790. */
  44791. onScaleBoxDragObservable: Observable<{}>;
  44792. /**
  44793. * Fired when a scale box drag is ended
  44794. */
  44795. onScaleBoxDragEndObservable: Observable<{}>;
  44796. /**
  44797. * Fired when a rotation sphere is dragged
  44798. */
  44799. onRotationSphereDragObservable: Observable<{}>;
  44800. /**
  44801. * Fired when a rotation sphere drag is ended
  44802. */
  44803. onRotationSphereDragEndObservable: Observable<{}>;
  44804. /**
  44805. * 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)
  44806. */
  44807. scalePivot: Nullable<Vector3>;
  44808. /**
  44809. * Mesh used as a pivot to rotate the attached mesh
  44810. */
  44811. private _anchorMesh;
  44812. private _existingMeshScale;
  44813. private _dragMesh;
  44814. private pointerDragBehavior;
  44815. private coloredMaterial;
  44816. private hoverColoredMaterial;
  44817. /**
  44818. * Sets the color of the bounding box gizmo
  44819. * @param color the color to set
  44820. */
  44821. setColor(color: Color3): void;
  44822. /**
  44823. * Creates an BoundingBoxGizmo
  44824. * @param gizmoLayer The utility layer the gizmo will be added to
  44825. * @param color The color of the gizmo
  44826. */
  44827. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44828. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44829. private _selectNode;
  44830. /**
  44831. * Updates the bounding box information for the Gizmo
  44832. */
  44833. updateBoundingBox(): void;
  44834. private _updateRotationSpheres;
  44835. private _updateScaleBoxes;
  44836. /**
  44837. * Enables rotation on the specified axis and disables rotation on the others
  44838. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44839. */
  44840. setEnabledRotationAxis(axis: string): void;
  44841. /**
  44842. * Enables/disables scaling
  44843. * @param enable if scaling should be enabled
  44844. */
  44845. setEnabledScaling(enable: boolean): void;
  44846. private _updateDummy;
  44847. /**
  44848. * Enables a pointer drag behavior on the bounding box of the gizmo
  44849. */
  44850. enableDragBehavior(): void;
  44851. /**
  44852. * Disposes of the gizmo
  44853. */
  44854. dispose(): void;
  44855. /**
  44856. * 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)
  44857. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44858. * @returns the bounding box mesh with the passed in mesh as a child
  44859. */
  44860. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44861. /**
  44862. * CustomMeshes are not supported by this gizmo
  44863. * @param mesh The mesh to replace the default mesh of the gizmo
  44864. */
  44865. setCustomMesh(mesh: Mesh): void;
  44866. }
  44867. }
  44868. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44869. import { Observable } from "babylonjs/Misc/observable";
  44870. import { Nullable } from "babylonjs/types";
  44871. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44873. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44874. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44875. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44876. import "babylonjs/Meshes/Builders/linesBuilder";
  44877. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44878. /**
  44879. * Single plane rotation gizmo
  44880. */
  44881. export class PlaneRotationGizmo extends Gizmo {
  44882. /**
  44883. * Drag behavior responsible for the gizmos dragging interactions
  44884. */
  44885. dragBehavior: PointerDragBehavior;
  44886. private _pointerObserver;
  44887. /**
  44888. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44889. */
  44890. snapDistance: number;
  44891. /**
  44892. * Event that fires each time the gizmo snaps to a new location.
  44893. * * snapDistance is the the change in distance
  44894. */
  44895. onSnapObservable: Observable<{
  44896. snapDistance: number;
  44897. }>;
  44898. private _isEnabled;
  44899. private _parent;
  44900. /**
  44901. * Creates a PlaneRotationGizmo
  44902. * @param gizmoLayer The utility layer the gizmo will be added to
  44903. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44904. * @param color The color of the gizmo
  44905. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44906. */
  44907. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44908. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44909. /**
  44910. * If the gizmo is enabled
  44911. */
  44912. isEnabled: boolean;
  44913. /**
  44914. * Disposes of the gizmo
  44915. */
  44916. dispose(): void;
  44917. }
  44918. }
  44919. declare module "babylonjs/Gizmos/rotationGizmo" {
  44920. import { Observable } from "babylonjs/Misc/observable";
  44921. import { Nullable } from "babylonjs/types";
  44922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44923. import { Mesh } from "babylonjs/Meshes/mesh";
  44924. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44925. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44926. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44927. /**
  44928. * Gizmo that enables rotating a mesh along 3 axis
  44929. */
  44930. export class RotationGizmo extends Gizmo {
  44931. /**
  44932. * Internal gizmo used for interactions on the x axis
  44933. */
  44934. xGizmo: PlaneRotationGizmo;
  44935. /**
  44936. * Internal gizmo used for interactions on the y axis
  44937. */
  44938. yGizmo: PlaneRotationGizmo;
  44939. /**
  44940. * Internal gizmo used for interactions on the z axis
  44941. */
  44942. zGizmo: PlaneRotationGizmo;
  44943. /** Fires an event when any of it's sub gizmos are dragged */
  44944. onDragStartObservable: Observable<{}>;
  44945. /** Fires an event when any of it's sub gizmos are released from dragging */
  44946. onDragEndObservable: Observable<{}>;
  44947. private _meshAttached;
  44948. attachedMesh: Nullable<AbstractMesh>;
  44949. /**
  44950. * Creates a RotationGizmo
  44951. * @param gizmoLayer The utility layer the gizmo will be added to
  44952. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44953. */
  44954. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44955. updateGizmoRotationToMatchAttachedMesh: boolean;
  44956. /**
  44957. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44958. */
  44959. snapDistance: number;
  44960. /**
  44961. * Ratio for the scale of the gizmo (Default: 1)
  44962. */
  44963. scaleRatio: number;
  44964. /**
  44965. * Disposes of the gizmo
  44966. */
  44967. dispose(): void;
  44968. /**
  44969. * CustomMeshes are not supported by this gizmo
  44970. * @param mesh The mesh to replace the default mesh of the gizmo
  44971. */
  44972. setCustomMesh(mesh: Mesh): void;
  44973. }
  44974. }
  44975. declare module "babylonjs/Gizmos/gizmoManager" {
  44976. import { Observable } from "babylonjs/Misc/observable";
  44977. import { Nullable } from "babylonjs/types";
  44978. import { Scene, IDisposable } from "babylonjs/scene";
  44979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44980. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44981. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44982. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44983. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44984. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44985. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44986. /**
  44987. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44988. */
  44989. export class GizmoManager implements IDisposable {
  44990. private scene;
  44991. /**
  44992. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44993. */
  44994. gizmos: {
  44995. positionGizmo: Nullable<PositionGizmo>;
  44996. rotationGizmo: Nullable<RotationGizmo>;
  44997. scaleGizmo: Nullable<ScaleGizmo>;
  44998. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44999. };
  45000. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45001. clearGizmoOnEmptyPointerEvent: boolean;
  45002. /** Fires an event when the manager is attached to a mesh */
  45003. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45004. private _gizmosEnabled;
  45005. private _pointerObserver;
  45006. private _attachedMesh;
  45007. private _boundingBoxColor;
  45008. private _defaultUtilityLayer;
  45009. private _defaultKeepDepthUtilityLayer;
  45010. /**
  45011. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45012. */
  45013. boundingBoxDragBehavior: SixDofDragBehavior;
  45014. /**
  45015. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45016. */
  45017. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45018. /**
  45019. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45020. */
  45021. usePointerToAttachGizmos: boolean;
  45022. /**
  45023. * Utility layer that the bounding box gizmo belongs to
  45024. */
  45025. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45026. /**
  45027. * Utility layer that all gizmos besides bounding box belong to
  45028. */
  45029. readonly utilityLayer: UtilityLayerRenderer;
  45030. /**
  45031. * Instatiates a gizmo manager
  45032. * @param scene the scene to overlay the gizmos on top of
  45033. */
  45034. constructor(scene: Scene);
  45035. /**
  45036. * Attaches a set of gizmos to the specified mesh
  45037. * @param mesh The mesh the gizmo's should be attached to
  45038. */
  45039. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45040. /**
  45041. * If the position gizmo is enabled
  45042. */
  45043. positionGizmoEnabled: boolean;
  45044. /**
  45045. * If the rotation gizmo is enabled
  45046. */
  45047. rotationGizmoEnabled: boolean;
  45048. /**
  45049. * If the scale gizmo is enabled
  45050. */
  45051. scaleGizmoEnabled: boolean;
  45052. /**
  45053. * If the boundingBox gizmo is enabled
  45054. */
  45055. boundingBoxGizmoEnabled: boolean;
  45056. /**
  45057. * Disposes of the gizmo manager
  45058. */
  45059. dispose(): void;
  45060. }
  45061. }
  45062. declare module "babylonjs/Lights/directionalLight" {
  45063. import { Camera } from "babylonjs/Cameras/camera";
  45064. import { Scene } from "babylonjs/scene";
  45065. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45067. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45068. import { Effect } from "babylonjs/Materials/effect";
  45069. /**
  45070. * A directional light is defined by a direction (what a surprise!).
  45071. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45072. * 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.
  45073. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45074. */
  45075. export class DirectionalLight extends ShadowLight {
  45076. private _shadowFrustumSize;
  45077. /**
  45078. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45079. */
  45080. /**
  45081. * Specifies a fix frustum size for the shadow generation.
  45082. */
  45083. shadowFrustumSize: number;
  45084. private _shadowOrthoScale;
  45085. /**
  45086. * Gets the shadow projection scale against the optimal computed one.
  45087. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45088. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45089. */
  45090. /**
  45091. * Sets the shadow projection scale against the optimal computed one.
  45092. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45093. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45094. */
  45095. shadowOrthoScale: number;
  45096. /**
  45097. * Automatically compute the projection matrix to best fit (including all the casters)
  45098. * on each frame.
  45099. */
  45100. autoUpdateExtends: boolean;
  45101. private _orthoLeft;
  45102. private _orthoRight;
  45103. private _orthoTop;
  45104. private _orthoBottom;
  45105. /**
  45106. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45107. * The directional light is emitted from everywhere in the given direction.
  45108. * It can cast shadows.
  45109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45110. * @param name The friendly name of the light
  45111. * @param direction The direction of the light
  45112. * @param scene The scene the light belongs to
  45113. */
  45114. constructor(name: string, direction: Vector3, scene: Scene);
  45115. /**
  45116. * Returns the string "DirectionalLight".
  45117. * @return The class name
  45118. */
  45119. getClassName(): string;
  45120. /**
  45121. * Returns the integer 1.
  45122. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45123. */
  45124. getTypeID(): number;
  45125. /**
  45126. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45127. * Returns the DirectionalLight Shadow projection matrix.
  45128. */
  45129. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45130. /**
  45131. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45132. * Returns the DirectionalLight Shadow projection matrix.
  45133. */
  45134. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45135. /**
  45136. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45137. * Returns the DirectionalLight Shadow projection matrix.
  45138. */
  45139. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45140. protected _buildUniformLayout(): void;
  45141. /**
  45142. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45143. * @param effect The effect to update
  45144. * @param lightIndex The index of the light in the effect to update
  45145. * @returns The directional light
  45146. */
  45147. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45148. /**
  45149. * Gets the minZ used for shadow according to both the scene and the light.
  45150. *
  45151. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45152. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45153. * @param activeCamera The camera we are returning the min for
  45154. * @returns the depth min z
  45155. */
  45156. getDepthMinZ(activeCamera: Camera): number;
  45157. /**
  45158. * Gets the maxZ used for shadow according to both the scene and the light.
  45159. *
  45160. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45161. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45162. * @param activeCamera The camera we are returning the max for
  45163. * @returns the depth max z
  45164. */
  45165. getDepthMaxZ(activeCamera: Camera): number;
  45166. /**
  45167. * Prepares the list of defines specific to the light type.
  45168. * @param defines the list of defines
  45169. * @param lightIndex defines the index of the light for the effect
  45170. */
  45171. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45172. }
  45173. }
  45174. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45175. import { Mesh } from "babylonjs/Meshes/mesh";
  45176. /**
  45177. * Class containing static functions to help procedurally build meshes
  45178. */
  45179. export class HemisphereBuilder {
  45180. /**
  45181. * Creates a hemisphere mesh
  45182. * @param name defines the name of the mesh
  45183. * @param options defines the options used to create the mesh
  45184. * @param scene defines the hosting scene
  45185. * @returns the hemisphere mesh
  45186. */
  45187. static CreateHemisphere(name: string, options: {
  45188. segments?: number;
  45189. diameter?: number;
  45190. sideOrientation?: number;
  45191. }, scene: any): Mesh;
  45192. }
  45193. }
  45194. declare module "babylonjs/Lights/spotLight" {
  45195. import { Nullable } from "babylonjs/types";
  45196. import { Scene } from "babylonjs/scene";
  45197. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45199. import { Effect } from "babylonjs/Materials/effect";
  45200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45201. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45202. /**
  45203. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45204. * These values define a cone of light starting from the position, emitting toward the direction.
  45205. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45206. * and the exponent defines the speed of the decay of the light with distance (reach).
  45207. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45208. */
  45209. export class SpotLight extends ShadowLight {
  45210. private _angle;
  45211. private _innerAngle;
  45212. private _cosHalfAngle;
  45213. private _lightAngleScale;
  45214. private _lightAngleOffset;
  45215. /**
  45216. * Gets the cone angle of the spot light in Radians.
  45217. */
  45218. /**
  45219. * Sets the cone angle of the spot light in Radians.
  45220. */
  45221. angle: number;
  45222. /**
  45223. * Only used in gltf falloff mode, this defines the angle where
  45224. * the directional falloff will start before cutting at angle which could be seen
  45225. * as outer angle.
  45226. */
  45227. /**
  45228. * Only used in gltf falloff mode, this defines the angle where
  45229. * the directional falloff will start before cutting at angle which could be seen
  45230. * as outer angle.
  45231. */
  45232. innerAngle: number;
  45233. private _shadowAngleScale;
  45234. /**
  45235. * Allows scaling the angle of the light for shadow generation only.
  45236. */
  45237. /**
  45238. * Allows scaling the angle of the light for shadow generation only.
  45239. */
  45240. shadowAngleScale: number;
  45241. /**
  45242. * The light decay speed with the distance from the emission spot.
  45243. */
  45244. exponent: number;
  45245. private _projectionTextureMatrix;
  45246. /**
  45247. * Allows reading the projecton texture
  45248. */
  45249. readonly projectionTextureMatrix: Matrix;
  45250. protected _projectionTextureLightNear: number;
  45251. /**
  45252. * Gets the near clip of the Spotlight for texture projection.
  45253. */
  45254. /**
  45255. * Sets the near clip of the Spotlight for texture projection.
  45256. */
  45257. projectionTextureLightNear: number;
  45258. protected _projectionTextureLightFar: number;
  45259. /**
  45260. * Gets the far clip of the Spotlight for texture projection.
  45261. */
  45262. /**
  45263. * Sets the far clip of the Spotlight for texture projection.
  45264. */
  45265. projectionTextureLightFar: number;
  45266. protected _projectionTextureUpDirection: Vector3;
  45267. /**
  45268. * Gets the Up vector of the Spotlight for texture projection.
  45269. */
  45270. /**
  45271. * Sets the Up vector of the Spotlight for texture projection.
  45272. */
  45273. projectionTextureUpDirection: Vector3;
  45274. private _projectionTexture;
  45275. /**
  45276. * Gets the projection texture of the light.
  45277. */
  45278. /**
  45279. * Sets the projection texture of the light.
  45280. */
  45281. projectionTexture: Nullable<BaseTexture>;
  45282. private _projectionTextureViewLightDirty;
  45283. private _projectionTextureProjectionLightDirty;
  45284. private _projectionTextureDirty;
  45285. private _projectionTextureViewTargetVector;
  45286. private _projectionTextureViewLightMatrix;
  45287. private _projectionTextureProjectionLightMatrix;
  45288. private _projectionTextureScalingMatrix;
  45289. /**
  45290. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45291. * It can cast shadows.
  45292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45293. * @param name The light friendly name
  45294. * @param position The position of the spot light in the scene
  45295. * @param direction The direction of the light in the scene
  45296. * @param angle The cone angle of the light in Radians
  45297. * @param exponent The light decay speed with the distance from the emission spot
  45298. * @param scene The scene the lights belongs to
  45299. */
  45300. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45301. /**
  45302. * Returns the string "SpotLight".
  45303. * @returns the class name
  45304. */
  45305. getClassName(): string;
  45306. /**
  45307. * Returns the integer 2.
  45308. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45309. */
  45310. getTypeID(): number;
  45311. /**
  45312. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45313. */
  45314. protected _setDirection(value: Vector3): void;
  45315. /**
  45316. * Overrides the position setter to recompute the projection texture view light Matrix.
  45317. */
  45318. protected _setPosition(value: Vector3): void;
  45319. /**
  45320. * 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.
  45321. * Returns the SpotLight.
  45322. */
  45323. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45324. protected _computeProjectionTextureViewLightMatrix(): void;
  45325. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45326. /**
  45327. * Main function for light texture projection matrix computing.
  45328. */
  45329. protected _computeProjectionTextureMatrix(): void;
  45330. protected _buildUniformLayout(): void;
  45331. private _computeAngleValues;
  45332. /**
  45333. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45334. * @param effect The effect to update
  45335. * @param lightIndex The index of the light in the effect to update
  45336. * @returns The spot light
  45337. */
  45338. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45339. /**
  45340. * Disposes the light and the associated resources.
  45341. */
  45342. dispose(): void;
  45343. /**
  45344. * Prepares the list of defines specific to the light type.
  45345. * @param defines the list of defines
  45346. * @param lightIndex defines the index of the light for the effect
  45347. */
  45348. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45349. }
  45350. }
  45351. declare module "babylonjs/Gizmos/lightGizmo" {
  45352. import { Nullable } from "babylonjs/types";
  45353. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45354. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45355. import { Light } from "babylonjs/Lights/light";
  45356. /**
  45357. * Gizmo that enables viewing a light
  45358. */
  45359. export class LightGizmo extends Gizmo {
  45360. private _lightMesh;
  45361. private _material;
  45362. private cachedPosition;
  45363. private cachedForward;
  45364. /**
  45365. * Creates a LightGizmo
  45366. * @param gizmoLayer The utility layer the gizmo will be added to
  45367. */
  45368. constructor(gizmoLayer?: UtilityLayerRenderer);
  45369. private _light;
  45370. /**
  45371. * The light that the gizmo is attached to
  45372. */
  45373. light: Nullable<Light>;
  45374. /**
  45375. * @hidden
  45376. * Updates the gizmo to match the attached mesh's position/rotation
  45377. */
  45378. protected _update(): void;
  45379. private static _Scale;
  45380. /**
  45381. * Creates the lines for a light mesh
  45382. */
  45383. private static _createLightLines;
  45384. /**
  45385. * Disposes of the light gizmo
  45386. */
  45387. dispose(): void;
  45388. private static _CreateHemisphericLightMesh;
  45389. private static _CreatePointLightMesh;
  45390. private static _CreateSpotLightMesh;
  45391. private static _CreateDirectionalLightMesh;
  45392. }
  45393. }
  45394. declare module "babylonjs/Gizmos/index" {
  45395. export * from "babylonjs/Gizmos/axisDragGizmo";
  45396. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45397. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45398. export * from "babylonjs/Gizmos/gizmo";
  45399. export * from "babylonjs/Gizmos/gizmoManager";
  45400. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45401. export * from "babylonjs/Gizmos/positionGizmo";
  45402. export * from "babylonjs/Gizmos/rotationGizmo";
  45403. export * from "babylonjs/Gizmos/scaleGizmo";
  45404. export * from "babylonjs/Gizmos/lightGizmo";
  45405. }
  45406. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45407. /** @hidden */
  45408. export var backgroundFragmentDeclaration: {
  45409. name: string;
  45410. shader: string;
  45411. };
  45412. }
  45413. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45414. /** @hidden */
  45415. export var backgroundUboDeclaration: {
  45416. name: string;
  45417. shader: string;
  45418. };
  45419. }
  45420. declare module "babylonjs/Shaders/background.fragment" {
  45421. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45422. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45423. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45424. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45425. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45426. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45427. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45428. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45429. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45430. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45431. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45432. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45433. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45434. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45435. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45436. /** @hidden */
  45437. export var backgroundPixelShader: {
  45438. name: string;
  45439. shader: string;
  45440. };
  45441. }
  45442. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45443. /** @hidden */
  45444. export var backgroundVertexDeclaration: {
  45445. name: string;
  45446. shader: string;
  45447. };
  45448. }
  45449. declare module "babylonjs/Shaders/background.vertex" {
  45450. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45451. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45452. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45453. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45454. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45455. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45456. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45457. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45458. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45459. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45460. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45461. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45462. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45463. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45464. /** @hidden */
  45465. export var backgroundVertexShader: {
  45466. name: string;
  45467. shader: string;
  45468. };
  45469. }
  45470. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45471. import { Nullable, int, float } from "babylonjs/types";
  45472. import { Scene } from "babylonjs/scene";
  45473. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45476. import { Mesh } from "babylonjs/Meshes/mesh";
  45477. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45478. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45479. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45481. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45482. import "babylonjs/Shaders/background.fragment";
  45483. import "babylonjs/Shaders/background.vertex";
  45484. /**
  45485. * Background material used to create an efficient environement around your scene.
  45486. */
  45487. export class BackgroundMaterial extends PushMaterial {
  45488. /**
  45489. * Standard reflectance value at parallel view angle.
  45490. */
  45491. static StandardReflectance0: number;
  45492. /**
  45493. * Standard reflectance value at grazing angle.
  45494. */
  45495. static StandardReflectance90: number;
  45496. protected _primaryColor: Color3;
  45497. /**
  45498. * Key light Color (multiply against the environement texture)
  45499. */
  45500. primaryColor: Color3;
  45501. protected __perceptualColor: Nullable<Color3>;
  45502. /**
  45503. * Experimental Internal Use Only.
  45504. *
  45505. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45506. * This acts as a helper to set the primary color to a more "human friendly" value.
  45507. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45508. * output color as close as possible from the chosen value.
  45509. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45510. * part of lighting setup.)
  45511. */
  45512. _perceptualColor: Nullable<Color3>;
  45513. protected _primaryColorShadowLevel: float;
  45514. /**
  45515. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45516. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45517. */
  45518. primaryColorShadowLevel: float;
  45519. protected _primaryColorHighlightLevel: float;
  45520. /**
  45521. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45522. * The primary color is used at the level chosen to define what the white area would look.
  45523. */
  45524. primaryColorHighlightLevel: float;
  45525. protected _reflectionTexture: Nullable<BaseTexture>;
  45526. /**
  45527. * Reflection Texture used in the material.
  45528. * Should be author in a specific way for the best result (refer to the documentation).
  45529. */
  45530. reflectionTexture: Nullable<BaseTexture>;
  45531. protected _reflectionBlur: float;
  45532. /**
  45533. * Reflection Texture level of blur.
  45534. *
  45535. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45536. * texture twice.
  45537. */
  45538. reflectionBlur: float;
  45539. protected _diffuseTexture: Nullable<BaseTexture>;
  45540. /**
  45541. * Diffuse Texture used in the material.
  45542. * Should be author in a specific way for the best result (refer to the documentation).
  45543. */
  45544. diffuseTexture: Nullable<BaseTexture>;
  45545. protected _shadowLights: Nullable<IShadowLight[]>;
  45546. /**
  45547. * Specify the list of lights casting shadow on the material.
  45548. * All scene shadow lights will be included if null.
  45549. */
  45550. shadowLights: Nullable<IShadowLight[]>;
  45551. protected _shadowLevel: float;
  45552. /**
  45553. * Helps adjusting the shadow to a softer level if required.
  45554. * 0 means black shadows and 1 means no shadows.
  45555. */
  45556. shadowLevel: float;
  45557. protected _sceneCenter: Vector3;
  45558. /**
  45559. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45560. * It is usually zero but might be interesting to modify according to your setup.
  45561. */
  45562. sceneCenter: Vector3;
  45563. protected _opacityFresnel: boolean;
  45564. /**
  45565. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45566. * This helps ensuring a nice transition when the camera goes under the ground.
  45567. */
  45568. opacityFresnel: boolean;
  45569. protected _reflectionFresnel: boolean;
  45570. /**
  45571. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45572. * This helps adding a mirror texture on the ground.
  45573. */
  45574. reflectionFresnel: boolean;
  45575. protected _reflectionFalloffDistance: number;
  45576. /**
  45577. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45578. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45579. */
  45580. reflectionFalloffDistance: number;
  45581. protected _reflectionAmount: number;
  45582. /**
  45583. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45584. */
  45585. reflectionAmount: number;
  45586. protected _reflectionReflectance0: number;
  45587. /**
  45588. * This specifies the weight of the reflection at grazing angle.
  45589. */
  45590. reflectionReflectance0: number;
  45591. protected _reflectionReflectance90: number;
  45592. /**
  45593. * This specifies the weight of the reflection at a perpendicular point of view.
  45594. */
  45595. reflectionReflectance90: number;
  45596. /**
  45597. * Sets the reflection reflectance fresnel values according to the default standard
  45598. * empirically know to work well :-)
  45599. */
  45600. reflectionStandardFresnelWeight: number;
  45601. protected _useRGBColor: boolean;
  45602. /**
  45603. * Helps to directly use the maps channels instead of their level.
  45604. */
  45605. useRGBColor: boolean;
  45606. protected _enableNoise: boolean;
  45607. /**
  45608. * This helps reducing the banding effect that could occur on the background.
  45609. */
  45610. enableNoise: boolean;
  45611. /**
  45612. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45613. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45614. * Recommended to be keep at 1.0 except for special cases.
  45615. */
  45616. fovMultiplier: number;
  45617. private _fovMultiplier;
  45618. /**
  45619. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45620. */
  45621. useEquirectangularFOV: boolean;
  45622. private _maxSimultaneousLights;
  45623. /**
  45624. * Number of Simultaneous lights allowed on the material.
  45625. */
  45626. maxSimultaneousLights: int;
  45627. /**
  45628. * Default configuration related to image processing available in the Background Material.
  45629. */
  45630. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45631. /**
  45632. * Keep track of the image processing observer to allow dispose and replace.
  45633. */
  45634. private _imageProcessingObserver;
  45635. /**
  45636. * Attaches a new image processing configuration to the PBR Material.
  45637. * @param configuration (if null the scene configuration will be use)
  45638. */
  45639. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45640. /**
  45641. * Gets the image processing configuration used either in this material.
  45642. */
  45643. /**
  45644. * Sets the Default image processing configuration used either in the this material.
  45645. *
  45646. * If sets to null, the scene one is in use.
  45647. */
  45648. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45649. /**
  45650. * Gets wether the color curves effect is enabled.
  45651. */
  45652. /**
  45653. * Sets wether the color curves effect is enabled.
  45654. */
  45655. cameraColorCurvesEnabled: boolean;
  45656. /**
  45657. * Gets wether the color grading effect is enabled.
  45658. */
  45659. /**
  45660. * Gets wether the color grading effect is enabled.
  45661. */
  45662. cameraColorGradingEnabled: boolean;
  45663. /**
  45664. * Gets wether tonemapping is enabled or not.
  45665. */
  45666. /**
  45667. * Sets wether tonemapping is enabled or not
  45668. */
  45669. cameraToneMappingEnabled: boolean;
  45670. /**
  45671. * The camera exposure used on this material.
  45672. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45673. * This corresponds to a photographic exposure.
  45674. */
  45675. /**
  45676. * The camera exposure used on this material.
  45677. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45678. * This corresponds to a photographic exposure.
  45679. */
  45680. cameraExposure: float;
  45681. /**
  45682. * Gets The camera contrast used on this material.
  45683. */
  45684. /**
  45685. * Sets The camera contrast used on this material.
  45686. */
  45687. cameraContrast: float;
  45688. /**
  45689. * Gets the Color Grading 2D Lookup Texture.
  45690. */
  45691. /**
  45692. * Sets the Color Grading 2D Lookup Texture.
  45693. */
  45694. cameraColorGradingTexture: Nullable<BaseTexture>;
  45695. /**
  45696. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45697. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45698. * 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;
  45699. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45700. */
  45701. /**
  45702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45704. * 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;
  45705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45706. */
  45707. cameraColorCurves: Nullable<ColorCurves>;
  45708. /**
  45709. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45710. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45711. */
  45712. switchToBGR: boolean;
  45713. private _renderTargets;
  45714. private _reflectionControls;
  45715. private _white;
  45716. private _primaryShadowColor;
  45717. private _primaryHighlightColor;
  45718. /**
  45719. * Instantiates a Background Material in the given scene
  45720. * @param name The friendly name of the material
  45721. * @param scene The scene to add the material to
  45722. */
  45723. constructor(name: string, scene: Scene);
  45724. /**
  45725. * Gets a boolean indicating that current material needs to register RTT
  45726. */
  45727. readonly hasRenderTargetTextures: boolean;
  45728. /**
  45729. * The entire material has been created in order to prevent overdraw.
  45730. * @returns false
  45731. */
  45732. needAlphaTesting(): boolean;
  45733. /**
  45734. * The entire material has been created in order to prevent overdraw.
  45735. * @returns true if blending is enable
  45736. */
  45737. needAlphaBlending(): boolean;
  45738. /**
  45739. * Checks wether the material is ready to be rendered for a given mesh.
  45740. * @param mesh The mesh to render
  45741. * @param subMesh The submesh to check against
  45742. * @param useInstances Specify wether or not the material is used with instances
  45743. * @returns true if all the dependencies are ready (Textures, Effects...)
  45744. */
  45745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45746. /**
  45747. * Compute the primary color according to the chosen perceptual color.
  45748. */
  45749. private _computePrimaryColorFromPerceptualColor;
  45750. /**
  45751. * Compute the highlights and shadow colors according to their chosen levels.
  45752. */
  45753. private _computePrimaryColors;
  45754. /**
  45755. * Build the uniform buffer used in the material.
  45756. */
  45757. buildUniformLayout(): void;
  45758. /**
  45759. * Unbind the material.
  45760. */
  45761. unbind(): void;
  45762. /**
  45763. * Bind only the world matrix to the material.
  45764. * @param world The world matrix to bind.
  45765. */
  45766. bindOnlyWorldMatrix(world: Matrix): void;
  45767. /**
  45768. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45769. * @param world The world matrix to bind.
  45770. * @param subMesh The submesh to bind for.
  45771. */
  45772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45773. /**
  45774. * Dispose the material.
  45775. * @param forceDisposeEffect Force disposal of the associated effect.
  45776. * @param forceDisposeTextures Force disposal of the associated textures.
  45777. */
  45778. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45779. /**
  45780. * Clones the material.
  45781. * @param name The cloned name.
  45782. * @returns The cloned material.
  45783. */
  45784. clone(name: string): BackgroundMaterial;
  45785. /**
  45786. * Serializes the current material to its JSON representation.
  45787. * @returns The JSON representation.
  45788. */
  45789. serialize(): any;
  45790. /**
  45791. * Gets the class name of the material
  45792. * @returns "BackgroundMaterial"
  45793. */
  45794. getClassName(): string;
  45795. /**
  45796. * Parse a JSON input to create back a background material.
  45797. * @param source The JSON data to parse
  45798. * @param scene The scene to create the parsed material in
  45799. * @param rootUrl The root url of the assets the material depends upon
  45800. * @returns the instantiated BackgroundMaterial.
  45801. */
  45802. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45803. }
  45804. }
  45805. declare module "babylonjs/Helpers/environmentHelper" {
  45806. import { Observable } from "babylonjs/Misc/observable";
  45807. import { Nullable } from "babylonjs/types";
  45808. import { Scene } from "babylonjs/scene";
  45809. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45811. import { Mesh } from "babylonjs/Meshes/mesh";
  45812. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45813. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45814. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45815. import "babylonjs/Meshes/Builders/planeBuilder";
  45816. import "babylonjs/Meshes/Builders/boxBuilder";
  45817. /**
  45818. * Represents the different options available during the creation of
  45819. * a Environment helper.
  45820. *
  45821. * This can control the default ground, skybox and image processing setup of your scene.
  45822. */
  45823. export interface IEnvironmentHelperOptions {
  45824. /**
  45825. * Specifies wether or not to create a ground.
  45826. * True by default.
  45827. */
  45828. createGround: boolean;
  45829. /**
  45830. * Specifies the ground size.
  45831. * 15 by default.
  45832. */
  45833. groundSize: number;
  45834. /**
  45835. * The texture used on the ground for the main color.
  45836. * Comes from the BabylonJS CDN by default.
  45837. *
  45838. * Remarks: Can be either a texture or a url.
  45839. */
  45840. groundTexture: string | BaseTexture;
  45841. /**
  45842. * The color mixed in the ground texture by default.
  45843. * BabylonJS clearColor by default.
  45844. */
  45845. groundColor: Color3;
  45846. /**
  45847. * Specifies the ground opacity.
  45848. * 1 by default.
  45849. */
  45850. groundOpacity: number;
  45851. /**
  45852. * Enables the ground to receive shadows.
  45853. * True by default.
  45854. */
  45855. enableGroundShadow: boolean;
  45856. /**
  45857. * Helps preventing the shadow to be fully black on the ground.
  45858. * 0.5 by default.
  45859. */
  45860. groundShadowLevel: number;
  45861. /**
  45862. * Creates a mirror texture attach to the ground.
  45863. * false by default.
  45864. */
  45865. enableGroundMirror: boolean;
  45866. /**
  45867. * Specifies the ground mirror size ratio.
  45868. * 0.3 by default as the default kernel is 64.
  45869. */
  45870. groundMirrorSizeRatio: number;
  45871. /**
  45872. * Specifies the ground mirror blur kernel size.
  45873. * 64 by default.
  45874. */
  45875. groundMirrorBlurKernel: number;
  45876. /**
  45877. * Specifies the ground mirror visibility amount.
  45878. * 1 by default
  45879. */
  45880. groundMirrorAmount: number;
  45881. /**
  45882. * Specifies the ground mirror reflectance weight.
  45883. * This uses the standard weight of the background material to setup the fresnel effect
  45884. * of the mirror.
  45885. * 1 by default.
  45886. */
  45887. groundMirrorFresnelWeight: number;
  45888. /**
  45889. * Specifies the ground mirror Falloff distance.
  45890. * This can helps reducing the size of the reflection.
  45891. * 0 by Default.
  45892. */
  45893. groundMirrorFallOffDistance: number;
  45894. /**
  45895. * Specifies the ground mirror texture type.
  45896. * Unsigned Int by Default.
  45897. */
  45898. groundMirrorTextureType: number;
  45899. /**
  45900. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45901. * the shown objects.
  45902. */
  45903. groundYBias: number;
  45904. /**
  45905. * Specifies wether or not to create a skybox.
  45906. * True by default.
  45907. */
  45908. createSkybox: boolean;
  45909. /**
  45910. * Specifies the skybox size.
  45911. * 20 by default.
  45912. */
  45913. skyboxSize: number;
  45914. /**
  45915. * The texture used on the skybox for the main color.
  45916. * Comes from the BabylonJS CDN by default.
  45917. *
  45918. * Remarks: Can be either a texture or a url.
  45919. */
  45920. skyboxTexture: string | BaseTexture;
  45921. /**
  45922. * The color mixed in the skybox texture by default.
  45923. * BabylonJS clearColor by default.
  45924. */
  45925. skyboxColor: Color3;
  45926. /**
  45927. * The background rotation around the Y axis of the scene.
  45928. * This helps aligning the key lights of your scene with the background.
  45929. * 0 by default.
  45930. */
  45931. backgroundYRotation: number;
  45932. /**
  45933. * Compute automatically the size of the elements to best fit with the scene.
  45934. */
  45935. sizeAuto: boolean;
  45936. /**
  45937. * Default position of the rootMesh if autoSize is not true.
  45938. */
  45939. rootPosition: Vector3;
  45940. /**
  45941. * Sets up the image processing in the scene.
  45942. * true by default.
  45943. */
  45944. setupImageProcessing: boolean;
  45945. /**
  45946. * The texture used as your environment texture in the scene.
  45947. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45948. *
  45949. * Remarks: Can be either a texture or a url.
  45950. */
  45951. environmentTexture: string | BaseTexture;
  45952. /**
  45953. * The value of the exposure to apply to the scene.
  45954. * 0.6 by default if setupImageProcessing is true.
  45955. */
  45956. cameraExposure: number;
  45957. /**
  45958. * The value of the contrast to apply to the scene.
  45959. * 1.6 by default if setupImageProcessing is true.
  45960. */
  45961. cameraContrast: number;
  45962. /**
  45963. * Specifies wether or not tonemapping should be enabled in the scene.
  45964. * true by default if setupImageProcessing is true.
  45965. */
  45966. toneMappingEnabled: boolean;
  45967. }
  45968. /**
  45969. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45970. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45971. * It also helps with the default setup of your imageProcessing configuration.
  45972. */
  45973. export class EnvironmentHelper {
  45974. /**
  45975. * Default ground texture URL.
  45976. */
  45977. private static _groundTextureCDNUrl;
  45978. /**
  45979. * Default skybox texture URL.
  45980. */
  45981. private static _skyboxTextureCDNUrl;
  45982. /**
  45983. * Default environment texture URL.
  45984. */
  45985. private static _environmentTextureCDNUrl;
  45986. /**
  45987. * Creates the default options for the helper.
  45988. */
  45989. private static _getDefaultOptions;
  45990. private _rootMesh;
  45991. /**
  45992. * Gets the root mesh created by the helper.
  45993. */
  45994. readonly rootMesh: Mesh;
  45995. private _skybox;
  45996. /**
  45997. * Gets the skybox created by the helper.
  45998. */
  45999. readonly skybox: Nullable<Mesh>;
  46000. private _skyboxTexture;
  46001. /**
  46002. * Gets the skybox texture created by the helper.
  46003. */
  46004. readonly skyboxTexture: Nullable<BaseTexture>;
  46005. private _skyboxMaterial;
  46006. /**
  46007. * Gets the skybox material created by the helper.
  46008. */
  46009. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46010. private _ground;
  46011. /**
  46012. * Gets the ground mesh created by the helper.
  46013. */
  46014. readonly ground: Nullable<Mesh>;
  46015. private _groundTexture;
  46016. /**
  46017. * Gets the ground texture created by the helper.
  46018. */
  46019. readonly groundTexture: Nullable<BaseTexture>;
  46020. private _groundMirror;
  46021. /**
  46022. * Gets the ground mirror created by the helper.
  46023. */
  46024. readonly groundMirror: Nullable<MirrorTexture>;
  46025. /**
  46026. * Gets the ground mirror render list to helps pushing the meshes
  46027. * you wish in the ground reflection.
  46028. */
  46029. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46030. private _groundMaterial;
  46031. /**
  46032. * Gets the ground material created by the helper.
  46033. */
  46034. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46035. /**
  46036. * Stores the creation options.
  46037. */
  46038. private readonly _scene;
  46039. private _options;
  46040. /**
  46041. * This observable will be notified with any error during the creation of the environment,
  46042. * mainly texture creation errors.
  46043. */
  46044. onErrorObservable: Observable<{
  46045. message?: string;
  46046. exception?: any;
  46047. }>;
  46048. /**
  46049. * constructor
  46050. * @param options Defines the options we want to customize the helper
  46051. * @param scene The scene to add the material to
  46052. */
  46053. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46054. /**
  46055. * Updates the background according to the new options
  46056. * @param options
  46057. */
  46058. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46059. /**
  46060. * Sets the primary color of all the available elements.
  46061. * @param color the main color to affect to the ground and the background
  46062. */
  46063. setMainColor(color: Color3): void;
  46064. /**
  46065. * Setup the image processing according to the specified options.
  46066. */
  46067. private _setupImageProcessing;
  46068. /**
  46069. * Setup the environment texture according to the specified options.
  46070. */
  46071. private _setupEnvironmentTexture;
  46072. /**
  46073. * Setup the background according to the specified options.
  46074. */
  46075. private _setupBackground;
  46076. /**
  46077. * Get the scene sizes according to the setup.
  46078. */
  46079. private _getSceneSize;
  46080. /**
  46081. * Setup the ground according to the specified options.
  46082. */
  46083. private _setupGround;
  46084. /**
  46085. * Setup the ground material according to the specified options.
  46086. */
  46087. private _setupGroundMaterial;
  46088. /**
  46089. * Setup the ground diffuse texture according to the specified options.
  46090. */
  46091. private _setupGroundDiffuseTexture;
  46092. /**
  46093. * Setup the ground mirror texture according to the specified options.
  46094. */
  46095. private _setupGroundMirrorTexture;
  46096. /**
  46097. * Setup the ground to receive the mirror texture.
  46098. */
  46099. private _setupMirrorInGroundMaterial;
  46100. /**
  46101. * Setup the skybox according to the specified options.
  46102. */
  46103. private _setupSkybox;
  46104. /**
  46105. * Setup the skybox material according to the specified options.
  46106. */
  46107. private _setupSkyboxMaterial;
  46108. /**
  46109. * Setup the skybox reflection texture according to the specified options.
  46110. */
  46111. private _setupSkyboxReflectionTexture;
  46112. private _errorHandler;
  46113. /**
  46114. * Dispose all the elements created by the Helper.
  46115. */
  46116. dispose(): void;
  46117. }
  46118. }
  46119. declare module "babylonjs/Helpers/photoDome" {
  46120. import { Observable } from "babylonjs/Misc/observable";
  46121. import { Nullable } from "babylonjs/types";
  46122. import { Scene } from "babylonjs/scene";
  46123. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46124. import { Mesh } from "babylonjs/Meshes/mesh";
  46125. import { Texture } from "babylonjs/Materials/Textures/texture";
  46126. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46127. import "babylonjs/Meshes/Builders/sphereBuilder";
  46128. /**
  46129. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46130. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46131. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46132. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46133. */
  46134. export class PhotoDome extends TransformNode {
  46135. /**
  46136. * Define the image as a Monoscopic panoramic 360 image.
  46137. */
  46138. static readonly MODE_MONOSCOPIC: number;
  46139. /**
  46140. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46141. */
  46142. static readonly MODE_TOPBOTTOM: number;
  46143. /**
  46144. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46145. */
  46146. static readonly MODE_SIDEBYSIDE: number;
  46147. private _useDirectMapping;
  46148. /**
  46149. * The texture being displayed on the sphere
  46150. */
  46151. protected _photoTexture: Texture;
  46152. /**
  46153. * Gets or sets the texture being displayed on the sphere
  46154. */
  46155. photoTexture: Texture;
  46156. /**
  46157. * Observable raised when an error occured while loading the 360 image
  46158. */
  46159. onLoadErrorObservable: Observable<string>;
  46160. /**
  46161. * The skybox material
  46162. */
  46163. protected _material: BackgroundMaterial;
  46164. /**
  46165. * The surface used for the skybox
  46166. */
  46167. protected _mesh: Mesh;
  46168. /**
  46169. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46170. * Also see the options.resolution property.
  46171. */
  46172. fovMultiplier: number;
  46173. private _imageMode;
  46174. /**
  46175. * Gets or set the current video mode for the video. It can be:
  46176. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46177. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46178. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46179. */
  46180. imageMode: number;
  46181. /**
  46182. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46183. * @param name Element's name, child elements will append suffixes for their own names.
  46184. * @param urlsOfPhoto defines the url of the photo to display
  46185. * @param options defines an object containing optional or exposed sub element properties
  46186. * @param onError defines a callback called when an error occured while loading the texture
  46187. */
  46188. constructor(name: string, urlOfPhoto: string, options: {
  46189. resolution?: number;
  46190. size?: number;
  46191. useDirectMapping?: boolean;
  46192. faceForward?: boolean;
  46193. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46194. private _onBeforeCameraRenderObserver;
  46195. private _changeImageMode;
  46196. /**
  46197. * Releases resources associated with this node.
  46198. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46199. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46200. */
  46201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46202. }
  46203. }
  46204. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46205. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46206. /** @hidden */
  46207. export var rgbdDecodePixelShader: {
  46208. name: string;
  46209. shader: string;
  46210. };
  46211. }
  46212. declare module "babylonjs/Misc/brdfTextureTools" {
  46213. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46214. import { Scene } from "babylonjs/scene";
  46215. import "babylonjs/Shaders/rgbdDecode.fragment";
  46216. /**
  46217. * Class used to host texture specific utilities
  46218. */
  46219. export class BRDFTextureTools {
  46220. /**
  46221. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46222. * @param texture the texture to expand.
  46223. */
  46224. private static _ExpandDefaultBRDFTexture;
  46225. /**
  46226. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46227. * @param scene defines the hosting scene
  46228. * @returns the environment BRDF texture
  46229. */
  46230. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46231. private static _environmentBRDFBase64Texture;
  46232. }
  46233. }
  46234. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46235. import { Nullable } from "babylonjs/types";
  46236. import { IAnimatable } from "babylonjs/Misc/tools";
  46237. import { Color3 } from "babylonjs/Maths/math";
  46238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46239. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46240. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46241. import { Engine } from "babylonjs/Engines/engine";
  46242. import { Scene } from "babylonjs/scene";
  46243. /**
  46244. * @hidden
  46245. */
  46246. export interface IMaterialClearCoatDefines {
  46247. CLEARCOAT: boolean;
  46248. CLEARCOAT_DEFAULTIOR: boolean;
  46249. CLEARCOAT_TEXTURE: boolean;
  46250. CLEARCOAT_TEXTUREDIRECTUV: number;
  46251. CLEARCOAT_BUMP: boolean;
  46252. CLEARCOAT_BUMPDIRECTUV: number;
  46253. CLEARCOAT_TINT: boolean;
  46254. CLEARCOAT_TINT_TEXTURE: boolean;
  46255. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46256. /** @hidden */
  46257. _areTexturesDirty: boolean;
  46258. }
  46259. /**
  46260. * Define the code related to the clear coat parameters of the pbr material.
  46261. */
  46262. export class PBRClearCoatConfiguration {
  46263. /**
  46264. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46265. * The default fits with a polyurethane material.
  46266. */
  46267. private static readonly _DefaultIndiceOfRefraction;
  46268. private _isEnabled;
  46269. /**
  46270. * Defines if the clear coat is enabled in the material.
  46271. */
  46272. isEnabled: boolean;
  46273. /**
  46274. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46275. */
  46276. intensity: number;
  46277. /**
  46278. * Defines the clear coat layer roughness.
  46279. */
  46280. roughness: number;
  46281. private _indiceOfRefraction;
  46282. /**
  46283. * Defines the indice of refraction of the clear coat.
  46284. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46285. * The default fits with a polyurethane material.
  46286. * Changing the default value is more performance intensive.
  46287. */
  46288. indiceOfRefraction: number;
  46289. private _texture;
  46290. /**
  46291. * Stores the clear coat values in a texture.
  46292. */
  46293. texture: Nullable<BaseTexture>;
  46294. private _bumpTexture;
  46295. /**
  46296. * Define the clear coat specific bump texture.
  46297. */
  46298. bumpTexture: Nullable<BaseTexture>;
  46299. private _isTintEnabled;
  46300. /**
  46301. * Defines if the clear coat tint is enabled in the material.
  46302. */
  46303. isTintEnabled: boolean;
  46304. /**
  46305. * Defines the clear coat tint of the material.
  46306. * This is only use if tint is enabled
  46307. */
  46308. tintColor: Color3;
  46309. /**
  46310. * Defines the distance at which the tint color should be found in the
  46311. * clear coat media.
  46312. * This is only use if tint is enabled
  46313. */
  46314. tintColorAtDistance: number;
  46315. /**
  46316. * Defines the clear coat layer thickness.
  46317. * This is only use if tint is enabled
  46318. */
  46319. tintThickness: number;
  46320. private _tintTexture;
  46321. /**
  46322. * Stores the clear tint values in a texture.
  46323. * rgb is tint
  46324. * a is a thickness factor
  46325. */
  46326. tintTexture: Nullable<BaseTexture>;
  46327. /** @hidden */
  46328. private _internalMarkAllSubMeshesAsTexturesDirty;
  46329. /** @hidden */
  46330. _markAllSubMeshesAsTexturesDirty(): void;
  46331. /**
  46332. * Instantiate a new istance of clear coat configuration.
  46333. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46334. */
  46335. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46336. /**
  46337. * Gets wehter the submesh is ready to be used or not.
  46338. * @param defines the list of "defines" to update.
  46339. * @param scene defines the scene the material belongs to.
  46340. * @param engine defines the engine the material belongs to.
  46341. * @param disableBumpMap defines wether the material disables bump or not.
  46342. * @returns - boolean indicating that the submesh is ready or not.
  46343. */
  46344. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46345. /**
  46346. * Checks to see if a texture is used in the material.
  46347. * @param defines the list of "defines" to update.
  46348. * @param scene defines the scene to the material belongs to.
  46349. */
  46350. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46351. /**
  46352. * Binds the material data.
  46353. * @param uniformBuffer defines the Uniform buffer to fill in.
  46354. * @param scene defines the scene the material belongs to.
  46355. * @param engine defines the engine the material belongs to.
  46356. * @param disableBumpMap defines wether the material disables bump or not.
  46357. * @param isFrozen defines wether the material is frozen or not.
  46358. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46359. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46360. */
  46361. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46362. /**
  46363. * Checks to see if a texture is used in the material.
  46364. * @param texture - Base texture to use.
  46365. * @returns - Boolean specifying if a texture is used in the material.
  46366. */
  46367. hasTexture(texture: BaseTexture): boolean;
  46368. /**
  46369. * Returns an array of the actively used textures.
  46370. * @param activeTextures Array of BaseTextures
  46371. */
  46372. getActiveTextures(activeTextures: BaseTexture[]): void;
  46373. /**
  46374. * Returns the animatable textures.
  46375. * @param animatables Array of animatable textures.
  46376. */
  46377. getAnimatables(animatables: IAnimatable[]): void;
  46378. /**
  46379. * Disposes the resources of the material.
  46380. * @param forceDisposeTextures - Forces the disposal of all textures.
  46381. */
  46382. dispose(forceDisposeTextures?: boolean): void;
  46383. /**
  46384. * Get the current class name of the texture useful for serialization or dynamic coding.
  46385. * @returns "PBRClearCoatConfiguration"
  46386. */
  46387. getClassName(): string;
  46388. /**
  46389. * Add fallbacks to the effect fallbacks list.
  46390. * @param defines defines the Base texture to use.
  46391. * @param fallbacks defines the current fallback list.
  46392. * @param currentRank defines the current fallback rank.
  46393. * @returns the new fallback rank.
  46394. */
  46395. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46396. /**
  46397. * Add the required uniforms to the current list.
  46398. * @param uniforms defines the current uniform list.
  46399. */
  46400. static AddUniforms(uniforms: string[]): void;
  46401. /**
  46402. * Add the required samplers to the current list.
  46403. * @param samplers defines the current sampler list.
  46404. */
  46405. static AddSamplers(samplers: string[]): void;
  46406. /**
  46407. * Add the required uniforms to the current buffer.
  46408. * @param uniformBuffer defines the current uniform buffer.
  46409. */
  46410. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46411. /**
  46412. * Makes a duplicate of the current configuration into another one.
  46413. * @param clearCoatConfiguration define the config where to copy the info
  46414. */
  46415. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46416. /**
  46417. * Serializes this clear coat configuration.
  46418. * @returns - An object with the serialized config.
  46419. */
  46420. serialize(): any;
  46421. /**
  46422. * Parses a Clear Coat Configuration from a serialized object.
  46423. * @param source - Serialized object.
  46424. */
  46425. parse(source: any): void;
  46426. }
  46427. }
  46428. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46429. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46430. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46432. import { Vector2 } from "babylonjs/Maths/math";
  46433. import { Scene } from "babylonjs/scene";
  46434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46435. import { IAnimatable } from "babylonjs/Misc/tools";
  46436. import { Nullable } from "babylonjs/types";
  46437. /**
  46438. * @hidden
  46439. */
  46440. export interface IMaterialAnisotropicDefines {
  46441. ANISOTROPIC: boolean;
  46442. ANISOTROPIC_TEXTURE: boolean;
  46443. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46444. MAINUV1: boolean;
  46445. _areTexturesDirty: boolean;
  46446. _needUVs: boolean;
  46447. }
  46448. /**
  46449. * Define the code related to the anisotropic parameters of the pbr material.
  46450. */
  46451. export class PBRAnisotropicConfiguration {
  46452. private _isEnabled;
  46453. /**
  46454. * Defines if the anisotropy is enabled in the material.
  46455. */
  46456. isEnabled: boolean;
  46457. /**
  46458. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46459. */
  46460. intensity: number;
  46461. /**
  46462. * Defines if the effect is along the tangents, bitangents or in between.
  46463. * By default, the effect is "strectching" the highlights along the tangents.
  46464. */
  46465. direction: Vector2;
  46466. private _texture;
  46467. /**
  46468. * Stores the anisotropy values in a texture.
  46469. * rg is direction (like normal from -1 to 1)
  46470. * b is a intensity
  46471. */
  46472. texture: Nullable<BaseTexture>;
  46473. /** @hidden */
  46474. private _internalMarkAllSubMeshesAsTexturesDirty;
  46475. /** @hidden */
  46476. _markAllSubMeshesAsTexturesDirty(): void;
  46477. /**
  46478. * Instantiate a new istance of anisotropy configuration.
  46479. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46480. */
  46481. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46482. /**
  46483. * Specifies that the submesh is ready to be used.
  46484. * @param defines the list of "defines" to update.
  46485. * @param scene defines the scene the material belongs to.
  46486. * @returns - boolean indicating that the submesh is ready or not.
  46487. */
  46488. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46489. /**
  46490. * Checks to see if a texture is used in the material.
  46491. * @param defines the list of "defines" to update.
  46492. * @param mesh the mesh we are preparing the defines for.
  46493. * @param scene defines the scene the material belongs to.
  46494. */
  46495. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46496. /**
  46497. * Binds the material data.
  46498. * @param uniformBuffer defines the Uniform buffer to fill in.
  46499. * @param scene defines the scene the material belongs to.
  46500. * @param isFrozen defines wether the material is frozen or not.
  46501. */
  46502. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46503. /**
  46504. * Checks to see if a texture is used in the material.
  46505. * @param texture - Base texture to use.
  46506. * @returns - Boolean specifying if a texture is used in the material.
  46507. */
  46508. hasTexture(texture: BaseTexture): boolean;
  46509. /**
  46510. * Returns an array of the actively used textures.
  46511. * @param activeTextures Array of BaseTextures
  46512. */
  46513. getActiveTextures(activeTextures: BaseTexture[]): void;
  46514. /**
  46515. * Returns the animatable textures.
  46516. * @param animatables Array of animatable textures.
  46517. */
  46518. getAnimatables(animatables: IAnimatable[]): void;
  46519. /**
  46520. * Disposes the resources of the material.
  46521. * @param forceDisposeTextures - Forces the disposal of all textures.
  46522. */
  46523. dispose(forceDisposeTextures?: boolean): void;
  46524. /**
  46525. * Get the current class name of the texture useful for serialization or dynamic coding.
  46526. * @returns "PBRAnisotropicConfiguration"
  46527. */
  46528. getClassName(): string;
  46529. /**
  46530. * Add fallbacks to the effect fallbacks list.
  46531. * @param defines defines the Base texture to use.
  46532. * @param fallbacks defines the current fallback list.
  46533. * @param currentRank defines the current fallback rank.
  46534. * @returns the new fallback rank.
  46535. */
  46536. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46537. /**
  46538. * Add the required uniforms to the current list.
  46539. * @param uniforms defines the current uniform list.
  46540. */
  46541. static AddUniforms(uniforms: string[]): void;
  46542. /**
  46543. * Add the required uniforms to the current buffer.
  46544. * @param uniformBuffer defines the current uniform buffer.
  46545. */
  46546. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46547. /**
  46548. * Add the required samplers to the current list.
  46549. * @param samplers defines the current sampler list.
  46550. */
  46551. static AddSamplers(samplers: string[]): void;
  46552. /**
  46553. * Makes a duplicate of the current configuration into another one.
  46554. * @param anisotropicConfiguration define the config where to copy the info
  46555. */
  46556. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46557. /**
  46558. * Serializes this anisotropy configuration.
  46559. * @returns - An object with the serialized config.
  46560. */
  46561. serialize(): any;
  46562. /**
  46563. * Parses a anisotropy Configuration from a serialized object.
  46564. * @param source - Serialized object.
  46565. */
  46566. parse(source: any): void;
  46567. }
  46568. }
  46569. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46570. /**
  46571. * @hidden
  46572. */
  46573. export interface IMaterialBRDFDefines {
  46574. BRDF_V_HEIGHT_CORRELATED: boolean;
  46575. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46576. SPHERICAL_HARMONICS: boolean;
  46577. /** @hidden */
  46578. _areMiscDirty: boolean;
  46579. }
  46580. /**
  46581. * Define the code related to the BRDF parameters of the pbr material.
  46582. */
  46583. export class PBRBRDFConfiguration {
  46584. /**
  46585. * Default value used for the energy conservation.
  46586. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46587. */
  46588. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46589. /**
  46590. * Default value used for the Smith Visibility Height Correlated mode.
  46591. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46592. */
  46593. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46594. /**
  46595. * Default value used for the IBL diffuse part.
  46596. * This can help switching back to the polynomials mode globally which is a tiny bit
  46597. * less GPU intensive at the drawback of a lower quality.
  46598. */
  46599. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46600. private _useEnergyConservation;
  46601. /**
  46602. * Defines if the material uses energy conservation.
  46603. */
  46604. useEnergyConservation: boolean;
  46605. private _useSmithVisibilityHeightCorrelated;
  46606. /**
  46607. * LEGACY Mode set to false
  46608. * Defines if the material uses height smith correlated visibility term.
  46609. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46610. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46611. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46612. * Not relying on height correlated will also disable energy conservation.
  46613. */
  46614. useSmithVisibilityHeightCorrelated: boolean;
  46615. private _useSphericalHarmonics;
  46616. /**
  46617. * LEGACY Mode set to false
  46618. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46619. * diffuse part of the IBL.
  46620. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46621. * to the ground truth.
  46622. */
  46623. useSphericalHarmonics: boolean;
  46624. /** @hidden */
  46625. private _internalMarkAllSubMeshesAsMiscDirty;
  46626. /** @hidden */
  46627. _markAllSubMeshesAsMiscDirty(): void;
  46628. /**
  46629. * Instantiate a new istance of clear coat configuration.
  46630. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46631. */
  46632. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46633. /**
  46634. * Checks to see if a texture is used in the material.
  46635. * @param defines the list of "defines" to update.
  46636. */
  46637. prepareDefines(defines: IMaterialBRDFDefines): void;
  46638. /**
  46639. * Get the current class name of the texture useful for serialization or dynamic coding.
  46640. * @returns "PBRClearCoatConfiguration"
  46641. */
  46642. getClassName(): string;
  46643. /**
  46644. * Makes a duplicate of the current configuration into another one.
  46645. * @param brdfConfiguration define the config where to copy the info
  46646. */
  46647. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46648. /**
  46649. * Serializes this BRDF configuration.
  46650. * @returns - An object with the serialized config.
  46651. */
  46652. serialize(): any;
  46653. /**
  46654. * Parses a BRDF Configuration from a serialized object.
  46655. * @param source - Serialized object.
  46656. */
  46657. parse(source: any): void;
  46658. }
  46659. }
  46660. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46661. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46662. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46663. import { Color3 } from "babylonjs/Maths/math";
  46664. import { Scene } from "babylonjs/scene";
  46665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46666. import { IAnimatable } from "babylonjs/Misc/tools";
  46667. import { Nullable } from "babylonjs/types";
  46668. /**
  46669. * @hidden
  46670. */
  46671. export interface IMaterialSheenDefines {
  46672. SHEEN: boolean;
  46673. SHEEN_TEXTURE: boolean;
  46674. SHEEN_TEXTUREDIRECTUV: number;
  46675. SHEEN_LINKWITHALBEDO: boolean;
  46676. /** @hidden */
  46677. _areTexturesDirty: boolean;
  46678. }
  46679. /**
  46680. * Define the code related to the Sheen parameters of the pbr material.
  46681. */
  46682. export class PBRSheenConfiguration {
  46683. private _isEnabled;
  46684. /**
  46685. * Defines if the material uses sheen.
  46686. */
  46687. isEnabled: boolean;
  46688. private _linkSheenWithAlbedo;
  46689. /**
  46690. * Defines if the sheen is linked to the sheen color.
  46691. */
  46692. linkSheenWithAlbedo: boolean;
  46693. /**
  46694. * Defines the sheen intensity.
  46695. */
  46696. intensity: number;
  46697. /**
  46698. * Defines the sheen color.
  46699. */
  46700. color: Color3;
  46701. private _texture;
  46702. /**
  46703. * Stores the sheen tint values in a texture.
  46704. * rgb is tint
  46705. * a is a intensity
  46706. */
  46707. texture: Nullable<BaseTexture>;
  46708. /** @hidden */
  46709. private _internalMarkAllSubMeshesAsTexturesDirty;
  46710. /** @hidden */
  46711. _markAllSubMeshesAsTexturesDirty(): void;
  46712. /**
  46713. * Instantiate a new istance of clear coat configuration.
  46714. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46715. */
  46716. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46717. /**
  46718. * Specifies that the submesh is ready to be used.
  46719. * @param defines the list of "defines" to update.
  46720. * @param scene defines the scene the material belongs to.
  46721. * @returns - boolean indicating that the submesh is ready or not.
  46722. */
  46723. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46724. /**
  46725. * Checks to see if a texture is used in the material.
  46726. * @param defines the list of "defines" to update.
  46727. * @param scene defines the scene the material belongs to.
  46728. */
  46729. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46730. /**
  46731. * Binds the material data.
  46732. * @param uniformBuffer defines the Uniform buffer to fill in.
  46733. * @param scene defines the scene the material belongs to.
  46734. * @param isFrozen defines wether the material is frozen or not.
  46735. */
  46736. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46737. /**
  46738. * Checks to see if a texture is used in the material.
  46739. * @param texture - Base texture to use.
  46740. * @returns - Boolean specifying if a texture is used in the material.
  46741. */
  46742. hasTexture(texture: BaseTexture): boolean;
  46743. /**
  46744. * Returns an array of the actively used textures.
  46745. * @param activeTextures Array of BaseTextures
  46746. */
  46747. getActiveTextures(activeTextures: BaseTexture[]): void;
  46748. /**
  46749. * Returns the animatable textures.
  46750. * @param animatables Array of animatable textures.
  46751. */
  46752. getAnimatables(animatables: IAnimatable[]): void;
  46753. /**
  46754. * Disposes the resources of the material.
  46755. * @param forceDisposeTextures - Forces the disposal of all textures.
  46756. */
  46757. dispose(forceDisposeTextures?: boolean): void;
  46758. /**
  46759. * Get the current class name of the texture useful for serialization or dynamic coding.
  46760. * @returns "PBRSheenConfiguration"
  46761. */
  46762. getClassName(): string;
  46763. /**
  46764. * Add fallbacks to the effect fallbacks list.
  46765. * @param defines defines the Base texture to use.
  46766. * @param fallbacks defines the current fallback list.
  46767. * @param currentRank defines the current fallback rank.
  46768. * @returns the new fallback rank.
  46769. */
  46770. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46771. /**
  46772. * Add the required uniforms to the current list.
  46773. * @param uniforms defines the current uniform list.
  46774. */
  46775. static AddUniforms(uniforms: string[]): void;
  46776. /**
  46777. * Add the required uniforms to the current buffer.
  46778. * @param uniformBuffer defines the current uniform buffer.
  46779. */
  46780. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46781. /**
  46782. * Add the required samplers to the current list.
  46783. * @param samplers defines the current sampler list.
  46784. */
  46785. static AddSamplers(samplers: string[]): void;
  46786. /**
  46787. * Makes a duplicate of the current configuration into another one.
  46788. * @param sheenConfiguration define the config where to copy the info
  46789. */
  46790. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46791. /**
  46792. * Serializes this BRDF configuration.
  46793. * @returns - An object with the serialized config.
  46794. */
  46795. serialize(): any;
  46796. /**
  46797. * Parses a Sheen Configuration from a serialized object.
  46798. * @param source - Serialized object.
  46799. */
  46800. parse(source: any): void;
  46801. }
  46802. }
  46803. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46804. import { Nullable } from "babylonjs/types";
  46805. import { IAnimatable } from "babylonjs/Misc/tools";
  46806. import { Color3 } from "babylonjs/Maths/math";
  46807. import { SmartArray } from "babylonjs/Misc/smartArray";
  46808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46809. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46810. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46811. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46812. import { Engine } from "babylonjs/Engines/engine";
  46813. import { Scene } from "babylonjs/scene";
  46814. /**
  46815. * @hidden
  46816. */
  46817. export interface IMaterialSubSurfaceDefines {
  46818. SUBSURFACE: boolean;
  46819. SS_REFRACTION: boolean;
  46820. SS_TRANSLUCENCY: boolean;
  46821. SS_SCATERRING: boolean;
  46822. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46823. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46824. SS_REFRACTIONMAP_3D: boolean;
  46825. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46826. SS_LODINREFRACTIONALPHA: boolean;
  46827. SS_GAMMAREFRACTION: boolean;
  46828. SS_RGBDREFRACTION: boolean;
  46829. SS_LINEARSPECULARREFRACTION: boolean;
  46830. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46831. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46832. /** @hidden */
  46833. _areTexturesDirty: boolean;
  46834. }
  46835. /**
  46836. * Define the code related to the sub surface parameters of the pbr material.
  46837. */
  46838. export class PBRSubSurfaceConfiguration {
  46839. private _isRefractionEnabled;
  46840. /**
  46841. * Defines if the refraction is enabled in the material.
  46842. */
  46843. isRefractionEnabled: boolean;
  46844. private _isTranslucencyEnabled;
  46845. /**
  46846. * Defines if the translucency is enabled in the material.
  46847. */
  46848. isTranslucencyEnabled: boolean;
  46849. private _isScatteringEnabled;
  46850. /**
  46851. * Defines the refraction intensity of the material.
  46852. * The refraction when enabled replaces the Diffuse part of the material.
  46853. * The intensity helps transitionning between diffuse and refraction.
  46854. */
  46855. refractionIntensity: number;
  46856. /**
  46857. * Defines the translucency intensity of the material.
  46858. * When translucency has been enabled, this defines how much of the "translucency"
  46859. * is addded to the diffuse part of the material.
  46860. */
  46861. translucencyIntensity: number;
  46862. /**
  46863. * Defines the scattering intensity of the material.
  46864. * When scattering has been enabled, this defines how much of the "scattered light"
  46865. * is addded to the diffuse part of the material.
  46866. */
  46867. scatteringIntensity: number;
  46868. private _thicknessTexture;
  46869. /**
  46870. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46871. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46872. * 0 would mean minimumThickness
  46873. * 1 would mean maximumThickness
  46874. * The other channels might be use as a mask to vary the different effects intensity.
  46875. */
  46876. thicknessTexture: Nullable<BaseTexture>;
  46877. private _refractionTexture;
  46878. /**
  46879. * Defines the texture to use for refraction.
  46880. */
  46881. refractionTexture: Nullable<BaseTexture>;
  46882. private _indexOfRefraction;
  46883. /**
  46884. * Defines the indice of refraction used in the material.
  46885. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46886. */
  46887. indexOfRefraction: number;
  46888. private _invertRefractionY;
  46889. /**
  46890. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46891. */
  46892. invertRefractionY: boolean;
  46893. private _linkRefractionWithTransparency;
  46894. /**
  46895. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46896. * Materials half opaque for instance using refraction could benefit from this control.
  46897. */
  46898. linkRefractionWithTransparency: boolean;
  46899. /**
  46900. * Defines the minimum thickness stored in the thickness map.
  46901. * If no thickness map is defined, this value will be used to simulate thickness.
  46902. */
  46903. minimumThickness: number;
  46904. /**
  46905. * Defines the maximum thickness stored in the thickness map.
  46906. */
  46907. maximumThickness: number;
  46908. /**
  46909. * Defines the volume tint of the material.
  46910. * This is used for both translucency and scattering.
  46911. */
  46912. tintColor: Color3;
  46913. /**
  46914. * Defines the distance at which the tint color should be found in the media.
  46915. * This is used for refraction only.
  46916. */
  46917. tintColorAtDistance: number;
  46918. /**
  46919. * Defines how far each channel transmit through the media.
  46920. * It is defined as a color to simplify it selection.
  46921. */
  46922. diffusionDistance: Color3;
  46923. private _useMaskFromThicknessTexture;
  46924. /**
  46925. * Stores the intensity of the different subsurface effects in the thickness texture.
  46926. * * the green channel is the translucency intensity.
  46927. * * the blue channel is the scattering intensity.
  46928. * * the alpha channel is the refraction intensity.
  46929. */
  46930. useMaskFromThicknessTexture: boolean;
  46931. /** @hidden */
  46932. private _internalMarkAllSubMeshesAsTexturesDirty;
  46933. /** @hidden */
  46934. _markAllSubMeshesAsTexturesDirty(): void;
  46935. /**
  46936. * Instantiate a new istance of sub surface configuration.
  46937. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46938. */
  46939. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46940. /**
  46941. * Gets wehter the submesh is ready to be used or not.
  46942. * @param defines the list of "defines" to update.
  46943. * @param scene defines the scene the material belongs to.
  46944. * @returns - boolean indicating that the submesh is ready or not.
  46945. */
  46946. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46947. /**
  46948. * Checks to see if a texture is used in the material.
  46949. * @param defines the list of "defines" to update.
  46950. * @param scene defines the scene to the material belongs to.
  46951. */
  46952. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46953. /**
  46954. * Binds the material data.
  46955. * @param uniformBuffer defines the Uniform buffer to fill in.
  46956. * @param scene defines the scene the material belongs to.
  46957. * @param engine defines the engine the material belongs to.
  46958. * @param isFrozen defines wether the material is frozen or not.
  46959. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46960. */
  46961. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46962. /**
  46963. * Unbinds the material from the mesh.
  46964. * @param activeEffect defines the effect that should be unbound from.
  46965. * @returns true if unbound, otherwise false
  46966. */
  46967. unbind(activeEffect: Effect): boolean;
  46968. /**
  46969. * Returns the texture used for refraction or null if none is used.
  46970. * @param scene defines the scene the material belongs to.
  46971. * @returns - Refraction texture if present. If no refraction texture and refraction
  46972. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46973. */
  46974. private _getRefractionTexture;
  46975. /**
  46976. * Returns true if alpha blending should be disabled.
  46977. */
  46978. readonly disableAlphaBlending: boolean;
  46979. /**
  46980. * Fills the list of render target textures.
  46981. * @param renderTargets the list of render targets to update
  46982. */
  46983. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46984. /**
  46985. * Checks to see if a texture is used in the material.
  46986. * @param texture - Base texture to use.
  46987. * @returns - Boolean specifying if a texture is used in the material.
  46988. */
  46989. hasTexture(texture: BaseTexture): boolean;
  46990. /**
  46991. * Gets a boolean indicating that current material needs to register RTT
  46992. * @returns true if this uses a render target otherwise false.
  46993. */
  46994. hasRenderTargetTextures(): boolean;
  46995. /**
  46996. * Returns an array of the actively used textures.
  46997. * @param activeTextures Array of BaseTextures
  46998. */
  46999. getActiveTextures(activeTextures: BaseTexture[]): void;
  47000. /**
  47001. * Returns the animatable textures.
  47002. * @param animatables Array of animatable textures.
  47003. */
  47004. getAnimatables(animatables: IAnimatable[]): void;
  47005. /**
  47006. * Disposes the resources of the material.
  47007. * @param forceDisposeTextures - Forces the disposal of all textures.
  47008. */
  47009. dispose(forceDisposeTextures?: boolean): void;
  47010. /**
  47011. * Get the current class name of the texture useful for serialization or dynamic coding.
  47012. * @returns "PBRSubSurfaceConfiguration"
  47013. */
  47014. getClassName(): string;
  47015. /**
  47016. * Add fallbacks to the effect fallbacks list.
  47017. * @param defines defines the Base texture to use.
  47018. * @param fallbacks defines the current fallback list.
  47019. * @param currentRank defines the current fallback rank.
  47020. * @returns the new fallback rank.
  47021. */
  47022. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47023. /**
  47024. * Add the required uniforms to the current list.
  47025. * @param uniforms defines the current uniform list.
  47026. */
  47027. static AddUniforms(uniforms: string[]): void;
  47028. /**
  47029. * Add the required samplers to the current list.
  47030. * @param samplers defines the current sampler list.
  47031. */
  47032. static AddSamplers(samplers: string[]): void;
  47033. /**
  47034. * Add the required uniforms to the current buffer.
  47035. * @param uniformBuffer defines the current uniform buffer.
  47036. */
  47037. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47038. /**
  47039. * Makes a duplicate of the current configuration into another one.
  47040. * @param configuration define the config where to copy the info
  47041. */
  47042. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47043. /**
  47044. * Serializes this Sub Surface configuration.
  47045. * @returns - An object with the serialized config.
  47046. */
  47047. serialize(): any;
  47048. /**
  47049. * Parses a Sub Surface Configuration from a serialized object.
  47050. * @param source - Serialized object.
  47051. */
  47052. parse(source: any): void;
  47053. }
  47054. }
  47055. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47056. /** @hidden */
  47057. export var pbrFragmentDeclaration: {
  47058. name: string;
  47059. shader: string;
  47060. };
  47061. }
  47062. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47063. /** @hidden */
  47064. export var pbrUboDeclaration: {
  47065. name: string;
  47066. shader: string;
  47067. };
  47068. }
  47069. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47070. /** @hidden */
  47071. export var pbrFragmentExtraDeclaration: {
  47072. name: string;
  47073. shader: string;
  47074. };
  47075. }
  47076. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47077. /** @hidden */
  47078. export var pbrFragmentSamplersDeclaration: {
  47079. name: string;
  47080. shader: string;
  47081. };
  47082. }
  47083. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47084. /** @hidden */
  47085. export var pbrHelperFunctions: {
  47086. name: string;
  47087. shader: string;
  47088. };
  47089. }
  47090. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47091. /** @hidden */
  47092. export var harmonicsFunctions: {
  47093. name: string;
  47094. shader: string;
  47095. };
  47096. }
  47097. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47098. /** @hidden */
  47099. export var pbrDirectLightingSetupFunctions: {
  47100. name: string;
  47101. shader: string;
  47102. };
  47103. }
  47104. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47105. /** @hidden */
  47106. export var pbrDirectLightingFalloffFunctions: {
  47107. name: string;
  47108. shader: string;
  47109. };
  47110. }
  47111. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47112. /** @hidden */
  47113. export var pbrBRDFFunctions: {
  47114. name: string;
  47115. shader: string;
  47116. };
  47117. }
  47118. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47119. /** @hidden */
  47120. export var pbrDirectLightingFunctions: {
  47121. name: string;
  47122. shader: string;
  47123. };
  47124. }
  47125. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47126. /** @hidden */
  47127. export var pbrIBLFunctions: {
  47128. name: string;
  47129. shader: string;
  47130. };
  47131. }
  47132. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47133. /** @hidden */
  47134. export var pbrDebug: {
  47135. name: string;
  47136. shader: string;
  47137. };
  47138. }
  47139. declare module "babylonjs/Shaders/pbr.fragment" {
  47140. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47141. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47142. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47143. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47144. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47145. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47146. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47147. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47148. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47149. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47150. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47151. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47152. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47153. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47154. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47155. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47156. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47157. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47158. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47159. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47160. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47161. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47162. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47163. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47164. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47165. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47166. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47167. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47168. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47169. /** @hidden */
  47170. export var pbrPixelShader: {
  47171. name: string;
  47172. shader: string;
  47173. };
  47174. }
  47175. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47176. /** @hidden */
  47177. export var pbrVertexDeclaration: {
  47178. name: string;
  47179. shader: string;
  47180. };
  47181. }
  47182. declare module "babylonjs/Shaders/pbr.vertex" {
  47183. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47184. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47185. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47187. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47188. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47189. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47190. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47191. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47192. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47193. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47194. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47195. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47196. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47197. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47198. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47199. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47200. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47201. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47202. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47203. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47204. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47205. /** @hidden */
  47206. export var pbrVertexShader: {
  47207. name: string;
  47208. shader: string;
  47209. };
  47210. }
  47211. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47212. import { IAnimatable } from "babylonjs/Misc/tools";
  47213. import { Nullable } from "babylonjs/types";
  47214. import { Scene } from "babylonjs/scene";
  47215. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47218. import { Mesh } from "babylonjs/Meshes/mesh";
  47219. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47220. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47221. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47222. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47223. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47224. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47225. import { Material } from "babylonjs/Materials/material";
  47226. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47227. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47228. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47229. import "babylonjs/Shaders/pbr.fragment";
  47230. import "babylonjs/Shaders/pbr.vertex";
  47231. /**
  47232. * Manages the defines for the PBR Material.
  47233. * @hidden
  47234. */
  47235. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47236. PBR: boolean;
  47237. MAINUV1: boolean;
  47238. MAINUV2: boolean;
  47239. UV1: boolean;
  47240. UV2: boolean;
  47241. ALBEDO: boolean;
  47242. ALBEDODIRECTUV: number;
  47243. VERTEXCOLOR: boolean;
  47244. AMBIENT: boolean;
  47245. AMBIENTDIRECTUV: number;
  47246. AMBIENTINGRAYSCALE: boolean;
  47247. OPACITY: boolean;
  47248. VERTEXALPHA: boolean;
  47249. OPACITYDIRECTUV: number;
  47250. OPACITYRGB: boolean;
  47251. ALPHATEST: boolean;
  47252. DEPTHPREPASS: boolean;
  47253. ALPHABLEND: boolean;
  47254. ALPHAFROMALBEDO: boolean;
  47255. ALPHATESTVALUE: string;
  47256. SPECULAROVERALPHA: boolean;
  47257. RADIANCEOVERALPHA: boolean;
  47258. ALPHAFRESNEL: boolean;
  47259. LINEARALPHAFRESNEL: boolean;
  47260. PREMULTIPLYALPHA: boolean;
  47261. EMISSIVE: boolean;
  47262. EMISSIVEDIRECTUV: number;
  47263. REFLECTIVITY: boolean;
  47264. REFLECTIVITYDIRECTUV: number;
  47265. SPECULARTERM: boolean;
  47266. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47267. MICROSURFACEAUTOMATIC: boolean;
  47268. LODBASEDMICROSFURACE: boolean;
  47269. MICROSURFACEMAP: boolean;
  47270. MICROSURFACEMAPDIRECTUV: number;
  47271. METALLICWORKFLOW: boolean;
  47272. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47273. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47274. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47275. AOSTOREINMETALMAPRED: boolean;
  47276. ENVIRONMENTBRDF: boolean;
  47277. ENVIRONMENTBRDF_RGBD: boolean;
  47278. NORMAL: boolean;
  47279. TANGENT: boolean;
  47280. BUMP: boolean;
  47281. BUMPDIRECTUV: number;
  47282. OBJECTSPACE_NORMALMAP: boolean;
  47283. PARALLAX: boolean;
  47284. PARALLAXOCCLUSION: boolean;
  47285. NORMALXYSCALE: boolean;
  47286. LIGHTMAP: boolean;
  47287. LIGHTMAPDIRECTUV: number;
  47288. USELIGHTMAPASSHADOWMAP: boolean;
  47289. GAMMALIGHTMAP: boolean;
  47290. REFLECTION: boolean;
  47291. REFLECTIONMAP_3D: boolean;
  47292. REFLECTIONMAP_SPHERICAL: boolean;
  47293. REFLECTIONMAP_PLANAR: boolean;
  47294. REFLECTIONMAP_CUBIC: boolean;
  47295. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47296. REFLECTIONMAP_PROJECTION: boolean;
  47297. REFLECTIONMAP_SKYBOX: boolean;
  47298. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47299. REFLECTIONMAP_EXPLICIT: boolean;
  47300. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47301. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47302. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47303. INVERTCUBICMAP: boolean;
  47304. USESPHERICALFROMREFLECTIONMAP: boolean;
  47305. USEIRRADIANCEMAP: boolean;
  47306. SPHERICAL_HARMONICS: boolean;
  47307. USESPHERICALINVERTEX: boolean;
  47308. REFLECTIONMAP_OPPOSITEZ: boolean;
  47309. LODINREFLECTIONALPHA: boolean;
  47310. GAMMAREFLECTION: boolean;
  47311. RGBDREFLECTION: boolean;
  47312. LINEARSPECULARREFLECTION: boolean;
  47313. RADIANCEOCCLUSION: boolean;
  47314. HORIZONOCCLUSION: boolean;
  47315. INSTANCES: boolean;
  47316. NUM_BONE_INFLUENCERS: number;
  47317. BonesPerMesh: number;
  47318. BONETEXTURE: boolean;
  47319. NONUNIFORMSCALING: boolean;
  47320. MORPHTARGETS: boolean;
  47321. MORPHTARGETS_NORMAL: boolean;
  47322. MORPHTARGETS_TANGENT: boolean;
  47323. NUM_MORPH_INFLUENCERS: number;
  47324. IMAGEPROCESSING: boolean;
  47325. VIGNETTE: boolean;
  47326. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47327. VIGNETTEBLENDMODEOPAQUE: boolean;
  47328. TONEMAPPING: boolean;
  47329. TONEMAPPING_ACES: boolean;
  47330. CONTRAST: boolean;
  47331. COLORCURVES: boolean;
  47332. COLORGRADING: boolean;
  47333. COLORGRADING3D: boolean;
  47334. SAMPLER3DGREENDEPTH: boolean;
  47335. SAMPLER3DBGRMAP: boolean;
  47336. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47337. EXPOSURE: boolean;
  47338. MULTIVIEW: boolean;
  47339. USEPHYSICALLIGHTFALLOFF: boolean;
  47340. USEGLTFLIGHTFALLOFF: boolean;
  47341. TWOSIDEDLIGHTING: boolean;
  47342. SHADOWFLOAT: boolean;
  47343. CLIPPLANE: boolean;
  47344. CLIPPLANE2: boolean;
  47345. CLIPPLANE3: boolean;
  47346. CLIPPLANE4: boolean;
  47347. POINTSIZE: boolean;
  47348. FOG: boolean;
  47349. LOGARITHMICDEPTH: boolean;
  47350. FORCENORMALFORWARD: boolean;
  47351. SPECULARAA: boolean;
  47352. CLEARCOAT: boolean;
  47353. CLEARCOAT_DEFAULTIOR: boolean;
  47354. CLEARCOAT_TEXTURE: boolean;
  47355. CLEARCOAT_TEXTUREDIRECTUV: number;
  47356. CLEARCOAT_BUMP: boolean;
  47357. CLEARCOAT_BUMPDIRECTUV: number;
  47358. CLEARCOAT_TINT: boolean;
  47359. CLEARCOAT_TINT_TEXTURE: boolean;
  47360. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47361. ANISOTROPIC: boolean;
  47362. ANISOTROPIC_TEXTURE: boolean;
  47363. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47364. BRDF_V_HEIGHT_CORRELATED: boolean;
  47365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47366. SHEEN: boolean;
  47367. SHEEN_TEXTURE: boolean;
  47368. SHEEN_TEXTUREDIRECTUV: number;
  47369. SHEEN_LINKWITHALBEDO: boolean;
  47370. SUBSURFACE: boolean;
  47371. SS_REFRACTION: boolean;
  47372. SS_TRANSLUCENCY: boolean;
  47373. SS_SCATERRING: boolean;
  47374. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47375. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47376. SS_REFRACTIONMAP_3D: boolean;
  47377. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47378. SS_LODINREFRACTIONALPHA: boolean;
  47379. SS_GAMMAREFRACTION: boolean;
  47380. SS_RGBDREFRACTION: boolean;
  47381. SS_LINEARSPECULARREFRACTION: boolean;
  47382. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47383. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47384. UNLIT: boolean;
  47385. DEBUGMODE: number;
  47386. /**
  47387. * Initializes the PBR Material defines.
  47388. */
  47389. constructor();
  47390. /**
  47391. * Resets the PBR Material defines.
  47392. */
  47393. reset(): void;
  47394. }
  47395. /**
  47396. * The Physically based material base class of BJS.
  47397. *
  47398. * This offers the main features of a standard PBR material.
  47399. * For more information, please refer to the documentation :
  47400. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47401. */
  47402. export abstract class PBRBaseMaterial extends PushMaterial {
  47403. /**
  47404. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47405. */
  47406. static readonly PBRMATERIAL_OPAQUE: number;
  47407. /**
  47408. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47409. */
  47410. static readonly PBRMATERIAL_ALPHATEST: number;
  47411. /**
  47412. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47413. */
  47414. static readonly PBRMATERIAL_ALPHABLEND: number;
  47415. /**
  47416. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47417. * They are also discarded below the alpha cutoff threshold to improve performances.
  47418. */
  47419. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47420. /**
  47421. * Defines the default value of how much AO map is occluding the analytical lights
  47422. * (point spot...).
  47423. */
  47424. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47425. /**
  47426. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47427. */
  47428. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47429. /**
  47430. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47431. * to enhance interoperability with other engines.
  47432. */
  47433. static readonly LIGHTFALLOFF_GLTF: number;
  47434. /**
  47435. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47436. * to enhance interoperability with other materials.
  47437. */
  47438. static readonly LIGHTFALLOFF_STANDARD: number;
  47439. /**
  47440. * Intensity of the direct lights e.g. the four lights available in your scene.
  47441. * This impacts both the direct diffuse and specular highlights.
  47442. */
  47443. protected _directIntensity: number;
  47444. /**
  47445. * Intensity of the emissive part of the material.
  47446. * This helps controlling the emissive effect without modifying the emissive color.
  47447. */
  47448. protected _emissiveIntensity: number;
  47449. /**
  47450. * Intensity of the environment e.g. how much the environment will light the object
  47451. * either through harmonics for rough material or through the refelction for shiny ones.
  47452. */
  47453. protected _environmentIntensity: number;
  47454. /**
  47455. * This is a special control allowing the reduction of the specular highlights coming from the
  47456. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47457. */
  47458. protected _specularIntensity: number;
  47459. /**
  47460. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47461. */
  47462. private _lightingInfos;
  47463. /**
  47464. * Debug Control allowing disabling the bump map on this material.
  47465. */
  47466. protected _disableBumpMap: boolean;
  47467. /**
  47468. * AKA Diffuse Texture in standard nomenclature.
  47469. */
  47470. protected _albedoTexture: Nullable<BaseTexture>;
  47471. /**
  47472. * AKA Occlusion Texture in other nomenclature.
  47473. */
  47474. protected _ambientTexture: Nullable<BaseTexture>;
  47475. /**
  47476. * AKA Occlusion Texture Intensity in other nomenclature.
  47477. */
  47478. protected _ambientTextureStrength: number;
  47479. /**
  47480. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47481. * 1 means it completely occludes it
  47482. * 0 mean it has no impact
  47483. */
  47484. protected _ambientTextureImpactOnAnalyticalLights: number;
  47485. /**
  47486. * Stores the alpha values in a texture.
  47487. */
  47488. protected _opacityTexture: Nullable<BaseTexture>;
  47489. /**
  47490. * Stores the reflection values in a texture.
  47491. */
  47492. protected _reflectionTexture: Nullable<BaseTexture>;
  47493. /**
  47494. * Stores the emissive values in a texture.
  47495. */
  47496. protected _emissiveTexture: Nullable<BaseTexture>;
  47497. /**
  47498. * AKA Specular texture in other nomenclature.
  47499. */
  47500. protected _reflectivityTexture: Nullable<BaseTexture>;
  47501. /**
  47502. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47503. */
  47504. protected _metallicTexture: Nullable<BaseTexture>;
  47505. /**
  47506. * Specifies the metallic scalar of the metallic/roughness workflow.
  47507. * Can also be used to scale the metalness values of the metallic texture.
  47508. */
  47509. protected _metallic: Nullable<number>;
  47510. /**
  47511. * Specifies the roughness scalar of the metallic/roughness workflow.
  47512. * Can also be used to scale the roughness values of the metallic texture.
  47513. */
  47514. protected _roughness: Nullable<number>;
  47515. /**
  47516. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47517. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47518. */
  47519. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47520. /**
  47521. * Stores surface normal data used to displace a mesh in a texture.
  47522. */
  47523. protected _bumpTexture: Nullable<BaseTexture>;
  47524. /**
  47525. * Stores the pre-calculated light information of a mesh in a texture.
  47526. */
  47527. protected _lightmapTexture: Nullable<BaseTexture>;
  47528. /**
  47529. * The color of a material in ambient lighting.
  47530. */
  47531. protected _ambientColor: Color3;
  47532. /**
  47533. * AKA Diffuse Color in other nomenclature.
  47534. */
  47535. protected _albedoColor: Color3;
  47536. /**
  47537. * AKA Specular Color in other nomenclature.
  47538. */
  47539. protected _reflectivityColor: Color3;
  47540. /**
  47541. * The color applied when light is reflected from a material.
  47542. */
  47543. protected _reflectionColor: Color3;
  47544. /**
  47545. * The color applied when light is emitted from a material.
  47546. */
  47547. protected _emissiveColor: Color3;
  47548. /**
  47549. * AKA Glossiness in other nomenclature.
  47550. */
  47551. protected _microSurface: number;
  47552. /**
  47553. * Specifies that the material will use the light map as a show map.
  47554. */
  47555. protected _useLightmapAsShadowmap: boolean;
  47556. /**
  47557. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47558. * makes the reflect vector face the model (under horizon).
  47559. */
  47560. protected _useHorizonOcclusion: boolean;
  47561. /**
  47562. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47563. * too much the area relying on ambient texture to define their ambient occlusion.
  47564. */
  47565. protected _useRadianceOcclusion: boolean;
  47566. /**
  47567. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47568. */
  47569. protected _useAlphaFromAlbedoTexture: boolean;
  47570. /**
  47571. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47572. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47573. */
  47574. protected _useSpecularOverAlpha: boolean;
  47575. /**
  47576. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47577. */
  47578. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47579. /**
  47580. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47581. */
  47582. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47583. /**
  47584. * Specifies if the metallic texture contains the roughness information in its green channel.
  47585. */
  47586. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47587. /**
  47588. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47589. */
  47590. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47591. /**
  47592. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47593. */
  47594. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47595. /**
  47596. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47597. */
  47598. protected _useAmbientInGrayScale: boolean;
  47599. /**
  47600. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47601. * The material will try to infer what glossiness each pixel should be.
  47602. */
  47603. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47604. /**
  47605. * Defines the falloff type used in this material.
  47606. * It by default is Physical.
  47607. */
  47608. protected _lightFalloff: number;
  47609. /**
  47610. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47611. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47612. */
  47613. protected _useRadianceOverAlpha: boolean;
  47614. /**
  47615. * Allows using an object space normal map (instead of tangent space).
  47616. */
  47617. protected _useObjectSpaceNormalMap: boolean;
  47618. /**
  47619. * Allows using the bump map in parallax mode.
  47620. */
  47621. protected _useParallax: boolean;
  47622. /**
  47623. * Allows using the bump map in parallax occlusion mode.
  47624. */
  47625. protected _useParallaxOcclusion: boolean;
  47626. /**
  47627. * Controls the scale bias of the parallax mode.
  47628. */
  47629. protected _parallaxScaleBias: number;
  47630. /**
  47631. * If sets to true, disables all the lights affecting the material.
  47632. */
  47633. protected _disableLighting: boolean;
  47634. /**
  47635. * Number of Simultaneous lights allowed on the material.
  47636. */
  47637. protected _maxSimultaneousLights: number;
  47638. /**
  47639. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47640. */
  47641. protected _invertNormalMapX: boolean;
  47642. /**
  47643. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47644. */
  47645. protected _invertNormalMapY: boolean;
  47646. /**
  47647. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47648. */
  47649. protected _twoSidedLighting: boolean;
  47650. /**
  47651. * Defines the alpha limits in alpha test mode.
  47652. */
  47653. protected _alphaCutOff: number;
  47654. /**
  47655. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47656. */
  47657. protected _forceAlphaTest: boolean;
  47658. /**
  47659. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47660. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47661. */
  47662. protected _useAlphaFresnel: boolean;
  47663. /**
  47664. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47665. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47666. */
  47667. protected _useLinearAlphaFresnel: boolean;
  47668. /**
  47669. * The transparency mode of the material.
  47670. */
  47671. protected _transparencyMode: Nullable<number>;
  47672. /**
  47673. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47674. * from cos thetav and roughness:
  47675. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47676. */
  47677. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47678. /**
  47679. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47680. */
  47681. protected _forceIrradianceInFragment: boolean;
  47682. /**
  47683. * Force normal to face away from face.
  47684. */
  47685. protected _forceNormalForward: boolean;
  47686. /**
  47687. * Enables specular anti aliasing in the PBR shader.
  47688. * It will both interacts on the Geometry for analytical and IBL lighting.
  47689. * It also prefilter the roughness map based on the bump values.
  47690. */
  47691. protected _enableSpecularAntiAliasing: boolean;
  47692. /**
  47693. * Default configuration related to image processing available in the PBR Material.
  47694. */
  47695. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47696. /**
  47697. * Keep track of the image processing observer to allow dispose and replace.
  47698. */
  47699. private _imageProcessingObserver;
  47700. /**
  47701. * Attaches a new image processing configuration to the PBR Material.
  47702. * @param configuration
  47703. */
  47704. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47705. /**
  47706. * Stores the available render targets.
  47707. */
  47708. private _renderTargets;
  47709. /**
  47710. * Sets the global ambient color for the material used in lighting calculations.
  47711. */
  47712. private _globalAmbientColor;
  47713. /**
  47714. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47715. */
  47716. private _useLogarithmicDepth;
  47717. /**
  47718. * If set to true, no lighting calculations will be applied.
  47719. */
  47720. private _unlit;
  47721. private _debugMode;
  47722. /**
  47723. * @hidden
  47724. * This is reserved for the inspector.
  47725. * Defines the material debug mode.
  47726. * It helps seeing only some components of the material while troubleshooting.
  47727. */
  47728. debugMode: number;
  47729. /**
  47730. * @hidden
  47731. * This is reserved for the inspector.
  47732. * Specify from where on screen the debug mode should start.
  47733. * The value goes from -1 (full screen) to 1 (not visible)
  47734. * It helps with side by side comparison against the final render
  47735. * This defaults to -1
  47736. */
  47737. private debugLimit;
  47738. /**
  47739. * @hidden
  47740. * This is reserved for the inspector.
  47741. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47742. * You can use the factor to better multiply the final value.
  47743. */
  47744. private debugFactor;
  47745. /**
  47746. * Defines the clear coat layer parameters for the material.
  47747. */
  47748. readonly clearCoat: PBRClearCoatConfiguration;
  47749. /**
  47750. * Defines the anisotropic parameters for the material.
  47751. */
  47752. readonly anisotropy: PBRAnisotropicConfiguration;
  47753. /**
  47754. * Defines the BRDF parameters for the material.
  47755. */
  47756. readonly brdf: PBRBRDFConfiguration;
  47757. /**
  47758. * Defines the Sheen parameters for the material.
  47759. */
  47760. readonly sheen: PBRSheenConfiguration;
  47761. /**
  47762. * Defines the SubSurface parameters for the material.
  47763. */
  47764. readonly subSurface: PBRSubSurfaceConfiguration;
  47765. /**
  47766. * Custom callback helping to override the default shader used in the material.
  47767. */
  47768. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47769. /**
  47770. * Instantiates a new PBRMaterial instance.
  47771. *
  47772. * @param name The material name
  47773. * @param scene The scene the material will be use in.
  47774. */
  47775. constructor(name: string, scene: Scene);
  47776. /**
  47777. * Gets a boolean indicating that current material needs to register RTT
  47778. */
  47779. readonly hasRenderTargetTextures: boolean;
  47780. /**
  47781. * Gets the name of the material class.
  47782. */
  47783. getClassName(): string;
  47784. /**
  47785. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47786. */
  47787. /**
  47788. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47789. */
  47790. useLogarithmicDepth: boolean;
  47791. /**
  47792. * Gets the current transparency mode.
  47793. */
  47794. /**
  47795. * Sets the transparency mode of the material.
  47796. *
  47797. * | Value | Type | Description |
  47798. * | ----- | ----------------------------------- | ----------- |
  47799. * | 0 | OPAQUE | |
  47800. * | 1 | ALPHATEST | |
  47801. * | 2 | ALPHABLEND | |
  47802. * | 3 | ALPHATESTANDBLEND | |
  47803. *
  47804. */
  47805. transparencyMode: Nullable<number>;
  47806. /**
  47807. * Returns true if alpha blending should be disabled.
  47808. */
  47809. private readonly _disableAlphaBlending;
  47810. /**
  47811. * Specifies whether or not this material should be rendered in alpha blend mode.
  47812. */
  47813. needAlphaBlending(): boolean;
  47814. /**
  47815. * Specifies if the mesh will require alpha blending.
  47816. * @param mesh - BJS mesh.
  47817. */
  47818. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47819. /**
  47820. * Specifies whether or not this material should be rendered in alpha test mode.
  47821. */
  47822. needAlphaTesting(): boolean;
  47823. /**
  47824. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47825. */
  47826. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47827. /**
  47828. * Gets the texture used for the alpha test.
  47829. */
  47830. getAlphaTestTexture(): Nullable<BaseTexture>;
  47831. /**
  47832. * Specifies that the submesh is ready to be used.
  47833. * @param mesh - BJS mesh.
  47834. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47835. * @param useInstances - Specifies that instances should be used.
  47836. * @returns - boolean indicating that the submesh is ready or not.
  47837. */
  47838. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47839. /**
  47840. * Specifies if the material uses metallic roughness workflow.
  47841. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47842. */
  47843. isMetallicWorkflow(): boolean;
  47844. private _prepareEffect;
  47845. private _prepareDefines;
  47846. /**
  47847. * Force shader compilation
  47848. */
  47849. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47850. clipPlane: boolean;
  47851. }>): void;
  47852. /**
  47853. * Initializes the uniform buffer layout for the shader.
  47854. */
  47855. buildUniformLayout(): void;
  47856. /**
  47857. * Unbinds the material from the mesh
  47858. */
  47859. unbind(): void;
  47860. /**
  47861. * Binds the submesh data.
  47862. * @param world - The world matrix.
  47863. * @param mesh - The BJS mesh.
  47864. * @param subMesh - A submesh of the BJS mesh.
  47865. */
  47866. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47867. /**
  47868. * Returns the animatable textures.
  47869. * @returns - Array of animatable textures.
  47870. */
  47871. getAnimatables(): IAnimatable[];
  47872. /**
  47873. * Returns the texture used for reflections.
  47874. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47875. */
  47876. private _getReflectionTexture;
  47877. /**
  47878. * Returns an array of the actively used textures.
  47879. * @returns - Array of BaseTextures
  47880. */
  47881. getActiveTextures(): BaseTexture[];
  47882. /**
  47883. * Checks to see if a texture is used in the material.
  47884. * @param texture - Base texture to use.
  47885. * @returns - Boolean specifying if a texture is used in the material.
  47886. */
  47887. hasTexture(texture: BaseTexture): boolean;
  47888. /**
  47889. * Disposes the resources of the material.
  47890. * @param forceDisposeEffect - Forces the disposal of effects.
  47891. * @param forceDisposeTextures - Forces the disposal of all textures.
  47892. */
  47893. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47894. }
  47895. }
  47896. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47897. import { Nullable } from "babylonjs/types";
  47898. import { Scene } from "babylonjs/scene";
  47899. import { Color3 } from "babylonjs/Maths/math";
  47900. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47901. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47902. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47903. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47904. /**
  47905. * The Physically based material of BJS.
  47906. *
  47907. * This offers the main features of a standard PBR material.
  47908. * For more information, please refer to the documentation :
  47909. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47910. */
  47911. export class PBRMaterial extends PBRBaseMaterial {
  47912. /**
  47913. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47914. */
  47915. static readonly PBRMATERIAL_OPAQUE: number;
  47916. /**
  47917. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47918. */
  47919. static readonly PBRMATERIAL_ALPHATEST: number;
  47920. /**
  47921. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47922. */
  47923. static readonly PBRMATERIAL_ALPHABLEND: number;
  47924. /**
  47925. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47926. * They are also discarded below the alpha cutoff threshold to improve performances.
  47927. */
  47928. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47929. /**
  47930. * Defines the default value of how much AO map is occluding the analytical lights
  47931. * (point spot...).
  47932. */
  47933. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47934. /**
  47935. * Intensity of the direct lights e.g. the four lights available in your scene.
  47936. * This impacts both the direct diffuse and specular highlights.
  47937. */
  47938. directIntensity: number;
  47939. /**
  47940. * Intensity of the emissive part of the material.
  47941. * This helps controlling the emissive effect without modifying the emissive color.
  47942. */
  47943. emissiveIntensity: number;
  47944. /**
  47945. * Intensity of the environment e.g. how much the environment will light the object
  47946. * either through harmonics for rough material or through the refelction for shiny ones.
  47947. */
  47948. environmentIntensity: number;
  47949. /**
  47950. * This is a special control allowing the reduction of the specular highlights coming from the
  47951. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47952. */
  47953. specularIntensity: number;
  47954. /**
  47955. * Debug Control allowing disabling the bump map on this material.
  47956. */
  47957. disableBumpMap: boolean;
  47958. /**
  47959. * AKA Diffuse Texture in standard nomenclature.
  47960. */
  47961. albedoTexture: BaseTexture;
  47962. /**
  47963. * AKA Occlusion Texture in other nomenclature.
  47964. */
  47965. ambientTexture: BaseTexture;
  47966. /**
  47967. * AKA Occlusion Texture Intensity in other nomenclature.
  47968. */
  47969. ambientTextureStrength: number;
  47970. /**
  47971. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47972. * 1 means it completely occludes it
  47973. * 0 mean it has no impact
  47974. */
  47975. ambientTextureImpactOnAnalyticalLights: number;
  47976. /**
  47977. * Stores the alpha values in a texture.
  47978. */
  47979. opacityTexture: BaseTexture;
  47980. /**
  47981. * Stores the reflection values in a texture.
  47982. */
  47983. reflectionTexture: Nullable<BaseTexture>;
  47984. /**
  47985. * Stores the emissive values in a texture.
  47986. */
  47987. emissiveTexture: BaseTexture;
  47988. /**
  47989. * AKA Specular texture in other nomenclature.
  47990. */
  47991. reflectivityTexture: BaseTexture;
  47992. /**
  47993. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47994. */
  47995. metallicTexture: BaseTexture;
  47996. /**
  47997. * Specifies the metallic scalar of the metallic/roughness workflow.
  47998. * Can also be used to scale the metalness values of the metallic texture.
  47999. */
  48000. metallic: Nullable<number>;
  48001. /**
  48002. * Specifies the roughness scalar of the metallic/roughness workflow.
  48003. * Can also be used to scale the roughness values of the metallic texture.
  48004. */
  48005. roughness: Nullable<number>;
  48006. /**
  48007. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48008. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48009. */
  48010. microSurfaceTexture: BaseTexture;
  48011. /**
  48012. * Stores surface normal data used to displace a mesh in a texture.
  48013. */
  48014. bumpTexture: BaseTexture;
  48015. /**
  48016. * Stores the pre-calculated light information of a mesh in a texture.
  48017. */
  48018. lightmapTexture: BaseTexture;
  48019. /**
  48020. * Stores the refracted light information in a texture.
  48021. */
  48022. refractionTexture: Nullable<BaseTexture>;
  48023. /**
  48024. * The color of a material in ambient lighting.
  48025. */
  48026. ambientColor: Color3;
  48027. /**
  48028. * AKA Diffuse Color in other nomenclature.
  48029. */
  48030. albedoColor: Color3;
  48031. /**
  48032. * AKA Specular Color in other nomenclature.
  48033. */
  48034. reflectivityColor: Color3;
  48035. /**
  48036. * The color reflected from the material.
  48037. */
  48038. reflectionColor: Color3;
  48039. /**
  48040. * The color emitted from the material.
  48041. */
  48042. emissiveColor: Color3;
  48043. /**
  48044. * AKA Glossiness in other nomenclature.
  48045. */
  48046. microSurface: number;
  48047. /**
  48048. * source material index of refraction (IOR)' / 'destination material IOR.
  48049. */
  48050. indexOfRefraction: number;
  48051. /**
  48052. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48053. */
  48054. invertRefractionY: boolean;
  48055. /**
  48056. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48057. * Materials half opaque for instance using refraction could benefit from this control.
  48058. */
  48059. linkRefractionWithTransparency: boolean;
  48060. /**
  48061. * If true, the light map contains occlusion information instead of lighting info.
  48062. */
  48063. useLightmapAsShadowmap: boolean;
  48064. /**
  48065. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48066. */
  48067. useAlphaFromAlbedoTexture: boolean;
  48068. /**
  48069. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48070. */
  48071. forceAlphaTest: boolean;
  48072. /**
  48073. * Defines the alpha limits in alpha test mode.
  48074. */
  48075. alphaCutOff: number;
  48076. /**
  48077. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48078. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48079. */
  48080. useSpecularOverAlpha: boolean;
  48081. /**
  48082. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48083. */
  48084. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48085. /**
  48086. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48087. */
  48088. useRoughnessFromMetallicTextureAlpha: boolean;
  48089. /**
  48090. * Specifies if the metallic texture contains the roughness information in its green channel.
  48091. */
  48092. useRoughnessFromMetallicTextureGreen: boolean;
  48093. /**
  48094. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48095. */
  48096. useMetallnessFromMetallicTextureBlue: boolean;
  48097. /**
  48098. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48099. */
  48100. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48101. /**
  48102. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48103. */
  48104. useAmbientInGrayScale: boolean;
  48105. /**
  48106. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48107. * The material will try to infer what glossiness each pixel should be.
  48108. */
  48109. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48110. /**
  48111. * BJS is using an harcoded light falloff based on a manually sets up range.
  48112. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48113. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48114. */
  48115. /**
  48116. * BJS is using an harcoded light falloff based on a manually sets up range.
  48117. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48118. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48119. */
  48120. usePhysicalLightFalloff: boolean;
  48121. /**
  48122. * In order to support the falloff compatibility with gltf, a special mode has been added
  48123. * to reproduce the gltf light falloff.
  48124. */
  48125. /**
  48126. * In order to support the falloff compatibility with gltf, a special mode has been added
  48127. * to reproduce the gltf light falloff.
  48128. */
  48129. useGLTFLightFalloff: boolean;
  48130. /**
  48131. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48132. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48133. */
  48134. useRadianceOverAlpha: boolean;
  48135. /**
  48136. * Allows using an object space normal map (instead of tangent space).
  48137. */
  48138. useObjectSpaceNormalMap: boolean;
  48139. /**
  48140. * Allows using the bump map in parallax mode.
  48141. */
  48142. useParallax: boolean;
  48143. /**
  48144. * Allows using the bump map in parallax occlusion mode.
  48145. */
  48146. useParallaxOcclusion: boolean;
  48147. /**
  48148. * Controls the scale bias of the parallax mode.
  48149. */
  48150. parallaxScaleBias: number;
  48151. /**
  48152. * If sets to true, disables all the lights affecting the material.
  48153. */
  48154. disableLighting: boolean;
  48155. /**
  48156. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48157. */
  48158. forceIrradianceInFragment: boolean;
  48159. /**
  48160. * Number of Simultaneous lights allowed on the material.
  48161. */
  48162. maxSimultaneousLights: number;
  48163. /**
  48164. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48165. */
  48166. invertNormalMapX: boolean;
  48167. /**
  48168. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48169. */
  48170. invertNormalMapY: boolean;
  48171. /**
  48172. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48173. */
  48174. twoSidedLighting: boolean;
  48175. /**
  48176. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48177. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48178. */
  48179. useAlphaFresnel: boolean;
  48180. /**
  48181. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48182. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48183. */
  48184. useLinearAlphaFresnel: boolean;
  48185. /**
  48186. * Let user defines the brdf lookup texture used for IBL.
  48187. * A default 8bit version is embedded but you could point at :
  48188. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  48189. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48190. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48191. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48192. */
  48193. environmentBRDFTexture: Nullable<BaseTexture>;
  48194. /**
  48195. * Force normal to face away from face.
  48196. */
  48197. forceNormalForward: boolean;
  48198. /**
  48199. * Enables specular anti aliasing in the PBR shader.
  48200. * It will both interacts on the Geometry for analytical and IBL lighting.
  48201. * It also prefilter the roughness map based on the bump values.
  48202. */
  48203. enableSpecularAntiAliasing: boolean;
  48204. /**
  48205. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48206. * makes the reflect vector face the model (under horizon).
  48207. */
  48208. useHorizonOcclusion: boolean;
  48209. /**
  48210. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48211. * too much the area relying on ambient texture to define their ambient occlusion.
  48212. */
  48213. useRadianceOcclusion: boolean;
  48214. /**
  48215. * If set to true, no lighting calculations will be applied.
  48216. */
  48217. unlit: boolean;
  48218. /**
  48219. * Gets the image processing configuration used either in this material.
  48220. */
  48221. /**
  48222. * Sets the Default image processing configuration used either in the this material.
  48223. *
  48224. * If sets to null, the scene one is in use.
  48225. */
  48226. imageProcessingConfiguration: ImageProcessingConfiguration;
  48227. /**
  48228. * Gets wether the color curves effect is enabled.
  48229. */
  48230. /**
  48231. * Sets wether the color curves effect is enabled.
  48232. */
  48233. cameraColorCurvesEnabled: boolean;
  48234. /**
  48235. * Gets wether the color grading effect is enabled.
  48236. */
  48237. /**
  48238. * Gets wether the color grading effect is enabled.
  48239. */
  48240. cameraColorGradingEnabled: boolean;
  48241. /**
  48242. * Gets wether tonemapping is enabled or not.
  48243. */
  48244. /**
  48245. * Sets wether tonemapping is enabled or not
  48246. */
  48247. cameraToneMappingEnabled: boolean;
  48248. /**
  48249. * The camera exposure used on this material.
  48250. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48251. * This corresponds to a photographic exposure.
  48252. */
  48253. /**
  48254. * The camera exposure used on this material.
  48255. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48256. * This corresponds to a photographic exposure.
  48257. */
  48258. cameraExposure: number;
  48259. /**
  48260. * Gets The camera contrast used on this material.
  48261. */
  48262. /**
  48263. * Sets The camera contrast used on this material.
  48264. */
  48265. cameraContrast: number;
  48266. /**
  48267. * Gets the Color Grading 2D Lookup Texture.
  48268. */
  48269. /**
  48270. * Sets the Color Grading 2D Lookup Texture.
  48271. */
  48272. cameraColorGradingTexture: Nullable<BaseTexture>;
  48273. /**
  48274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48276. * 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;
  48277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48278. */
  48279. /**
  48280. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48281. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48282. * 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;
  48283. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48284. */
  48285. cameraColorCurves: Nullable<ColorCurves>;
  48286. /**
  48287. * Instantiates a new PBRMaterial instance.
  48288. *
  48289. * @param name The material name
  48290. * @param scene The scene the material will be use in.
  48291. */
  48292. constructor(name: string, scene: Scene);
  48293. /**
  48294. * Returns the name of this material class.
  48295. */
  48296. getClassName(): string;
  48297. /**
  48298. * Makes a duplicate of the current material.
  48299. * @param name - name to use for the new material.
  48300. */
  48301. clone(name: string): PBRMaterial;
  48302. /**
  48303. * Serializes this PBR Material.
  48304. * @returns - An object with the serialized material.
  48305. */
  48306. serialize(): any;
  48307. /**
  48308. * Parses a PBR Material from a serialized object.
  48309. * @param source - Serialized object.
  48310. * @param scene - BJS scene instance.
  48311. * @param rootUrl - url for the scene object
  48312. * @returns - PBRMaterial
  48313. */
  48314. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48315. }
  48316. }
  48317. declare module "babylonjs/Misc/dds" {
  48318. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48319. import { Engine } from "babylonjs/Engines/engine";
  48320. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48321. import { Nullable } from "babylonjs/types";
  48322. import { Scene } from "babylonjs/scene";
  48323. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48324. /**
  48325. * Direct draw surface info
  48326. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48327. */
  48328. export interface DDSInfo {
  48329. /**
  48330. * Width of the texture
  48331. */
  48332. width: number;
  48333. /**
  48334. * Width of the texture
  48335. */
  48336. height: number;
  48337. /**
  48338. * Number of Mipmaps for the texture
  48339. * @see https://en.wikipedia.org/wiki/Mipmap
  48340. */
  48341. mipmapCount: number;
  48342. /**
  48343. * If the textures format is a known fourCC format
  48344. * @see https://www.fourcc.org/
  48345. */
  48346. isFourCC: boolean;
  48347. /**
  48348. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48349. */
  48350. isRGB: boolean;
  48351. /**
  48352. * If the texture is a lumincance format
  48353. */
  48354. isLuminance: boolean;
  48355. /**
  48356. * If this is a cube texture
  48357. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48358. */
  48359. isCube: boolean;
  48360. /**
  48361. * If the texture is a compressed format eg. FOURCC_DXT1
  48362. */
  48363. isCompressed: boolean;
  48364. /**
  48365. * The dxgiFormat of the texture
  48366. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48367. */
  48368. dxgiFormat: number;
  48369. /**
  48370. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48371. */
  48372. textureType: number;
  48373. /**
  48374. * Sphericle polynomial created for the dds texture
  48375. */
  48376. sphericalPolynomial?: SphericalPolynomial;
  48377. }
  48378. /**
  48379. * Class used to provide DDS decompression tools
  48380. */
  48381. export class DDSTools {
  48382. /**
  48383. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48384. */
  48385. static StoreLODInAlphaChannel: boolean;
  48386. /**
  48387. * Gets DDS information from an array buffer
  48388. * @param arrayBuffer defines the array buffer to read data from
  48389. * @returns the DDS information
  48390. */
  48391. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48392. private static _FloatView;
  48393. private static _Int32View;
  48394. private static _ToHalfFloat;
  48395. private static _FromHalfFloat;
  48396. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48397. private static _GetHalfFloatRGBAArrayBuffer;
  48398. private static _GetFloatRGBAArrayBuffer;
  48399. private static _GetFloatAsUIntRGBAArrayBuffer;
  48400. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48401. private static _GetRGBAArrayBuffer;
  48402. private static _ExtractLongWordOrder;
  48403. private static _GetRGBArrayBuffer;
  48404. private static _GetLuminanceArrayBuffer;
  48405. /**
  48406. * Uploads DDS Levels to a Babylon Texture
  48407. * @hidden
  48408. */
  48409. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48410. }
  48411. module "babylonjs/Engines/engine" {
  48412. interface Engine {
  48413. /**
  48414. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48415. * @param rootUrl defines the url where the file to load is located
  48416. * @param scene defines the current scene
  48417. * @param lodScale defines scale to apply to the mip map selection
  48418. * @param lodOffset defines offset to apply to the mip map selection
  48419. * @param onLoad defines an optional callback raised when the texture is loaded
  48420. * @param onError defines an optional callback raised if there is an issue to load the texture
  48421. * @param format defines the format of the data
  48422. * @param forcedExtension defines the extension to use to pick the right loader
  48423. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48424. * @returns the cube texture as an InternalTexture
  48425. */
  48426. 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;
  48427. }
  48428. }
  48429. }
  48430. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48431. import { Nullable } from "babylonjs/types";
  48432. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48433. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48434. /**
  48435. * Implementation of the DDS Texture Loader.
  48436. * @hidden
  48437. */
  48438. export class _DDSTextureLoader implements IInternalTextureLoader {
  48439. /**
  48440. * Defines wether the loader supports cascade loading the different faces.
  48441. */
  48442. readonly supportCascades: boolean;
  48443. /**
  48444. * This returns if the loader support the current file information.
  48445. * @param extension defines the file extension of the file being loaded
  48446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48447. * @param fallback defines the fallback internal texture if any
  48448. * @param isBase64 defines whether the texture is encoded as a base64
  48449. * @param isBuffer defines whether the texture data are stored as a buffer
  48450. * @returns true if the loader can load the specified file
  48451. */
  48452. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48453. /**
  48454. * Transform the url before loading if required.
  48455. * @param rootUrl the url of the texture
  48456. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48457. * @returns the transformed texture
  48458. */
  48459. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48460. /**
  48461. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48462. * @param rootUrl the url of the texture
  48463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48464. * @returns the fallback texture
  48465. */
  48466. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48467. /**
  48468. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48469. * @param data contains the texture data
  48470. * @param texture defines the BabylonJS internal texture
  48471. * @param createPolynomials will be true if polynomials have been requested
  48472. * @param onLoad defines the callback to trigger once the texture is ready
  48473. * @param onError defines the callback to trigger in case of error
  48474. */
  48475. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48476. /**
  48477. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48478. * @param data contains the texture data
  48479. * @param texture defines the BabylonJS internal texture
  48480. * @param callback defines the method to call once ready to upload
  48481. */
  48482. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48483. }
  48484. }
  48485. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48486. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48487. /** @hidden */
  48488. export var rgbdEncodePixelShader: {
  48489. name: string;
  48490. shader: string;
  48491. };
  48492. }
  48493. declare module "babylonjs/Misc/environmentTextureTools" {
  48494. import { Nullable } from "babylonjs/types";
  48495. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48497. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48498. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48499. import "babylonjs/Shaders/rgbdEncode.fragment";
  48500. import "babylonjs/Shaders/rgbdDecode.fragment";
  48501. /**
  48502. * Raw texture data and descriptor sufficient for WebGL texture upload
  48503. */
  48504. export interface EnvironmentTextureInfo {
  48505. /**
  48506. * Version of the environment map
  48507. */
  48508. version: number;
  48509. /**
  48510. * Width of image
  48511. */
  48512. width: number;
  48513. /**
  48514. * Irradiance information stored in the file.
  48515. */
  48516. irradiance: any;
  48517. /**
  48518. * Specular information stored in the file.
  48519. */
  48520. specular: any;
  48521. }
  48522. /**
  48523. * Sets of helpers addressing the serialization and deserialization of environment texture
  48524. * stored in a BabylonJS env file.
  48525. * Those files are usually stored as .env files.
  48526. */
  48527. export class EnvironmentTextureTools {
  48528. /**
  48529. * Magic number identifying the env file.
  48530. */
  48531. private static _MagicBytes;
  48532. /**
  48533. * Gets the environment info from an env file.
  48534. * @param data The array buffer containing the .env bytes.
  48535. * @returns the environment file info (the json header) if successfully parsed.
  48536. */
  48537. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48538. /**
  48539. * Creates an environment texture from a loaded cube texture.
  48540. * @param texture defines the cube texture to convert in env file
  48541. * @return a promise containing the environment data if succesfull.
  48542. */
  48543. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48544. /**
  48545. * Creates a JSON representation of the spherical data.
  48546. * @param texture defines the texture containing the polynomials
  48547. * @return the JSON representation of the spherical info
  48548. */
  48549. private static _CreateEnvTextureIrradiance;
  48550. /**
  48551. * Uploads the texture info contained in the env file to the GPU.
  48552. * @param texture defines the internal texture to upload to
  48553. * @param arrayBuffer defines the buffer cotaining the data to load
  48554. * @param info defines the texture info retrieved through the GetEnvInfo method
  48555. * @returns a promise
  48556. */
  48557. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48558. /**
  48559. * Uploads the levels of image data to the GPU.
  48560. * @param texture defines the internal texture to upload to
  48561. * @param imageData defines the array buffer views of image data [mipmap][face]
  48562. * @returns a promise
  48563. */
  48564. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48565. /**
  48566. * Uploads spherical polynomials information to the texture.
  48567. * @param texture defines the texture we are trying to upload the information to
  48568. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48569. */
  48570. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48571. /** @hidden */
  48572. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48573. }
  48574. }
  48575. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48576. import { Nullable } from "babylonjs/types";
  48577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48578. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48579. /**
  48580. * Implementation of the ENV Texture Loader.
  48581. * @hidden
  48582. */
  48583. export class _ENVTextureLoader implements IInternalTextureLoader {
  48584. /**
  48585. * Defines wether the loader supports cascade loading the different faces.
  48586. */
  48587. readonly supportCascades: boolean;
  48588. /**
  48589. * This returns if the loader support the current file information.
  48590. * @param extension defines the file extension of the file being loaded
  48591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48592. * @param fallback defines the fallback internal texture if any
  48593. * @param isBase64 defines whether the texture is encoded as a base64
  48594. * @param isBuffer defines whether the texture data are stored as a buffer
  48595. * @returns true if the loader can load the specified file
  48596. */
  48597. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48598. /**
  48599. * Transform the url before loading if required.
  48600. * @param rootUrl the url of the texture
  48601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48602. * @returns the transformed texture
  48603. */
  48604. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48605. /**
  48606. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48607. * @param rootUrl the url of the texture
  48608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48609. * @returns the fallback texture
  48610. */
  48611. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48612. /**
  48613. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48614. * @param data contains the texture data
  48615. * @param texture defines the BabylonJS internal texture
  48616. * @param createPolynomials will be true if polynomials have been requested
  48617. * @param onLoad defines the callback to trigger once the texture is ready
  48618. * @param onError defines the callback to trigger in case of error
  48619. */
  48620. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48621. /**
  48622. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48623. * @param data contains the texture data
  48624. * @param texture defines the BabylonJS internal texture
  48625. * @param callback defines the method to call once ready to upload
  48626. */
  48627. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48628. }
  48629. }
  48630. declare module "babylonjs/Misc/khronosTextureContainer" {
  48631. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48632. /**
  48633. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48634. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48635. */
  48636. export class KhronosTextureContainer {
  48637. /** contents of the KTX container file */
  48638. arrayBuffer: any;
  48639. private static HEADER_LEN;
  48640. private static COMPRESSED_2D;
  48641. private static COMPRESSED_3D;
  48642. private static TEX_2D;
  48643. private static TEX_3D;
  48644. /**
  48645. * Gets the openGL type
  48646. */
  48647. glType: number;
  48648. /**
  48649. * Gets the openGL type size
  48650. */
  48651. glTypeSize: number;
  48652. /**
  48653. * Gets the openGL format
  48654. */
  48655. glFormat: number;
  48656. /**
  48657. * Gets the openGL internal format
  48658. */
  48659. glInternalFormat: number;
  48660. /**
  48661. * Gets the base internal format
  48662. */
  48663. glBaseInternalFormat: number;
  48664. /**
  48665. * Gets image width in pixel
  48666. */
  48667. pixelWidth: number;
  48668. /**
  48669. * Gets image height in pixel
  48670. */
  48671. pixelHeight: number;
  48672. /**
  48673. * Gets image depth in pixels
  48674. */
  48675. pixelDepth: number;
  48676. /**
  48677. * Gets the number of array elements
  48678. */
  48679. numberOfArrayElements: number;
  48680. /**
  48681. * Gets the number of faces
  48682. */
  48683. numberOfFaces: number;
  48684. /**
  48685. * Gets the number of mipmap levels
  48686. */
  48687. numberOfMipmapLevels: number;
  48688. /**
  48689. * Gets the bytes of key value data
  48690. */
  48691. bytesOfKeyValueData: number;
  48692. /**
  48693. * Gets the load type
  48694. */
  48695. loadType: number;
  48696. /**
  48697. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48698. */
  48699. isInvalid: boolean;
  48700. /**
  48701. * Creates a new KhronosTextureContainer
  48702. * @param arrayBuffer contents of the KTX container file
  48703. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48704. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48705. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48706. */
  48707. constructor(
  48708. /** contents of the KTX container file */
  48709. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48710. /**
  48711. * Uploads KTX content to a Babylon Texture.
  48712. * It is assumed that the texture has already been created & is currently bound
  48713. * @hidden
  48714. */
  48715. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48716. private _upload2DCompressedLevels;
  48717. }
  48718. }
  48719. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48720. import { Nullable } from "babylonjs/types";
  48721. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48722. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48723. /**
  48724. * Implementation of the KTX Texture Loader.
  48725. * @hidden
  48726. */
  48727. export class _KTXTextureLoader implements IInternalTextureLoader {
  48728. /**
  48729. * Defines wether the loader supports cascade loading the different faces.
  48730. */
  48731. readonly supportCascades: boolean;
  48732. /**
  48733. * This returns if the loader support the current file information.
  48734. * @param extension defines the file extension of the file being loaded
  48735. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48736. * @param fallback defines the fallback internal texture if any
  48737. * @param isBase64 defines whether the texture is encoded as a base64
  48738. * @param isBuffer defines whether the texture data are stored as a buffer
  48739. * @returns true if the loader can load the specified file
  48740. */
  48741. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48742. /**
  48743. * Transform the url before loading if required.
  48744. * @param rootUrl the url of the texture
  48745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48746. * @returns the transformed texture
  48747. */
  48748. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48749. /**
  48750. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48751. * @param rootUrl the url of the texture
  48752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48753. * @returns the fallback texture
  48754. */
  48755. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48756. /**
  48757. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48758. * @param data contains the texture data
  48759. * @param texture defines the BabylonJS internal texture
  48760. * @param createPolynomials will be true if polynomials have been requested
  48761. * @param onLoad defines the callback to trigger once the texture is ready
  48762. * @param onError defines the callback to trigger in case of error
  48763. */
  48764. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48765. /**
  48766. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48767. * @param data contains the texture data
  48768. * @param texture defines the BabylonJS internal texture
  48769. * @param callback defines the method to call once ready to upload
  48770. */
  48771. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48772. }
  48773. }
  48774. declare module "babylonjs/Helpers/sceneHelpers" {
  48775. import { Nullable } from "babylonjs/types";
  48776. import { Mesh } from "babylonjs/Meshes/mesh";
  48777. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48778. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48779. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48780. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48781. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48782. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48783. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48784. import "babylonjs/Meshes/Builders/boxBuilder";
  48785. /** @hidden */
  48786. export var _forceSceneHelpersToBundle: boolean;
  48787. module "babylonjs/scene" {
  48788. interface Scene {
  48789. /**
  48790. * Creates a default light for the scene.
  48791. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48792. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48793. */
  48794. createDefaultLight(replace?: boolean): void;
  48795. /**
  48796. * Creates a default camera for the scene.
  48797. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48798. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48799. * @param replace has default false, when true replaces the active camera in the scene
  48800. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48801. */
  48802. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48803. /**
  48804. * Creates a default camera and a default light.
  48805. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48806. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48807. * @param replace has the default false, when true replaces the active camera/light in the scene
  48808. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48809. */
  48810. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48811. /**
  48812. * Creates a new sky box
  48813. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48814. * @param environmentTexture defines the texture to use as environment texture
  48815. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48816. * @param scale defines the overall scale of the skybox
  48817. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48818. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48819. * @returns a new mesh holding the sky box
  48820. */
  48821. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48822. /**
  48823. * Creates a new environment
  48824. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48825. * @param options defines the options you can use to configure the environment
  48826. * @returns the new EnvironmentHelper
  48827. */
  48828. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48829. /**
  48830. * Creates a new VREXperienceHelper
  48831. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48832. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48833. * @returns a new VREXperienceHelper
  48834. */
  48835. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48836. /**
  48837. * Creates a new XREXperienceHelper
  48838. * @see http://doc.babylonjs.com/how_to/webxr
  48839. * @returns a promise for a new XREXperienceHelper
  48840. */
  48841. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48842. }
  48843. }
  48844. }
  48845. declare module "babylonjs/Helpers/videoDome" {
  48846. import { Scene } from "babylonjs/scene";
  48847. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48848. import { Mesh } from "babylonjs/Meshes/mesh";
  48849. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48850. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48851. import "babylonjs/Meshes/Builders/sphereBuilder";
  48852. /**
  48853. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48854. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48855. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48856. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48857. */
  48858. export class VideoDome extends TransformNode {
  48859. /**
  48860. * Define the video source as a Monoscopic panoramic 360 video.
  48861. */
  48862. static readonly MODE_MONOSCOPIC: number;
  48863. /**
  48864. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48865. */
  48866. static readonly MODE_TOPBOTTOM: number;
  48867. /**
  48868. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48869. */
  48870. static readonly MODE_SIDEBYSIDE: number;
  48871. private _useDirectMapping;
  48872. /**
  48873. * The video texture being displayed on the sphere
  48874. */
  48875. protected _videoTexture: VideoTexture;
  48876. /**
  48877. * Gets the video texture being displayed on the sphere
  48878. */
  48879. readonly videoTexture: VideoTexture;
  48880. /**
  48881. * The skybox material
  48882. */
  48883. protected _material: BackgroundMaterial;
  48884. /**
  48885. * The surface used for the skybox
  48886. */
  48887. protected _mesh: Mesh;
  48888. /**
  48889. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48890. * Also see the options.resolution property.
  48891. */
  48892. fovMultiplier: number;
  48893. private _videoMode;
  48894. /**
  48895. * Gets or set the current video mode for the video. It can be:
  48896. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48897. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48898. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48899. */
  48900. videoMode: number;
  48901. /**
  48902. * Oberserver used in Stereoscopic VR Mode.
  48903. */
  48904. private _onBeforeCameraRenderObserver;
  48905. /**
  48906. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48907. * @param name Element's name, child elements will append suffixes for their own names.
  48908. * @param urlsOrVideo defines the url(s) or the video element to use
  48909. * @param options An object containing optional or exposed sub element properties
  48910. */
  48911. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48912. resolution?: number;
  48913. clickToPlay?: boolean;
  48914. autoPlay?: boolean;
  48915. loop?: boolean;
  48916. size?: number;
  48917. poster?: string;
  48918. faceForward?: boolean;
  48919. useDirectMapping?: boolean;
  48920. }, scene: Scene);
  48921. private _changeVideoMode;
  48922. /**
  48923. * Releases resources associated with this node.
  48924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48926. */
  48927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48928. }
  48929. }
  48930. declare module "babylonjs/Helpers/index" {
  48931. export * from "babylonjs/Helpers/environmentHelper";
  48932. export * from "babylonjs/Helpers/photoDome";
  48933. export * from "babylonjs/Helpers/sceneHelpers";
  48934. export * from "babylonjs/Helpers/videoDome";
  48935. }
  48936. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48937. import { PerfCounter } from "babylonjs/Misc/tools";
  48938. import { IDisposable } from "babylonjs/scene";
  48939. import { Engine } from "babylonjs/Engines/engine";
  48940. /**
  48941. * This class can be used to get instrumentation data from a Babylon engine
  48942. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48943. */
  48944. export class EngineInstrumentation implements IDisposable {
  48945. /**
  48946. * Define the instrumented engine.
  48947. */
  48948. engine: Engine;
  48949. private _captureGPUFrameTime;
  48950. private _gpuFrameTimeToken;
  48951. private _gpuFrameTime;
  48952. private _captureShaderCompilationTime;
  48953. private _shaderCompilationTime;
  48954. private _onBeginFrameObserver;
  48955. private _onEndFrameObserver;
  48956. private _onBeforeShaderCompilationObserver;
  48957. private _onAfterShaderCompilationObserver;
  48958. /**
  48959. * Gets the perf counter used for GPU frame time
  48960. */
  48961. readonly gpuFrameTimeCounter: PerfCounter;
  48962. /**
  48963. * Gets the GPU frame time capture status
  48964. */
  48965. /**
  48966. * Enable or disable the GPU frame time capture
  48967. */
  48968. captureGPUFrameTime: boolean;
  48969. /**
  48970. * Gets the perf counter used for shader compilation time
  48971. */
  48972. readonly shaderCompilationTimeCounter: PerfCounter;
  48973. /**
  48974. * Gets the shader compilation time capture status
  48975. */
  48976. /**
  48977. * Enable or disable the shader compilation time capture
  48978. */
  48979. captureShaderCompilationTime: boolean;
  48980. /**
  48981. * Instantiates a new engine instrumentation.
  48982. * This class can be used to get instrumentation data from a Babylon engine
  48983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48984. * @param engine Defines the engine to instrument
  48985. */
  48986. constructor(
  48987. /**
  48988. * Define the instrumented engine.
  48989. */
  48990. engine: Engine);
  48991. /**
  48992. * Dispose and release associated resources.
  48993. */
  48994. dispose(): void;
  48995. }
  48996. }
  48997. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48998. import { PerfCounter } from "babylonjs/Misc/tools";
  48999. import { Scene, IDisposable } from "babylonjs/scene";
  49000. /**
  49001. * This class can be used to get instrumentation data from a Babylon engine
  49002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49003. */
  49004. export class SceneInstrumentation implements IDisposable {
  49005. /**
  49006. * Defines the scene to instrument
  49007. */
  49008. scene: Scene;
  49009. private _captureActiveMeshesEvaluationTime;
  49010. private _activeMeshesEvaluationTime;
  49011. private _captureRenderTargetsRenderTime;
  49012. private _renderTargetsRenderTime;
  49013. private _captureFrameTime;
  49014. private _frameTime;
  49015. private _captureRenderTime;
  49016. private _renderTime;
  49017. private _captureInterFrameTime;
  49018. private _interFrameTime;
  49019. private _captureParticlesRenderTime;
  49020. private _particlesRenderTime;
  49021. private _captureSpritesRenderTime;
  49022. private _spritesRenderTime;
  49023. private _capturePhysicsTime;
  49024. private _physicsTime;
  49025. private _captureAnimationsTime;
  49026. private _animationsTime;
  49027. private _captureCameraRenderTime;
  49028. private _cameraRenderTime;
  49029. private _onBeforeActiveMeshesEvaluationObserver;
  49030. private _onAfterActiveMeshesEvaluationObserver;
  49031. private _onBeforeRenderTargetsRenderObserver;
  49032. private _onAfterRenderTargetsRenderObserver;
  49033. private _onAfterRenderObserver;
  49034. private _onBeforeDrawPhaseObserver;
  49035. private _onAfterDrawPhaseObserver;
  49036. private _onBeforeAnimationsObserver;
  49037. private _onBeforeParticlesRenderingObserver;
  49038. private _onAfterParticlesRenderingObserver;
  49039. private _onBeforeSpritesRenderingObserver;
  49040. private _onAfterSpritesRenderingObserver;
  49041. private _onBeforePhysicsObserver;
  49042. private _onAfterPhysicsObserver;
  49043. private _onAfterAnimationsObserver;
  49044. private _onBeforeCameraRenderObserver;
  49045. private _onAfterCameraRenderObserver;
  49046. /**
  49047. * Gets the perf counter used for active meshes evaluation time
  49048. */
  49049. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49050. /**
  49051. * Gets the active meshes evaluation time capture status
  49052. */
  49053. /**
  49054. * Enable or disable the active meshes evaluation time capture
  49055. */
  49056. captureActiveMeshesEvaluationTime: boolean;
  49057. /**
  49058. * Gets the perf counter used for render targets render time
  49059. */
  49060. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49061. /**
  49062. * Gets the render targets render time capture status
  49063. */
  49064. /**
  49065. * Enable or disable the render targets render time capture
  49066. */
  49067. captureRenderTargetsRenderTime: boolean;
  49068. /**
  49069. * Gets the perf counter used for particles render time
  49070. */
  49071. readonly particlesRenderTimeCounter: PerfCounter;
  49072. /**
  49073. * Gets the particles render time capture status
  49074. */
  49075. /**
  49076. * Enable or disable the particles render time capture
  49077. */
  49078. captureParticlesRenderTime: boolean;
  49079. /**
  49080. * Gets the perf counter used for sprites render time
  49081. */
  49082. readonly spritesRenderTimeCounter: PerfCounter;
  49083. /**
  49084. * Gets the sprites render time capture status
  49085. */
  49086. /**
  49087. * Enable or disable the sprites render time capture
  49088. */
  49089. captureSpritesRenderTime: boolean;
  49090. /**
  49091. * Gets the perf counter used for physics time
  49092. */
  49093. readonly physicsTimeCounter: PerfCounter;
  49094. /**
  49095. * Gets the physics time capture status
  49096. */
  49097. /**
  49098. * Enable or disable the physics time capture
  49099. */
  49100. capturePhysicsTime: boolean;
  49101. /**
  49102. * Gets the perf counter used for animations time
  49103. */
  49104. readonly animationsTimeCounter: PerfCounter;
  49105. /**
  49106. * Gets the animations time capture status
  49107. */
  49108. /**
  49109. * Enable or disable the animations time capture
  49110. */
  49111. captureAnimationsTime: boolean;
  49112. /**
  49113. * Gets the perf counter used for frame time capture
  49114. */
  49115. readonly frameTimeCounter: PerfCounter;
  49116. /**
  49117. * Gets the frame time capture status
  49118. */
  49119. /**
  49120. * Enable or disable the frame time capture
  49121. */
  49122. captureFrameTime: boolean;
  49123. /**
  49124. * Gets the perf counter used for inter-frames time capture
  49125. */
  49126. readonly interFrameTimeCounter: PerfCounter;
  49127. /**
  49128. * Gets the inter-frames time capture status
  49129. */
  49130. /**
  49131. * Enable or disable the inter-frames time capture
  49132. */
  49133. captureInterFrameTime: boolean;
  49134. /**
  49135. * Gets the perf counter used for render time capture
  49136. */
  49137. readonly renderTimeCounter: PerfCounter;
  49138. /**
  49139. * Gets the render time capture status
  49140. */
  49141. /**
  49142. * Enable or disable the render time capture
  49143. */
  49144. captureRenderTime: boolean;
  49145. /**
  49146. * Gets the perf counter used for camera render time capture
  49147. */
  49148. readonly cameraRenderTimeCounter: PerfCounter;
  49149. /**
  49150. * Gets the camera render time capture status
  49151. */
  49152. /**
  49153. * Enable or disable the camera render time capture
  49154. */
  49155. captureCameraRenderTime: boolean;
  49156. /**
  49157. * Gets the perf counter used for draw calls
  49158. */
  49159. readonly drawCallsCounter: PerfCounter;
  49160. /**
  49161. * Instantiates a new scene instrumentation.
  49162. * This class can be used to get instrumentation data from a Babylon engine
  49163. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49164. * @param scene Defines the scene to instrument
  49165. */
  49166. constructor(
  49167. /**
  49168. * Defines the scene to instrument
  49169. */
  49170. scene: Scene);
  49171. /**
  49172. * Dispose and release associated resources.
  49173. */
  49174. dispose(): void;
  49175. }
  49176. }
  49177. declare module "babylonjs/Instrumentation/index" {
  49178. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49179. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49180. export * from "babylonjs/Instrumentation/timeToken";
  49181. }
  49182. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49183. /** @hidden */
  49184. export var glowMapGenerationPixelShader: {
  49185. name: string;
  49186. shader: string;
  49187. };
  49188. }
  49189. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49190. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49192. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49193. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49194. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49195. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49196. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49197. /** @hidden */
  49198. export var glowMapGenerationVertexShader: {
  49199. name: string;
  49200. shader: string;
  49201. };
  49202. }
  49203. declare module "babylonjs/Layers/effectLayer" {
  49204. import { Observable } from "babylonjs/Misc/observable";
  49205. import { Nullable } from "babylonjs/types";
  49206. import { Camera } from "babylonjs/Cameras/camera";
  49207. import { Scene } from "babylonjs/scene";
  49208. import { Color4, ISize } from "babylonjs/Maths/math";
  49209. import { Engine } from "babylonjs/Engines/engine";
  49210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49212. import { Mesh } from "babylonjs/Meshes/mesh";
  49213. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49214. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49215. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49216. import { Effect } from "babylonjs/Materials/effect";
  49217. import { Material } from "babylonjs/Materials/material";
  49218. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49219. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49220. /**
  49221. * Effect layer options. This helps customizing the behaviour
  49222. * of the effect layer.
  49223. */
  49224. export interface IEffectLayerOptions {
  49225. /**
  49226. * Multiplication factor apply to the canvas size to compute the render target size
  49227. * used to generated the objects (the smaller the faster).
  49228. */
  49229. mainTextureRatio: number;
  49230. /**
  49231. * Enforces a fixed size texture to ensure effect stability across devices.
  49232. */
  49233. mainTextureFixedSize?: number;
  49234. /**
  49235. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49236. */
  49237. alphaBlendingMode: number;
  49238. /**
  49239. * The camera attached to the layer.
  49240. */
  49241. camera: Nullable<Camera>;
  49242. /**
  49243. * The rendering group to draw the layer in.
  49244. */
  49245. renderingGroupId: number;
  49246. }
  49247. /**
  49248. * The effect layer Helps adding post process effect blended with the main pass.
  49249. *
  49250. * This can be for instance use to generate glow or higlight effects on the scene.
  49251. *
  49252. * The effect layer class can not be used directly and is intented to inherited from to be
  49253. * customized per effects.
  49254. */
  49255. export abstract class EffectLayer {
  49256. private _vertexBuffers;
  49257. private _indexBuffer;
  49258. private _cachedDefines;
  49259. private _effectLayerMapGenerationEffect;
  49260. private _effectLayerOptions;
  49261. private _mergeEffect;
  49262. protected _scene: Scene;
  49263. protected _engine: Engine;
  49264. protected _maxSize: number;
  49265. protected _mainTextureDesiredSize: ISize;
  49266. protected _mainTexture: RenderTargetTexture;
  49267. protected _shouldRender: boolean;
  49268. protected _postProcesses: PostProcess[];
  49269. protected _textures: BaseTexture[];
  49270. protected _emissiveTextureAndColor: {
  49271. texture: Nullable<BaseTexture>;
  49272. color: Color4;
  49273. };
  49274. /**
  49275. * The name of the layer
  49276. */
  49277. name: string;
  49278. /**
  49279. * The clear color of the texture used to generate the glow map.
  49280. */
  49281. neutralColor: Color4;
  49282. /**
  49283. * Specifies wether the highlight layer is enabled or not.
  49284. */
  49285. isEnabled: boolean;
  49286. /**
  49287. * Gets the camera attached to the layer.
  49288. */
  49289. readonly camera: Nullable<Camera>;
  49290. /**
  49291. * Gets the rendering group id the layer should render in.
  49292. */
  49293. readonly renderingGroupId: number;
  49294. /**
  49295. * An event triggered when the effect layer has been disposed.
  49296. */
  49297. onDisposeObservable: Observable<EffectLayer>;
  49298. /**
  49299. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49300. */
  49301. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49302. /**
  49303. * An event triggered when the generated texture is being merged in the scene.
  49304. */
  49305. onBeforeComposeObservable: Observable<EffectLayer>;
  49306. /**
  49307. * An event triggered when the generated texture has been merged in the scene.
  49308. */
  49309. onAfterComposeObservable: Observable<EffectLayer>;
  49310. /**
  49311. * An event triggered when the efffect layer changes its size.
  49312. */
  49313. onSizeChangedObservable: Observable<EffectLayer>;
  49314. /** @hidden */
  49315. static _SceneComponentInitialization: (scene: Scene) => void;
  49316. /**
  49317. * Instantiates a new effect Layer and references it in the scene.
  49318. * @param name The name of the layer
  49319. * @param scene The scene to use the layer in
  49320. */
  49321. constructor(
  49322. /** The Friendly of the effect in the scene */
  49323. name: string, scene: Scene);
  49324. /**
  49325. * Get the effect name of the layer.
  49326. * @return The effect name
  49327. */
  49328. abstract getEffectName(): string;
  49329. /**
  49330. * Checks for the readiness of the element composing the layer.
  49331. * @param subMesh the mesh to check for
  49332. * @param useInstances specify wether or not to use instances to render the mesh
  49333. * @return true if ready otherwise, false
  49334. */
  49335. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49336. /**
  49337. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49338. * @returns true if the effect requires stencil during the main canvas render pass.
  49339. */
  49340. abstract needStencil(): boolean;
  49341. /**
  49342. * Create the merge effect. This is the shader use to blit the information back
  49343. * to the main canvas at the end of the scene rendering.
  49344. * @returns The effect containing the shader used to merge the effect on the main canvas
  49345. */
  49346. protected abstract _createMergeEffect(): Effect;
  49347. /**
  49348. * Creates the render target textures and post processes used in the effect layer.
  49349. */
  49350. protected abstract _createTextureAndPostProcesses(): void;
  49351. /**
  49352. * Implementation specific of rendering the generating effect on the main canvas.
  49353. * @param effect The effect used to render through
  49354. */
  49355. protected abstract _internalRender(effect: Effect): void;
  49356. /**
  49357. * Sets the required values for both the emissive texture and and the main color.
  49358. */
  49359. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49360. /**
  49361. * Free any resources and references associated to a mesh.
  49362. * Internal use
  49363. * @param mesh The mesh to free.
  49364. */
  49365. abstract _disposeMesh(mesh: Mesh): void;
  49366. /**
  49367. * Serializes this layer (Glow or Highlight for example)
  49368. * @returns a serialized layer object
  49369. */
  49370. abstract serialize?(): any;
  49371. /**
  49372. * Initializes the effect layer with the required options.
  49373. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49374. */
  49375. protected _init(options: Partial<IEffectLayerOptions>): void;
  49376. /**
  49377. * Generates the index buffer of the full screen quad blending to the main canvas.
  49378. */
  49379. private _generateIndexBuffer;
  49380. /**
  49381. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49382. */
  49383. private _generateVertexBuffer;
  49384. /**
  49385. * Sets the main texture desired size which is the closest power of two
  49386. * of the engine canvas size.
  49387. */
  49388. private _setMainTextureSize;
  49389. /**
  49390. * Creates the main texture for the effect layer.
  49391. */
  49392. protected _createMainTexture(): void;
  49393. /**
  49394. * Adds specific effects defines.
  49395. * @param defines The defines to add specifics to.
  49396. */
  49397. protected _addCustomEffectDefines(defines: string[]): void;
  49398. /**
  49399. * Checks for the readiness of the element composing the layer.
  49400. * @param subMesh the mesh to check for
  49401. * @param useInstances specify wether or not to use instances to render the mesh
  49402. * @param emissiveTexture the associated emissive texture used to generate the glow
  49403. * @return true if ready otherwise, false
  49404. */
  49405. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49406. /**
  49407. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49408. */
  49409. render(): void;
  49410. /**
  49411. * Determine if a given mesh will be used in the current effect.
  49412. * @param mesh mesh to test
  49413. * @returns true if the mesh will be used
  49414. */
  49415. hasMesh(mesh: AbstractMesh): boolean;
  49416. /**
  49417. * Returns true if the layer contains information to display, otherwise false.
  49418. * @returns true if the glow layer should be rendered
  49419. */
  49420. shouldRender(): boolean;
  49421. /**
  49422. * Returns true if the mesh should render, otherwise false.
  49423. * @param mesh The mesh to render
  49424. * @returns true if it should render otherwise false
  49425. */
  49426. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49427. /**
  49428. * Returns true if the mesh can be rendered, otherwise false.
  49429. * @param mesh The mesh to render
  49430. * @param material The material used on the mesh
  49431. * @returns true if it can be rendered otherwise false
  49432. */
  49433. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49434. /**
  49435. * Returns true if the mesh should render, otherwise false.
  49436. * @param mesh The mesh to render
  49437. * @returns true if it should render otherwise false
  49438. */
  49439. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49440. /**
  49441. * Renders the submesh passed in parameter to the generation map.
  49442. */
  49443. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49444. /**
  49445. * Rebuild the required buffers.
  49446. * @hidden Internal use only.
  49447. */
  49448. _rebuild(): void;
  49449. /**
  49450. * Dispose only the render target textures and post process.
  49451. */
  49452. private _disposeTextureAndPostProcesses;
  49453. /**
  49454. * Dispose the highlight layer and free resources.
  49455. */
  49456. dispose(): void;
  49457. /**
  49458. * Gets the class name of the effect layer
  49459. * @returns the string with the class name of the effect layer
  49460. */
  49461. getClassName(): string;
  49462. /**
  49463. * Creates an effect layer from parsed effect layer data
  49464. * @param parsedEffectLayer defines effect layer data
  49465. * @param scene defines the current scene
  49466. * @param rootUrl defines the root URL containing the effect layer information
  49467. * @returns a parsed effect Layer
  49468. */
  49469. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49470. }
  49471. }
  49472. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49473. import { Scene } from "babylonjs/scene";
  49474. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49475. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49476. import { AbstractScene } from "babylonjs/abstractScene";
  49477. module "babylonjs/abstractScene" {
  49478. interface AbstractScene {
  49479. /**
  49480. * The list of effect layers (highlights/glow) added to the scene
  49481. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49482. * @see http://doc.babylonjs.com/how_to/glow_layer
  49483. */
  49484. effectLayers: Array<EffectLayer>;
  49485. /**
  49486. * Removes the given effect layer from this scene.
  49487. * @param toRemove defines the effect layer to remove
  49488. * @returns the index of the removed effect layer
  49489. */
  49490. removeEffectLayer(toRemove: EffectLayer): number;
  49491. /**
  49492. * Adds the given effect layer to this scene
  49493. * @param newEffectLayer defines the effect layer to add
  49494. */
  49495. addEffectLayer(newEffectLayer: EffectLayer): void;
  49496. }
  49497. }
  49498. /**
  49499. * Defines the layer scene component responsible to manage any effect layers
  49500. * in a given scene.
  49501. */
  49502. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49503. /**
  49504. * The component name helpfull to identify the component in the list of scene components.
  49505. */
  49506. readonly name: string;
  49507. /**
  49508. * The scene the component belongs to.
  49509. */
  49510. scene: Scene;
  49511. private _engine;
  49512. private _renderEffects;
  49513. private _needStencil;
  49514. private _previousStencilState;
  49515. /**
  49516. * Creates a new instance of the component for the given scene
  49517. * @param scene Defines the scene to register the component in
  49518. */
  49519. constructor(scene: Scene);
  49520. /**
  49521. * Registers the component in a given scene
  49522. */
  49523. register(): void;
  49524. /**
  49525. * Rebuilds the elements related to this component in case of
  49526. * context lost for instance.
  49527. */
  49528. rebuild(): void;
  49529. /**
  49530. * Serializes the component data to the specified json object
  49531. * @param serializationObject The object to serialize to
  49532. */
  49533. serialize(serializationObject: any): void;
  49534. /**
  49535. * Adds all the elements from the container to the scene
  49536. * @param container the container holding the elements
  49537. */
  49538. addFromContainer(container: AbstractScene): void;
  49539. /**
  49540. * Removes all the elements in the container from the scene
  49541. * @param container contains the elements to remove
  49542. * @param dispose if the removed element should be disposed (default: false)
  49543. */
  49544. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49545. /**
  49546. * Disposes the component and the associated ressources.
  49547. */
  49548. dispose(): void;
  49549. private _isReadyForMesh;
  49550. private _renderMainTexture;
  49551. private _setStencil;
  49552. private _setStencilBack;
  49553. private _draw;
  49554. private _drawCamera;
  49555. private _drawRenderingGroup;
  49556. }
  49557. }
  49558. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49559. /** @hidden */
  49560. export var glowMapMergePixelShader: {
  49561. name: string;
  49562. shader: string;
  49563. };
  49564. }
  49565. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49566. /** @hidden */
  49567. export var glowMapMergeVertexShader: {
  49568. name: string;
  49569. shader: string;
  49570. };
  49571. }
  49572. declare module "babylonjs/Layers/glowLayer" {
  49573. import { Nullable } from "babylonjs/types";
  49574. import { Camera } from "babylonjs/Cameras/camera";
  49575. import { Scene } from "babylonjs/scene";
  49576. import { Color4 } from "babylonjs/Maths/math";
  49577. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49579. import { Mesh } from "babylonjs/Meshes/mesh";
  49580. import { Texture } from "babylonjs/Materials/Textures/texture";
  49581. import { Effect } from "babylonjs/Materials/effect";
  49582. import { Material } from "babylonjs/Materials/material";
  49583. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49584. import "babylonjs/Shaders/glowMapMerge.fragment";
  49585. import "babylonjs/Shaders/glowMapMerge.vertex";
  49586. import "babylonjs/Layers/effectLayerSceneComponent";
  49587. module "babylonjs/abstractScene" {
  49588. interface AbstractScene {
  49589. /**
  49590. * Return a the first highlight layer of the scene with a given name.
  49591. * @param name The name of the highlight layer to look for.
  49592. * @return The highlight layer if found otherwise null.
  49593. */
  49594. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49595. }
  49596. }
  49597. /**
  49598. * Glow layer options. This helps customizing the behaviour
  49599. * of the glow layer.
  49600. */
  49601. export interface IGlowLayerOptions {
  49602. /**
  49603. * Multiplication factor apply to the canvas size to compute the render target size
  49604. * used to generated the glowing objects (the smaller the faster).
  49605. */
  49606. mainTextureRatio: number;
  49607. /**
  49608. * Enforces a fixed size texture to ensure resize independant blur.
  49609. */
  49610. mainTextureFixedSize?: number;
  49611. /**
  49612. * How big is the kernel of the blur texture.
  49613. */
  49614. blurKernelSize: number;
  49615. /**
  49616. * The camera attached to the layer.
  49617. */
  49618. camera: Nullable<Camera>;
  49619. /**
  49620. * Enable MSAA by chosing the number of samples.
  49621. */
  49622. mainTextureSamples?: number;
  49623. /**
  49624. * The rendering group to draw the layer in.
  49625. */
  49626. renderingGroupId: number;
  49627. }
  49628. /**
  49629. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49630. *
  49631. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49632. * glowy meshes to your scene.
  49633. *
  49634. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49635. */
  49636. export class GlowLayer extends EffectLayer {
  49637. /**
  49638. * Effect Name of the layer.
  49639. */
  49640. static readonly EffectName: string;
  49641. /**
  49642. * The default blur kernel size used for the glow.
  49643. */
  49644. static DefaultBlurKernelSize: number;
  49645. /**
  49646. * The default texture size ratio used for the glow.
  49647. */
  49648. static DefaultTextureRatio: number;
  49649. /**
  49650. * Sets the kernel size of the blur.
  49651. */
  49652. /**
  49653. * Gets the kernel size of the blur.
  49654. */
  49655. blurKernelSize: number;
  49656. /**
  49657. * Sets the glow intensity.
  49658. */
  49659. /**
  49660. * Gets the glow intensity.
  49661. */
  49662. intensity: number;
  49663. private _options;
  49664. private _intensity;
  49665. private _horizontalBlurPostprocess1;
  49666. private _verticalBlurPostprocess1;
  49667. private _horizontalBlurPostprocess2;
  49668. private _verticalBlurPostprocess2;
  49669. private _blurTexture1;
  49670. private _blurTexture2;
  49671. private _postProcesses1;
  49672. private _postProcesses2;
  49673. private _includedOnlyMeshes;
  49674. private _excludedMeshes;
  49675. /**
  49676. * Callback used to let the user override the color selection on a per mesh basis
  49677. */
  49678. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49679. /**
  49680. * Callback used to let the user override the texture selection on a per mesh basis
  49681. */
  49682. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49683. /**
  49684. * Instantiates a new glow Layer and references it to the scene.
  49685. * @param name The name of the layer
  49686. * @param scene The scene to use the layer in
  49687. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49688. */
  49689. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49690. /**
  49691. * Get the effect name of the layer.
  49692. * @return The effect name
  49693. */
  49694. getEffectName(): string;
  49695. /**
  49696. * Create the merge effect. This is the shader use to blit the information back
  49697. * to the main canvas at the end of the scene rendering.
  49698. */
  49699. protected _createMergeEffect(): Effect;
  49700. /**
  49701. * Creates the render target textures and post processes used in the glow layer.
  49702. */
  49703. protected _createTextureAndPostProcesses(): void;
  49704. /**
  49705. * Checks for the readiness of the element composing the layer.
  49706. * @param subMesh the mesh to check for
  49707. * @param useInstances specify wether or not to use instances to render the mesh
  49708. * @param emissiveTexture the associated emissive texture used to generate the glow
  49709. * @return true if ready otherwise, false
  49710. */
  49711. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49712. /**
  49713. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49714. */
  49715. needStencil(): boolean;
  49716. /**
  49717. * Returns true if the mesh can be rendered, otherwise false.
  49718. * @param mesh The mesh to render
  49719. * @param material The material used on the mesh
  49720. * @returns true if it can be rendered otherwise false
  49721. */
  49722. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49723. /**
  49724. * Implementation specific of rendering the generating effect on the main canvas.
  49725. * @param effect The effect used to render through
  49726. */
  49727. protected _internalRender(effect: Effect): void;
  49728. /**
  49729. * Sets the required values for both the emissive texture and and the main color.
  49730. */
  49731. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49732. /**
  49733. * Returns true if the mesh should render, otherwise false.
  49734. * @param mesh The mesh to render
  49735. * @returns true if it should render otherwise false
  49736. */
  49737. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49738. /**
  49739. * Adds specific effects defines.
  49740. * @param defines The defines to add specifics to.
  49741. */
  49742. protected _addCustomEffectDefines(defines: string[]): void;
  49743. /**
  49744. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49745. * @param mesh The mesh to exclude from the glow layer
  49746. */
  49747. addExcludedMesh(mesh: Mesh): void;
  49748. /**
  49749. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49750. * @param mesh The mesh to remove
  49751. */
  49752. removeExcludedMesh(mesh: Mesh): void;
  49753. /**
  49754. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49755. * @param mesh The mesh to include in the glow layer
  49756. */
  49757. addIncludedOnlyMesh(mesh: Mesh): void;
  49758. /**
  49759. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49760. * @param mesh The mesh to remove
  49761. */
  49762. removeIncludedOnlyMesh(mesh: Mesh): void;
  49763. /**
  49764. * Determine if a given mesh will be used in the glow layer
  49765. * @param mesh The mesh to test
  49766. * @returns true if the mesh will be highlighted by the current glow layer
  49767. */
  49768. hasMesh(mesh: AbstractMesh): boolean;
  49769. /**
  49770. * Free any resources and references associated to a mesh.
  49771. * Internal use
  49772. * @param mesh The mesh to free.
  49773. * @hidden
  49774. */
  49775. _disposeMesh(mesh: Mesh): void;
  49776. /**
  49777. * Gets the class name of the effect layer
  49778. * @returns the string with the class name of the effect layer
  49779. */
  49780. getClassName(): string;
  49781. /**
  49782. * Serializes this glow layer
  49783. * @returns a serialized glow layer object
  49784. */
  49785. serialize(): any;
  49786. /**
  49787. * Creates a Glow Layer from parsed glow layer data
  49788. * @param parsedGlowLayer defines glow layer data
  49789. * @param scene defines the current scene
  49790. * @param rootUrl defines the root URL containing the glow layer information
  49791. * @returns a parsed Glow Layer
  49792. */
  49793. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49794. }
  49795. }
  49796. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49797. /** @hidden */
  49798. export var glowBlurPostProcessPixelShader: {
  49799. name: string;
  49800. shader: string;
  49801. };
  49802. }
  49803. declare module "babylonjs/Layers/highlightLayer" {
  49804. import { Observable } from "babylonjs/Misc/observable";
  49805. import { Nullable } from "babylonjs/types";
  49806. import { Camera } from "babylonjs/Cameras/camera";
  49807. import { Scene } from "babylonjs/scene";
  49808. import { Color3, Color4 } from "babylonjs/Maths/math";
  49809. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49811. import { Mesh } from "babylonjs/Meshes/mesh";
  49812. import { Effect } from "babylonjs/Materials/effect";
  49813. import { Material } from "babylonjs/Materials/material";
  49814. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49815. import "babylonjs/Shaders/glowMapMerge.fragment";
  49816. import "babylonjs/Shaders/glowMapMerge.vertex";
  49817. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49818. module "babylonjs/abstractScene" {
  49819. interface AbstractScene {
  49820. /**
  49821. * Return a the first highlight layer of the scene with a given name.
  49822. * @param name The name of the highlight layer to look for.
  49823. * @return The highlight layer if found otherwise null.
  49824. */
  49825. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49826. }
  49827. }
  49828. /**
  49829. * Highlight layer options. This helps customizing the behaviour
  49830. * of the highlight layer.
  49831. */
  49832. export interface IHighlightLayerOptions {
  49833. /**
  49834. * Multiplication factor apply to the canvas size to compute the render target size
  49835. * used to generated the glowing objects (the smaller the faster).
  49836. */
  49837. mainTextureRatio: number;
  49838. /**
  49839. * Enforces a fixed size texture to ensure resize independant blur.
  49840. */
  49841. mainTextureFixedSize?: number;
  49842. /**
  49843. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49844. * of the picture to blur (the smaller the faster).
  49845. */
  49846. blurTextureSizeRatio: number;
  49847. /**
  49848. * How big in texel of the blur texture is the vertical blur.
  49849. */
  49850. blurVerticalSize: number;
  49851. /**
  49852. * How big in texel of the blur texture is the horizontal blur.
  49853. */
  49854. blurHorizontalSize: number;
  49855. /**
  49856. * Alpha blending mode used to apply the blur. Default is combine.
  49857. */
  49858. alphaBlendingMode: number;
  49859. /**
  49860. * The camera attached to the layer.
  49861. */
  49862. camera: Nullable<Camera>;
  49863. /**
  49864. * Should we display highlight as a solid stroke?
  49865. */
  49866. isStroke?: boolean;
  49867. /**
  49868. * The rendering group to draw the layer in.
  49869. */
  49870. renderingGroupId: number;
  49871. }
  49872. /**
  49873. * The highlight layer Helps adding a glow effect around a mesh.
  49874. *
  49875. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49876. * glowy meshes to your scene.
  49877. *
  49878. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49879. */
  49880. export class HighlightLayer extends EffectLayer {
  49881. name: string;
  49882. /**
  49883. * Effect Name of the highlight layer.
  49884. */
  49885. static readonly EffectName: string;
  49886. /**
  49887. * The neutral color used during the preparation of the glow effect.
  49888. * This is black by default as the blend operation is a blend operation.
  49889. */
  49890. static NeutralColor: Color4;
  49891. /**
  49892. * Stencil value used for glowing meshes.
  49893. */
  49894. static GlowingMeshStencilReference: number;
  49895. /**
  49896. * Stencil value used for the other meshes in the scene.
  49897. */
  49898. static NormalMeshStencilReference: number;
  49899. /**
  49900. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49901. */
  49902. innerGlow: boolean;
  49903. /**
  49904. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49905. */
  49906. outerGlow: boolean;
  49907. /**
  49908. * Specifies the horizontal size of the blur.
  49909. */
  49910. /**
  49911. * Gets the horizontal size of the blur.
  49912. */
  49913. blurHorizontalSize: number;
  49914. /**
  49915. * Specifies the vertical size of the blur.
  49916. */
  49917. /**
  49918. * Gets the vertical size of the blur.
  49919. */
  49920. blurVerticalSize: number;
  49921. /**
  49922. * An event triggered when the highlight layer is being blurred.
  49923. */
  49924. onBeforeBlurObservable: Observable<HighlightLayer>;
  49925. /**
  49926. * An event triggered when the highlight layer has been blurred.
  49927. */
  49928. onAfterBlurObservable: Observable<HighlightLayer>;
  49929. private _instanceGlowingMeshStencilReference;
  49930. private _options;
  49931. private _downSamplePostprocess;
  49932. private _horizontalBlurPostprocess;
  49933. private _verticalBlurPostprocess;
  49934. private _blurTexture;
  49935. private _meshes;
  49936. private _excludedMeshes;
  49937. /**
  49938. * Instantiates a new highlight Layer and references it to the scene..
  49939. * @param name The name of the layer
  49940. * @param scene The scene to use the layer in
  49941. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49942. */
  49943. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49944. /**
  49945. * Get the effect name of the layer.
  49946. * @return The effect name
  49947. */
  49948. getEffectName(): string;
  49949. /**
  49950. * Create the merge effect. This is the shader use to blit the information back
  49951. * to the main canvas at the end of the scene rendering.
  49952. */
  49953. protected _createMergeEffect(): Effect;
  49954. /**
  49955. * Creates the render target textures and post processes used in the highlight layer.
  49956. */
  49957. protected _createTextureAndPostProcesses(): void;
  49958. /**
  49959. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49960. */
  49961. needStencil(): boolean;
  49962. /**
  49963. * Checks for the readiness of the element composing the layer.
  49964. * @param subMesh the mesh to check for
  49965. * @param useInstances specify wether or not to use instances to render the mesh
  49966. * @param emissiveTexture the associated emissive texture used to generate the glow
  49967. * @return true if ready otherwise, false
  49968. */
  49969. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49970. /**
  49971. * Implementation specific of rendering the generating effect on the main canvas.
  49972. * @param effect The effect used to render through
  49973. */
  49974. protected _internalRender(effect: Effect): void;
  49975. /**
  49976. * Returns true if the layer contains information to display, otherwise false.
  49977. */
  49978. shouldRender(): boolean;
  49979. /**
  49980. * Returns true if the mesh should render, otherwise false.
  49981. * @param mesh The mesh to render
  49982. * @returns true if it should render otherwise false
  49983. */
  49984. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49985. /**
  49986. * Sets the required values for both the emissive texture and and the main color.
  49987. */
  49988. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49989. /**
  49990. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49991. * @param mesh The mesh to exclude from the highlight layer
  49992. */
  49993. addExcludedMesh(mesh: Mesh): void;
  49994. /**
  49995. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49996. * @param mesh The mesh to highlight
  49997. */
  49998. removeExcludedMesh(mesh: Mesh): void;
  49999. /**
  50000. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50001. * @param mesh mesh to test
  50002. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50003. */
  50004. hasMesh(mesh: AbstractMesh): boolean;
  50005. /**
  50006. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50007. * @param mesh The mesh to highlight
  50008. * @param color The color of the highlight
  50009. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50010. */
  50011. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50012. /**
  50013. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50014. * @param mesh The mesh to highlight
  50015. */
  50016. removeMesh(mesh: Mesh): void;
  50017. /**
  50018. * Force the stencil to the normal expected value for none glowing parts
  50019. */
  50020. private _defaultStencilReference;
  50021. /**
  50022. * Free any resources and references associated to a mesh.
  50023. * Internal use
  50024. * @param mesh The mesh to free.
  50025. * @hidden
  50026. */
  50027. _disposeMesh(mesh: Mesh): void;
  50028. /**
  50029. * Dispose the highlight layer and free resources.
  50030. */
  50031. dispose(): void;
  50032. /**
  50033. * Gets the class name of the effect layer
  50034. * @returns the string with the class name of the effect layer
  50035. */
  50036. getClassName(): string;
  50037. /**
  50038. * Serializes this Highlight layer
  50039. * @returns a serialized Highlight layer object
  50040. */
  50041. serialize(): any;
  50042. /**
  50043. * Creates a Highlight layer from parsed Highlight layer data
  50044. * @param parsedHightlightLayer defines the Highlight layer data
  50045. * @param scene defines the current scene
  50046. * @param rootUrl defines the root URL containing the Highlight layer information
  50047. * @returns a parsed Highlight layer
  50048. */
  50049. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50050. }
  50051. }
  50052. declare module "babylonjs/Layers/layerSceneComponent" {
  50053. import { Scene } from "babylonjs/scene";
  50054. import { ISceneComponent } from "babylonjs/sceneComponent";
  50055. import { Layer } from "babylonjs/Layers/layer";
  50056. import { AbstractScene } from "babylonjs/abstractScene";
  50057. module "babylonjs/abstractScene" {
  50058. interface AbstractScene {
  50059. /**
  50060. * The list of layers (background and foreground) of the scene
  50061. */
  50062. layers: Array<Layer>;
  50063. }
  50064. }
  50065. /**
  50066. * Defines the layer scene component responsible to manage any layers
  50067. * in a given scene.
  50068. */
  50069. export class LayerSceneComponent implements ISceneComponent {
  50070. /**
  50071. * The component name helpfull to identify the component in the list of scene components.
  50072. */
  50073. readonly name: string;
  50074. /**
  50075. * The scene the component belongs to.
  50076. */
  50077. scene: Scene;
  50078. private _engine;
  50079. /**
  50080. * Creates a new instance of the component for the given scene
  50081. * @param scene Defines the scene to register the component in
  50082. */
  50083. constructor(scene: Scene);
  50084. /**
  50085. * Registers the component in a given scene
  50086. */
  50087. register(): void;
  50088. /**
  50089. * Rebuilds the elements related to this component in case of
  50090. * context lost for instance.
  50091. */
  50092. rebuild(): void;
  50093. /**
  50094. * Disposes the component and the associated ressources.
  50095. */
  50096. dispose(): void;
  50097. private _draw;
  50098. private _drawCameraPredicate;
  50099. private _drawCameraBackground;
  50100. private _drawCameraForeground;
  50101. private _drawRenderTargetPredicate;
  50102. private _drawRenderTargetBackground;
  50103. private _drawRenderTargetForeground;
  50104. /**
  50105. * Adds all the elements from the container to the scene
  50106. * @param container the container holding the elements
  50107. */
  50108. addFromContainer(container: AbstractScene): void;
  50109. /**
  50110. * Removes all the elements in the container from the scene
  50111. * @param container contains the elements to remove
  50112. * @param dispose if the removed element should be disposed (default: false)
  50113. */
  50114. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50115. }
  50116. }
  50117. declare module "babylonjs/Shaders/layer.fragment" {
  50118. /** @hidden */
  50119. export var layerPixelShader: {
  50120. name: string;
  50121. shader: string;
  50122. };
  50123. }
  50124. declare module "babylonjs/Shaders/layer.vertex" {
  50125. /** @hidden */
  50126. export var layerVertexShader: {
  50127. name: string;
  50128. shader: string;
  50129. };
  50130. }
  50131. declare module "babylonjs/Layers/layer" {
  50132. import { Observable } from "babylonjs/Misc/observable";
  50133. import { Nullable } from "babylonjs/types";
  50134. import { Scene } from "babylonjs/scene";
  50135. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50136. import { Texture } from "babylonjs/Materials/Textures/texture";
  50137. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50138. import "babylonjs/Shaders/layer.fragment";
  50139. import "babylonjs/Shaders/layer.vertex";
  50140. /**
  50141. * This represents a full screen 2d layer.
  50142. * This can be useful to display a picture in the background of your scene for instance.
  50143. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50144. */
  50145. export class Layer {
  50146. /**
  50147. * Define the name of the layer.
  50148. */
  50149. name: string;
  50150. /**
  50151. * Define the texture the layer should display.
  50152. */
  50153. texture: Nullable<Texture>;
  50154. /**
  50155. * Is the layer in background or foreground.
  50156. */
  50157. isBackground: boolean;
  50158. /**
  50159. * Define the color of the layer (instead of texture).
  50160. */
  50161. color: Color4;
  50162. /**
  50163. * Define the scale of the layer in order to zoom in out of the texture.
  50164. */
  50165. scale: Vector2;
  50166. /**
  50167. * Define an offset for the layer in order to shift the texture.
  50168. */
  50169. offset: Vector2;
  50170. /**
  50171. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50172. */
  50173. alphaBlendingMode: number;
  50174. /**
  50175. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50176. * Alpha test will not mix with the background color in case of transparency.
  50177. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50178. */
  50179. alphaTest: boolean;
  50180. /**
  50181. * Define a mask to restrict the layer to only some of the scene cameras.
  50182. */
  50183. layerMask: number;
  50184. /**
  50185. * Define the list of render target the layer is visible into.
  50186. */
  50187. renderTargetTextures: RenderTargetTexture[];
  50188. /**
  50189. * Define if the layer is only used in renderTarget or if it also
  50190. * renders in the main frame buffer of the canvas.
  50191. */
  50192. renderOnlyInRenderTargetTextures: boolean;
  50193. private _scene;
  50194. private _vertexBuffers;
  50195. private _indexBuffer;
  50196. private _effect;
  50197. private _alphaTestEffect;
  50198. /**
  50199. * An event triggered when the layer is disposed.
  50200. */
  50201. onDisposeObservable: Observable<Layer>;
  50202. private _onDisposeObserver;
  50203. /**
  50204. * Back compatibility with callback before the onDisposeObservable existed.
  50205. * The set callback will be triggered when the layer has been disposed.
  50206. */
  50207. onDispose: () => void;
  50208. /**
  50209. * An event triggered before rendering the scene
  50210. */
  50211. onBeforeRenderObservable: Observable<Layer>;
  50212. private _onBeforeRenderObserver;
  50213. /**
  50214. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50215. * The set callback will be triggered just before rendering the layer.
  50216. */
  50217. onBeforeRender: () => void;
  50218. /**
  50219. * An event triggered after rendering the scene
  50220. */
  50221. onAfterRenderObservable: Observable<Layer>;
  50222. private _onAfterRenderObserver;
  50223. /**
  50224. * Back compatibility with callback before the onAfterRenderObservable existed.
  50225. * The set callback will be triggered just after rendering the layer.
  50226. */
  50227. onAfterRender: () => void;
  50228. /**
  50229. * Instantiates a new layer.
  50230. * This represents a full screen 2d layer.
  50231. * This can be useful to display a picture in the background of your scene for instance.
  50232. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50233. * @param name Define the name of the layer in the scene
  50234. * @param imgUrl Define the url of the texture to display in the layer
  50235. * @param scene Define the scene the layer belongs to
  50236. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50237. * @param color Defines a color for the layer
  50238. */
  50239. constructor(
  50240. /**
  50241. * Define the name of the layer.
  50242. */
  50243. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50244. private _createIndexBuffer;
  50245. /** @hidden */
  50246. _rebuild(): void;
  50247. /**
  50248. * Renders the layer in the scene.
  50249. */
  50250. render(): void;
  50251. /**
  50252. * Disposes and releases the associated ressources.
  50253. */
  50254. dispose(): void;
  50255. }
  50256. }
  50257. declare module "babylonjs/Layers/index" {
  50258. export * from "babylonjs/Layers/effectLayer";
  50259. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50260. export * from "babylonjs/Layers/glowLayer";
  50261. export * from "babylonjs/Layers/highlightLayer";
  50262. export * from "babylonjs/Layers/layer";
  50263. export * from "babylonjs/Layers/layerSceneComponent";
  50264. }
  50265. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50266. /** @hidden */
  50267. export var lensFlarePixelShader: {
  50268. name: string;
  50269. shader: string;
  50270. };
  50271. }
  50272. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50273. /** @hidden */
  50274. export var lensFlareVertexShader: {
  50275. name: string;
  50276. shader: string;
  50277. };
  50278. }
  50279. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50280. import { Scene } from "babylonjs/scene";
  50281. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50283. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50284. import "babylonjs/Shaders/lensFlare.fragment";
  50285. import "babylonjs/Shaders/lensFlare.vertex";
  50286. /**
  50287. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50288. * It is usually composed of several `lensFlare`.
  50289. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50290. */
  50291. export class LensFlareSystem {
  50292. /**
  50293. * Define the name of the lens flare system
  50294. */
  50295. name: string;
  50296. /**
  50297. * List of lens flares used in this system.
  50298. */
  50299. lensFlares: LensFlare[];
  50300. /**
  50301. * Define a limit from the border the lens flare can be visible.
  50302. */
  50303. borderLimit: number;
  50304. /**
  50305. * Define a viewport border we do not want to see the lens flare in.
  50306. */
  50307. viewportBorder: number;
  50308. /**
  50309. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50310. */
  50311. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50312. /**
  50313. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50314. */
  50315. layerMask: number;
  50316. /**
  50317. * Define the id of the lens flare system in the scene.
  50318. * (equal to name by default)
  50319. */
  50320. id: string;
  50321. private _scene;
  50322. private _emitter;
  50323. private _vertexBuffers;
  50324. private _indexBuffer;
  50325. private _effect;
  50326. private _positionX;
  50327. private _positionY;
  50328. private _isEnabled;
  50329. /** @hidden */
  50330. static _SceneComponentInitialization: (scene: Scene) => void;
  50331. /**
  50332. * Instantiates a lens flare system.
  50333. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50334. * It is usually composed of several `lensFlare`.
  50335. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50336. * @param name Define the name of the lens flare system in the scene
  50337. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50338. * @param scene Define the scene the lens flare system belongs to
  50339. */
  50340. constructor(
  50341. /**
  50342. * Define the name of the lens flare system
  50343. */
  50344. name: string, emitter: any, scene: Scene);
  50345. /**
  50346. * Define if the lens flare system is enabled.
  50347. */
  50348. isEnabled: boolean;
  50349. /**
  50350. * Get the scene the effects belongs to.
  50351. * @returns the scene holding the lens flare system
  50352. */
  50353. getScene(): Scene;
  50354. /**
  50355. * Get the emitter of the lens flare system.
  50356. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50357. * @returns the emitter of the lens flare system
  50358. */
  50359. getEmitter(): any;
  50360. /**
  50361. * Set the emitter of the lens flare system.
  50362. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50363. * @param newEmitter Define the new emitter of the system
  50364. */
  50365. setEmitter(newEmitter: any): void;
  50366. /**
  50367. * Get the lens flare system emitter position.
  50368. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50369. * @returns the position
  50370. */
  50371. getEmitterPosition(): Vector3;
  50372. /**
  50373. * @hidden
  50374. */
  50375. computeEffectivePosition(globalViewport: Viewport): boolean;
  50376. /** @hidden */
  50377. _isVisible(): boolean;
  50378. /**
  50379. * @hidden
  50380. */
  50381. render(): boolean;
  50382. /**
  50383. * Dispose and release the lens flare with its associated resources.
  50384. */
  50385. dispose(): void;
  50386. /**
  50387. * Parse a lens flare system from a JSON repressentation
  50388. * @param parsedLensFlareSystem Define the JSON to parse
  50389. * @param scene Define the scene the parsed system should be instantiated in
  50390. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50391. * @returns the parsed system
  50392. */
  50393. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50394. /**
  50395. * Serialize the current Lens Flare System into a JSON representation.
  50396. * @returns the serialized JSON
  50397. */
  50398. serialize(): any;
  50399. }
  50400. }
  50401. declare module "babylonjs/LensFlares/lensFlare" {
  50402. import { Nullable } from "babylonjs/types";
  50403. import { Color3 } from "babylonjs/Maths/math";
  50404. import { Texture } from "babylonjs/Materials/Textures/texture";
  50405. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50406. /**
  50407. * This represents one of the lens effect in a `lensFlareSystem`.
  50408. * It controls one of the indiviual texture used in the effect.
  50409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50410. */
  50411. export class LensFlare {
  50412. /**
  50413. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50414. */
  50415. size: number;
  50416. /**
  50417. * 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.
  50418. */
  50419. position: number;
  50420. /**
  50421. * Define the lens color.
  50422. */
  50423. color: Color3;
  50424. /**
  50425. * Define the lens texture.
  50426. */
  50427. texture: Nullable<Texture>;
  50428. /**
  50429. * Define the alpha mode to render this particular lens.
  50430. */
  50431. alphaMode: number;
  50432. private _system;
  50433. /**
  50434. * Creates a new Lens Flare.
  50435. * This represents one of the lens effect in a `lensFlareSystem`.
  50436. * It controls one of the indiviual texture used in the effect.
  50437. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50438. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50439. * @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.
  50440. * @param color Define the lens color
  50441. * @param imgUrl Define the lens texture url
  50442. * @param system Define the `lensFlareSystem` this flare is part of
  50443. * @returns The newly created Lens Flare
  50444. */
  50445. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50446. /**
  50447. * Instantiates a new Lens Flare.
  50448. * This represents one of the lens effect in a `lensFlareSystem`.
  50449. * It controls one of the indiviual texture used in the effect.
  50450. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50451. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50452. * @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.
  50453. * @param color Define the lens color
  50454. * @param imgUrl Define the lens texture url
  50455. * @param system Define the `lensFlareSystem` this flare is part of
  50456. */
  50457. constructor(
  50458. /**
  50459. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50460. */
  50461. size: number,
  50462. /**
  50463. * 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.
  50464. */
  50465. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50466. /**
  50467. * Dispose and release the lens flare with its associated resources.
  50468. */
  50469. dispose(): void;
  50470. }
  50471. }
  50472. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50473. import { Nullable } from "babylonjs/types";
  50474. import { Scene } from "babylonjs/scene";
  50475. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50476. import { AbstractScene } from "babylonjs/abstractScene";
  50477. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50478. module "babylonjs/abstractScene" {
  50479. interface AbstractScene {
  50480. /**
  50481. * The list of lens flare system added to the scene
  50482. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50483. */
  50484. lensFlareSystems: Array<LensFlareSystem>;
  50485. /**
  50486. * Removes the given lens flare system from this scene.
  50487. * @param toRemove The lens flare system to remove
  50488. * @returns The index of the removed lens flare system
  50489. */
  50490. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50491. /**
  50492. * Adds the given lens flare system to this scene
  50493. * @param newLensFlareSystem The lens flare system to add
  50494. */
  50495. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50496. /**
  50497. * Gets a lens flare system using its name
  50498. * @param name defines the name to look for
  50499. * @returns the lens flare system or null if not found
  50500. */
  50501. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50502. /**
  50503. * Gets a lens flare system using its id
  50504. * @param id defines the id to look for
  50505. * @returns the lens flare system or null if not found
  50506. */
  50507. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50508. }
  50509. }
  50510. /**
  50511. * Defines the lens flare scene component responsible to manage any lens flares
  50512. * in a given scene.
  50513. */
  50514. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50515. /**
  50516. * The component name helpfull to identify the component in the list of scene components.
  50517. */
  50518. readonly name: string;
  50519. /**
  50520. * The scene the component belongs to.
  50521. */
  50522. scene: Scene;
  50523. /**
  50524. * Creates a new instance of the component for the given scene
  50525. * @param scene Defines the scene to register the component in
  50526. */
  50527. constructor(scene: Scene);
  50528. /**
  50529. * Registers the component in a given scene
  50530. */
  50531. register(): void;
  50532. /**
  50533. * Rebuilds the elements related to this component in case of
  50534. * context lost for instance.
  50535. */
  50536. rebuild(): void;
  50537. /**
  50538. * Adds all the elements from the container to the scene
  50539. * @param container the container holding the elements
  50540. */
  50541. addFromContainer(container: AbstractScene): void;
  50542. /**
  50543. * Removes all the elements in the container from the scene
  50544. * @param container contains the elements to remove
  50545. * @param dispose if the removed element should be disposed (default: false)
  50546. */
  50547. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50548. /**
  50549. * Serializes the component data to the specified json object
  50550. * @param serializationObject The object to serialize to
  50551. */
  50552. serialize(serializationObject: any): void;
  50553. /**
  50554. * Disposes the component and the associated ressources.
  50555. */
  50556. dispose(): void;
  50557. private _draw;
  50558. }
  50559. }
  50560. declare module "babylonjs/LensFlares/index" {
  50561. export * from "babylonjs/LensFlares/lensFlare";
  50562. export * from "babylonjs/LensFlares/lensFlareSystem";
  50563. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50564. }
  50565. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50566. import { Scene } from "babylonjs/scene";
  50567. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50568. import { AbstractScene } from "babylonjs/abstractScene";
  50569. /**
  50570. * Defines the shadow generator component responsible to manage any shadow generators
  50571. * in a given scene.
  50572. */
  50573. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50574. /**
  50575. * The component name helpfull to identify the component in the list of scene components.
  50576. */
  50577. readonly name: string;
  50578. /**
  50579. * The scene the component belongs to.
  50580. */
  50581. scene: Scene;
  50582. /**
  50583. * Creates a new instance of the component for the given scene
  50584. * @param scene Defines the scene to register the component in
  50585. */
  50586. constructor(scene: Scene);
  50587. /**
  50588. * Registers the component in a given scene
  50589. */
  50590. register(): void;
  50591. /**
  50592. * Rebuilds the elements related to this component in case of
  50593. * context lost for instance.
  50594. */
  50595. rebuild(): void;
  50596. /**
  50597. * Serializes the component data to the specified json object
  50598. * @param serializationObject The object to serialize to
  50599. */
  50600. serialize(serializationObject: any): void;
  50601. /**
  50602. * Adds all the elements from the container to the scene
  50603. * @param container the container holding the elements
  50604. */
  50605. addFromContainer(container: AbstractScene): void;
  50606. /**
  50607. * Removes all the elements in the container from the scene
  50608. * @param container contains the elements to remove
  50609. * @param dispose if the removed element should be disposed (default: false)
  50610. */
  50611. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50612. /**
  50613. * Rebuilds the elements related to this component in case of
  50614. * context lost for instance.
  50615. */
  50616. dispose(): void;
  50617. private _gatherRenderTargets;
  50618. }
  50619. }
  50620. declare module "babylonjs/Lights/Shadows/index" {
  50621. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50622. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50623. }
  50624. declare module "babylonjs/Lights/pointLight" {
  50625. import { Scene } from "babylonjs/scene";
  50626. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50628. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50629. import { Effect } from "babylonjs/Materials/effect";
  50630. /**
  50631. * A point light is a light defined by an unique point in world space.
  50632. * The light is emitted in every direction from this point.
  50633. * A good example of a point light is a standard light bulb.
  50634. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50635. */
  50636. export class PointLight extends ShadowLight {
  50637. private _shadowAngle;
  50638. /**
  50639. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50640. * This specifies what angle the shadow will use to be created.
  50641. *
  50642. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50643. */
  50644. /**
  50645. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50646. * This specifies what angle the shadow will use to be created.
  50647. *
  50648. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50649. */
  50650. shadowAngle: number;
  50651. /**
  50652. * Gets the direction if it has been set.
  50653. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50654. */
  50655. /**
  50656. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50657. */
  50658. direction: Vector3;
  50659. /**
  50660. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50661. * A PointLight emits the light in every direction.
  50662. * It can cast shadows.
  50663. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50664. * ```javascript
  50665. * var pointLight = new PointLight("pl", camera.position, scene);
  50666. * ```
  50667. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50668. * @param name The light friendly name
  50669. * @param position The position of the point light in the scene
  50670. * @param scene The scene the lights belongs to
  50671. */
  50672. constructor(name: string, position: Vector3, scene: Scene);
  50673. /**
  50674. * Returns the string "PointLight"
  50675. * @returns the class name
  50676. */
  50677. getClassName(): string;
  50678. /**
  50679. * Returns the integer 0.
  50680. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50681. */
  50682. getTypeID(): number;
  50683. /**
  50684. * Specifies wether or not the shadowmap should be a cube texture.
  50685. * @returns true if the shadowmap needs to be a cube texture.
  50686. */
  50687. needCube(): boolean;
  50688. /**
  50689. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50690. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50691. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50692. */
  50693. getShadowDirection(faceIndex?: number): Vector3;
  50694. /**
  50695. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50696. * - fov = PI / 2
  50697. * - aspect ratio : 1.0
  50698. * - z-near and far equal to the active camera minZ and maxZ.
  50699. * Returns the PointLight.
  50700. */
  50701. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50702. protected _buildUniformLayout(): void;
  50703. /**
  50704. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50705. * @param effect The effect to update
  50706. * @param lightIndex The index of the light in the effect to update
  50707. * @returns The point light
  50708. */
  50709. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50710. /**
  50711. * Prepares the list of defines specific to the light type.
  50712. * @param defines the list of defines
  50713. * @param lightIndex defines the index of the light for the effect
  50714. */
  50715. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50716. }
  50717. }
  50718. declare module "babylonjs/Lights/index" {
  50719. export * from "babylonjs/Lights/light";
  50720. export * from "babylonjs/Lights/shadowLight";
  50721. export * from "babylonjs/Lights/Shadows/index";
  50722. export * from "babylonjs/Lights/directionalLight";
  50723. export * from "babylonjs/Lights/hemisphericLight";
  50724. export * from "babylonjs/Lights/pointLight";
  50725. export * from "babylonjs/Lights/spotLight";
  50726. }
  50727. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50728. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50729. /**
  50730. * Header information of HDR texture files.
  50731. */
  50732. export interface HDRInfo {
  50733. /**
  50734. * The height of the texture in pixels.
  50735. */
  50736. height: number;
  50737. /**
  50738. * The width of the texture in pixels.
  50739. */
  50740. width: number;
  50741. /**
  50742. * The index of the beginning of the data in the binary file.
  50743. */
  50744. dataPosition: number;
  50745. }
  50746. /**
  50747. * This groups tools to convert HDR texture to native colors array.
  50748. */
  50749. export class HDRTools {
  50750. private static Ldexp;
  50751. private static Rgbe2float;
  50752. private static readStringLine;
  50753. /**
  50754. * Reads header information from an RGBE texture stored in a native array.
  50755. * More information on this format are available here:
  50756. * https://en.wikipedia.org/wiki/RGBE_image_format
  50757. *
  50758. * @param uint8array The binary file stored in native array.
  50759. * @return The header information.
  50760. */
  50761. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50762. /**
  50763. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50764. * This RGBE texture needs to store the information as a panorama.
  50765. *
  50766. * More information on this format are available here:
  50767. * https://en.wikipedia.org/wiki/RGBE_image_format
  50768. *
  50769. * @param buffer The binary file stored in an array buffer.
  50770. * @param size The expected size of the extracted cubemap.
  50771. * @return The Cube Map information.
  50772. */
  50773. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50774. /**
  50775. * Returns the pixels data extracted from an RGBE texture.
  50776. * This pixels will be stored left to right up to down in the R G B order in one array.
  50777. *
  50778. * More information on this format are available here:
  50779. * https://en.wikipedia.org/wiki/RGBE_image_format
  50780. *
  50781. * @param uint8array The binary file stored in an array buffer.
  50782. * @param hdrInfo The header information of the file.
  50783. * @return The pixels data in RGB right to left up to down order.
  50784. */
  50785. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50786. private static RGBE_ReadPixels_RLE;
  50787. }
  50788. }
  50789. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50790. import { Nullable } from "babylonjs/types";
  50791. import { Scene } from "babylonjs/scene";
  50792. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50794. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50795. /**
  50796. * This represents a texture coming from an HDR input.
  50797. *
  50798. * The only supported format is currently panorama picture stored in RGBE format.
  50799. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50800. */
  50801. export class HDRCubeTexture extends BaseTexture {
  50802. private static _facesMapping;
  50803. private _generateHarmonics;
  50804. private _noMipmap;
  50805. private _textureMatrix;
  50806. private _size;
  50807. private _onLoad;
  50808. private _onError;
  50809. /**
  50810. * The texture URL.
  50811. */
  50812. url: string;
  50813. /**
  50814. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50815. */
  50816. coordinatesMode: number;
  50817. protected _isBlocking: boolean;
  50818. /**
  50819. * Sets wether or not the texture is blocking during loading.
  50820. */
  50821. /**
  50822. * Gets wether or not the texture is blocking during loading.
  50823. */
  50824. isBlocking: boolean;
  50825. protected _rotationY: number;
  50826. /**
  50827. * Sets texture matrix rotation angle around Y axis in radians.
  50828. */
  50829. /**
  50830. * Gets texture matrix rotation angle around Y axis radians.
  50831. */
  50832. rotationY: number;
  50833. /**
  50834. * Gets or sets the center of the bounding box associated with the cube texture
  50835. * It must define where the camera used to render the texture was set
  50836. */
  50837. boundingBoxPosition: Vector3;
  50838. private _boundingBoxSize;
  50839. /**
  50840. * Gets or sets the size of the bounding box associated with the cube texture
  50841. * When defined, the cubemap will switch to local mode
  50842. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50843. * @example https://www.babylonjs-playground.com/#RNASML
  50844. */
  50845. boundingBoxSize: Vector3;
  50846. /**
  50847. * Instantiates an HDRTexture from the following parameters.
  50848. *
  50849. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50850. * @param scene The scene the texture will be used in
  50851. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50852. * @param noMipmap Forces to not generate the mipmap if true
  50853. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50854. * @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)
  50855. * @param reserved Reserved flag for internal use.
  50856. */
  50857. 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>);
  50858. /**
  50859. * Get the current class name of the texture useful for serialization or dynamic coding.
  50860. * @returns "HDRCubeTexture"
  50861. */
  50862. getClassName(): string;
  50863. /**
  50864. * Occurs when the file is raw .hdr file.
  50865. */
  50866. private loadTexture;
  50867. clone(): HDRCubeTexture;
  50868. delayLoad(): void;
  50869. /**
  50870. * Get the texture reflection matrix used to rotate/transform the reflection.
  50871. * @returns the reflection matrix
  50872. */
  50873. getReflectionTextureMatrix(): Matrix;
  50874. /**
  50875. * Set the texture reflection matrix used to rotate/transform the reflection.
  50876. * @param value Define the reflection matrix to set
  50877. */
  50878. setReflectionTextureMatrix(value: Matrix): void;
  50879. /**
  50880. * Parses a JSON representation of an HDR Texture in order to create the texture
  50881. * @param parsedTexture Define the JSON representation
  50882. * @param scene Define the scene the texture should be created in
  50883. * @param rootUrl Define the root url in case we need to load relative dependencies
  50884. * @returns the newly created texture after parsing
  50885. */
  50886. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50887. serialize(): any;
  50888. }
  50889. }
  50890. declare module "babylonjs/Physics/physicsEngine" {
  50891. import { Nullable } from "babylonjs/types";
  50892. import { Vector3 } from "babylonjs/Maths/math";
  50893. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50894. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50895. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50896. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50897. /**
  50898. * Class used to control physics engine
  50899. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50900. */
  50901. export class PhysicsEngine implements IPhysicsEngine {
  50902. private _physicsPlugin;
  50903. /**
  50904. * Global value used to control the smallest number supported by the simulation
  50905. */
  50906. static Epsilon: number;
  50907. private _impostors;
  50908. private _joints;
  50909. /**
  50910. * Gets the gravity vector used by the simulation
  50911. */
  50912. gravity: Vector3;
  50913. /**
  50914. * Factory used to create the default physics plugin.
  50915. * @returns The default physics plugin
  50916. */
  50917. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50918. /**
  50919. * Creates a new Physics Engine
  50920. * @param gravity defines the gravity vector used by the simulation
  50921. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50922. */
  50923. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50924. /**
  50925. * Sets the gravity vector used by the simulation
  50926. * @param gravity defines the gravity vector to use
  50927. */
  50928. setGravity(gravity: Vector3): void;
  50929. /**
  50930. * Set the time step of the physics engine.
  50931. * Default is 1/60.
  50932. * To slow it down, enter 1/600 for example.
  50933. * To speed it up, 1/30
  50934. * @param newTimeStep defines the new timestep to apply to this world.
  50935. */
  50936. setTimeStep(newTimeStep?: number): void;
  50937. /**
  50938. * Get the time step of the physics engine.
  50939. * @returns the current time step
  50940. */
  50941. getTimeStep(): number;
  50942. /**
  50943. * Release all resources
  50944. */
  50945. dispose(): void;
  50946. /**
  50947. * Gets the name of the current physics plugin
  50948. * @returns the name of the plugin
  50949. */
  50950. getPhysicsPluginName(): string;
  50951. /**
  50952. * Adding a new impostor for the impostor tracking.
  50953. * This will be done by the impostor itself.
  50954. * @param impostor the impostor to add
  50955. */
  50956. addImpostor(impostor: PhysicsImpostor): void;
  50957. /**
  50958. * Remove an impostor from the engine.
  50959. * This impostor and its mesh will not longer be updated by the physics engine.
  50960. * @param impostor the impostor to remove
  50961. */
  50962. removeImpostor(impostor: PhysicsImpostor): void;
  50963. /**
  50964. * Add a joint to the physics engine
  50965. * @param mainImpostor defines the main impostor to which the joint is added.
  50966. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50967. * @param joint defines the joint that will connect both impostors.
  50968. */
  50969. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50970. /**
  50971. * Removes a joint from the simulation
  50972. * @param mainImpostor defines the impostor used with the joint
  50973. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50974. * @param joint defines the joint to remove
  50975. */
  50976. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50977. /**
  50978. * Called by the scene. No need to call it.
  50979. * @param delta defines the timespam between frames
  50980. */
  50981. _step(delta: number): void;
  50982. /**
  50983. * Gets the current plugin used to run the simulation
  50984. * @returns current plugin
  50985. */
  50986. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50987. /**
  50988. * Gets the list of physic impostors
  50989. * @returns an array of PhysicsImpostor
  50990. */
  50991. getImpostors(): Array<PhysicsImpostor>;
  50992. /**
  50993. * Gets the impostor for a physics enabled object
  50994. * @param object defines the object impersonated by the impostor
  50995. * @returns the PhysicsImpostor or null if not found
  50996. */
  50997. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50998. /**
  50999. * Gets the impostor for a physics body object
  51000. * @param body defines physics body used by the impostor
  51001. * @returns the PhysicsImpostor or null if not found
  51002. */
  51003. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51004. /**
  51005. * Does a raycast in the physics world
  51006. * @param from when should the ray start?
  51007. * @param to when should the ray end?
  51008. * @returns PhysicsRaycastResult
  51009. */
  51010. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51011. }
  51012. }
  51013. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51014. import { Nullable } from "babylonjs/types";
  51015. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51017. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51018. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51019. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51020. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51021. /** @hidden */
  51022. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51023. private _useDeltaForWorldStep;
  51024. world: any;
  51025. name: string;
  51026. private _physicsMaterials;
  51027. private _fixedTimeStep;
  51028. private _cannonRaycastResult;
  51029. private _raycastResult;
  51030. private _removeAfterStep;
  51031. BJSCANNON: any;
  51032. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51033. setGravity(gravity: Vector3): void;
  51034. setTimeStep(timeStep: number): void;
  51035. getTimeStep(): number;
  51036. executeStep(delta: number): void;
  51037. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51038. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51039. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51040. private _processChildMeshes;
  51041. removePhysicsBody(impostor: PhysicsImpostor): void;
  51042. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51043. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51044. private _addMaterial;
  51045. private _checkWithEpsilon;
  51046. private _createShape;
  51047. private _createHeightmap;
  51048. private _minus90X;
  51049. private _plus90X;
  51050. private _tmpPosition;
  51051. private _tmpDeltaPosition;
  51052. private _tmpUnityRotation;
  51053. private _updatePhysicsBodyTransformation;
  51054. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51055. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51056. isSupported(): boolean;
  51057. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51058. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51059. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51060. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51061. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51062. getBodyMass(impostor: PhysicsImpostor): number;
  51063. getBodyFriction(impostor: PhysicsImpostor): number;
  51064. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51065. getBodyRestitution(impostor: PhysicsImpostor): number;
  51066. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51067. sleepBody(impostor: PhysicsImpostor): void;
  51068. wakeUpBody(impostor: PhysicsImpostor): void;
  51069. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51070. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51072. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51073. getRadius(impostor: PhysicsImpostor): number;
  51074. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51075. dispose(): void;
  51076. private _extendNamespace;
  51077. /**
  51078. * Does a raycast in the physics world
  51079. * @param from when should the ray start?
  51080. * @param to when should the ray end?
  51081. * @returns PhysicsRaycastResult
  51082. */
  51083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51084. }
  51085. }
  51086. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51087. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51089. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51091. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51092. import { Nullable } from "babylonjs/types";
  51093. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51094. /** @hidden */
  51095. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51096. world: any;
  51097. name: string;
  51098. BJSOIMO: any;
  51099. private _raycastResult;
  51100. constructor(iterations?: number, oimoInjection?: any);
  51101. setGravity(gravity: Vector3): void;
  51102. setTimeStep(timeStep: number): void;
  51103. getTimeStep(): number;
  51104. private _tmpImpostorsArray;
  51105. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51106. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51107. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51108. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51109. private _tmpPositionVector;
  51110. removePhysicsBody(impostor: PhysicsImpostor): void;
  51111. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51112. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51113. isSupported(): boolean;
  51114. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51115. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51116. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51117. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51118. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51119. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51120. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51121. getBodyMass(impostor: PhysicsImpostor): number;
  51122. getBodyFriction(impostor: PhysicsImpostor): number;
  51123. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51124. getBodyRestitution(impostor: PhysicsImpostor): number;
  51125. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51126. sleepBody(impostor: PhysicsImpostor): void;
  51127. wakeUpBody(impostor: PhysicsImpostor): void;
  51128. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51129. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51130. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51131. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51132. getRadius(impostor: PhysicsImpostor): number;
  51133. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51134. dispose(): void;
  51135. /**
  51136. * Does a raycast in the physics world
  51137. * @param from when should the ray start?
  51138. * @param to when should the ray end?
  51139. * @returns PhysicsRaycastResult
  51140. */
  51141. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51142. }
  51143. }
  51144. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51145. import { Nullable } from "babylonjs/types";
  51146. import { Scene } from "babylonjs/scene";
  51147. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51148. import { Mesh } from "babylonjs/Meshes/mesh";
  51149. /**
  51150. * Class containing static functions to help procedurally build meshes
  51151. */
  51152. export class RibbonBuilder {
  51153. /**
  51154. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51155. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51156. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51157. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51158. * * 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
  51159. * * 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
  51160. * * 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
  51161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51164. * * 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
  51165. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51166. * * 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
  51167. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51169. * @param name defines the name of the mesh
  51170. * @param options defines the options used to create the mesh
  51171. * @param scene defines the hosting scene
  51172. * @returns the ribbon mesh
  51173. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51175. */
  51176. static CreateRibbon(name: string, options: {
  51177. pathArray: Vector3[][];
  51178. closeArray?: boolean;
  51179. closePath?: boolean;
  51180. offset?: number;
  51181. updatable?: boolean;
  51182. sideOrientation?: number;
  51183. frontUVs?: Vector4;
  51184. backUVs?: Vector4;
  51185. instance?: Mesh;
  51186. invertUV?: boolean;
  51187. uvs?: Vector2[];
  51188. colors?: Color4[];
  51189. }, scene?: Nullable<Scene>): Mesh;
  51190. }
  51191. }
  51192. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51193. import { Nullable } from "babylonjs/types";
  51194. import { Scene } from "babylonjs/scene";
  51195. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51196. import { Mesh } from "babylonjs/Meshes/mesh";
  51197. /**
  51198. * Class containing static functions to help procedurally build meshes
  51199. */
  51200. export class ShapeBuilder {
  51201. /**
  51202. * 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.
  51203. * * 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.
  51204. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51205. * * 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.
  51206. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51207. * * 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
  51208. * * 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
  51209. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51210. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51211. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51212. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51214. * @param name defines the name of the mesh
  51215. * @param options defines the options used to create the mesh
  51216. * @param scene defines the hosting scene
  51217. * @returns the extruded shape mesh
  51218. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51219. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51220. */
  51221. static ExtrudeShape(name: string, options: {
  51222. shape: Vector3[];
  51223. path: Vector3[];
  51224. scale?: number;
  51225. rotation?: number;
  51226. cap?: number;
  51227. updatable?: boolean;
  51228. sideOrientation?: number;
  51229. frontUVs?: Vector4;
  51230. backUVs?: Vector4;
  51231. instance?: Mesh;
  51232. invertUV?: boolean;
  51233. }, scene?: Nullable<Scene>): Mesh;
  51234. /**
  51235. * Creates an custom extruded shape mesh.
  51236. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51237. * * 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.
  51238. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51239. * * 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
  51240. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51241. * * 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
  51242. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51243. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51244. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51245. * * 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
  51246. * * 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
  51247. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51252. * @param name defines the name of the mesh
  51253. * @param options defines the options used to create the mesh
  51254. * @param scene defines the hosting scene
  51255. * @returns the custom extruded shape mesh
  51256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51257. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51259. */
  51260. static ExtrudeShapeCustom(name: string, options: {
  51261. shape: Vector3[];
  51262. path: Vector3[];
  51263. scaleFunction?: any;
  51264. rotationFunction?: any;
  51265. ribbonCloseArray?: boolean;
  51266. ribbonClosePath?: boolean;
  51267. cap?: number;
  51268. updatable?: boolean;
  51269. sideOrientation?: number;
  51270. frontUVs?: Vector4;
  51271. backUVs?: Vector4;
  51272. instance?: Mesh;
  51273. invertUV?: boolean;
  51274. }, scene?: Nullable<Scene>): Mesh;
  51275. private static _ExtrudeShapeGeneric;
  51276. }
  51277. }
  51278. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51279. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51280. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51281. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51282. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51283. import { Nullable } from "babylonjs/types";
  51284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51285. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51286. /**
  51287. * AmmoJS Physics plugin
  51288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51289. * @see https://github.com/kripken/ammo.js/
  51290. */
  51291. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51292. private _useDeltaForWorldStep;
  51293. /**
  51294. * Reference to the Ammo library
  51295. */
  51296. bjsAMMO: any;
  51297. /**
  51298. * Created ammoJS world which physics bodies are added to
  51299. */
  51300. world: any;
  51301. /**
  51302. * Name of the plugin
  51303. */
  51304. name: string;
  51305. private _timeStep;
  51306. private _fixedTimeStep;
  51307. private _maxSteps;
  51308. private _tmpQuaternion;
  51309. private _tmpAmmoTransform;
  51310. private _tmpAmmoQuaternion;
  51311. private _tmpAmmoConcreteContactResultCallback;
  51312. private _collisionConfiguration;
  51313. private _dispatcher;
  51314. private _overlappingPairCache;
  51315. private _solver;
  51316. private _softBodySolver;
  51317. private _tmpAmmoVectorA;
  51318. private _tmpAmmoVectorB;
  51319. private _tmpAmmoVectorC;
  51320. private _tmpAmmoVectorD;
  51321. private _tmpContactCallbackResult;
  51322. private _tmpAmmoVectorRCA;
  51323. private _tmpAmmoVectorRCB;
  51324. private _raycastResult;
  51325. private static readonly DISABLE_COLLISION_FLAG;
  51326. private static readonly KINEMATIC_FLAG;
  51327. private static readonly DISABLE_DEACTIVATION_FLAG;
  51328. /**
  51329. * Initializes the ammoJS plugin
  51330. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51331. * @param ammoInjection can be used to inject your own ammo reference
  51332. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51333. */
  51334. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51335. /**
  51336. * Sets the gravity of the physics world (m/(s^2))
  51337. * @param gravity Gravity to set
  51338. */
  51339. setGravity(gravity: Vector3): void;
  51340. /**
  51341. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51342. * @param timeStep timestep to use in seconds
  51343. */
  51344. setTimeStep(timeStep: number): void;
  51345. /**
  51346. * 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)
  51347. * @param fixedTimeStep fixedTimeStep to use in seconds
  51348. */
  51349. setFixedTimeStep(fixedTimeStep: number): void;
  51350. /**
  51351. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51352. * @param maxSteps the maximum number of steps by the physics engine per frame
  51353. */
  51354. setMaxSteps(maxSteps: number): void;
  51355. /**
  51356. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51357. * @returns the current timestep in seconds
  51358. */
  51359. getTimeStep(): number;
  51360. private _isImpostorInContact;
  51361. private _isImpostorPairInContact;
  51362. private _stepSimulation;
  51363. /**
  51364. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51365. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51366. * After the step the babylon meshes are set to the position of the physics imposters
  51367. * @param delta amount of time to step forward
  51368. * @param impostors array of imposters to update before/after the step
  51369. */
  51370. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51371. /**
  51372. * Update babylon mesh to match physics world object
  51373. * @param impostor imposter to match
  51374. */
  51375. private _afterSoftStep;
  51376. /**
  51377. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51378. * @param impostor imposter to match
  51379. */
  51380. private _ropeStep;
  51381. /**
  51382. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51383. * @param impostor imposter to match
  51384. */
  51385. private _softbodyOrClothStep;
  51386. private _tmpVector;
  51387. private _tmpMatrix;
  51388. /**
  51389. * Applies an impulse on the imposter
  51390. * @param impostor imposter to apply impulse to
  51391. * @param force amount of force to be applied to the imposter
  51392. * @param contactPoint the location to apply the impulse on the imposter
  51393. */
  51394. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51395. /**
  51396. * Applies a force on the imposter
  51397. * @param impostor imposter to apply force
  51398. * @param force amount of force to be applied to the imposter
  51399. * @param contactPoint the location to apply the force on the imposter
  51400. */
  51401. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51402. /**
  51403. * Creates a physics body using the plugin
  51404. * @param impostor the imposter to create the physics body on
  51405. */
  51406. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51407. /**
  51408. * Removes the physics body from the imposter and disposes of the body's memory
  51409. * @param impostor imposter to remove the physics body from
  51410. */
  51411. removePhysicsBody(impostor: PhysicsImpostor): void;
  51412. /**
  51413. * Generates a joint
  51414. * @param impostorJoint the imposter joint to create the joint with
  51415. */
  51416. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51417. /**
  51418. * Removes a joint
  51419. * @param impostorJoint the imposter joint to remove the joint from
  51420. */
  51421. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51422. private _addMeshVerts;
  51423. /**
  51424. * Initialise the soft body vertices to match its object's (mesh) vertices
  51425. * Softbody vertices (nodes) are in world space and to match this
  51426. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51427. * @param impostor to create the softbody for
  51428. */
  51429. private _softVertexData;
  51430. /**
  51431. * Create an impostor's soft body
  51432. * @param impostor to create the softbody for
  51433. */
  51434. private _createSoftbody;
  51435. /**
  51436. * Create cloth for an impostor
  51437. * @param impostor to create the softbody for
  51438. */
  51439. private _createCloth;
  51440. /**
  51441. * Create rope for an impostor
  51442. * @param impostor to create the softbody for
  51443. */
  51444. private _createRope;
  51445. private _addHullVerts;
  51446. private _createShape;
  51447. /**
  51448. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51449. * @param impostor imposter containing the physics body and babylon object
  51450. */
  51451. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51452. /**
  51453. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51454. * @param impostor imposter containing the physics body and babylon object
  51455. * @param newPosition new position
  51456. * @param newRotation new rotation
  51457. */
  51458. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51459. /**
  51460. * If this plugin is supported
  51461. * @returns true if its supported
  51462. */
  51463. isSupported(): boolean;
  51464. /**
  51465. * Sets the linear velocity of the physics body
  51466. * @param impostor imposter to set the velocity on
  51467. * @param velocity velocity to set
  51468. */
  51469. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51470. /**
  51471. * Sets the angular velocity of the physics body
  51472. * @param impostor imposter to set the velocity on
  51473. * @param velocity velocity to set
  51474. */
  51475. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51476. /**
  51477. * gets the linear velocity
  51478. * @param impostor imposter to get linear velocity from
  51479. * @returns linear velocity
  51480. */
  51481. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51482. /**
  51483. * gets the angular velocity
  51484. * @param impostor imposter to get angular velocity from
  51485. * @returns angular velocity
  51486. */
  51487. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51488. /**
  51489. * Sets the mass of physics body
  51490. * @param impostor imposter to set the mass on
  51491. * @param mass mass to set
  51492. */
  51493. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51494. /**
  51495. * Gets the mass of the physics body
  51496. * @param impostor imposter to get the mass from
  51497. * @returns mass
  51498. */
  51499. getBodyMass(impostor: PhysicsImpostor): number;
  51500. /**
  51501. * Gets friction of the impostor
  51502. * @param impostor impostor to get friction from
  51503. * @returns friction value
  51504. */
  51505. getBodyFriction(impostor: PhysicsImpostor): number;
  51506. /**
  51507. * Sets friction of the impostor
  51508. * @param impostor impostor to set friction on
  51509. * @param friction friction value
  51510. */
  51511. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51512. /**
  51513. * Gets restitution of the impostor
  51514. * @param impostor impostor to get restitution from
  51515. * @returns restitution value
  51516. */
  51517. getBodyRestitution(impostor: PhysicsImpostor): number;
  51518. /**
  51519. * Sets resitution of the impostor
  51520. * @param impostor impostor to set resitution on
  51521. * @param restitution resitution value
  51522. */
  51523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51524. /**
  51525. * Gets pressure inside the impostor
  51526. * @param impostor impostor to get pressure from
  51527. * @returns pressure value
  51528. */
  51529. getBodyPressure(impostor: PhysicsImpostor): number;
  51530. /**
  51531. * Sets pressure inside a soft body impostor
  51532. * Cloth and rope must remain 0 pressure
  51533. * @param impostor impostor to set pressure on
  51534. * @param pressure pressure value
  51535. */
  51536. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51537. /**
  51538. * Gets stiffness of the impostor
  51539. * @param impostor impostor to get stiffness from
  51540. * @returns pressure value
  51541. */
  51542. getBodyStiffness(impostor: PhysicsImpostor): number;
  51543. /**
  51544. * Sets stiffness of the impostor
  51545. * @param impostor impostor to set stiffness on
  51546. * @param stiffness stiffness value from 0 to 1
  51547. */
  51548. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51549. /**
  51550. * Gets velocityIterations of the impostor
  51551. * @param impostor impostor to get velocity iterations from
  51552. * @returns velocityIterations value
  51553. */
  51554. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51555. /**
  51556. * Sets velocityIterations of the impostor
  51557. * @param impostor impostor to set velocity iterations on
  51558. * @param velocityIterations velocityIterations value
  51559. */
  51560. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51561. /**
  51562. * Gets positionIterations of the impostor
  51563. * @param impostor impostor to get position iterations from
  51564. * @returns positionIterations value
  51565. */
  51566. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51567. /**
  51568. * Sets positionIterations of the impostor
  51569. * @param impostor impostor to set position on
  51570. * @param positionIterations positionIterations value
  51571. */
  51572. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51573. /**
  51574. * Append an anchor to a cloth object
  51575. * @param impostor is the cloth impostor to add anchor to
  51576. * @param otherImpostor is the rigid impostor to anchor to
  51577. * @param width ratio across width from 0 to 1
  51578. * @param height ratio up height from 0 to 1
  51579. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51580. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51581. */
  51582. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51583. /**
  51584. * Append an hook to a rope object
  51585. * @param impostor is the rope impostor to add hook to
  51586. * @param otherImpostor is the rigid impostor to hook to
  51587. * @param length ratio along the rope from 0 to 1
  51588. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51589. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51590. */
  51591. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51592. /**
  51593. * Sleeps the physics body and stops it from being active
  51594. * @param impostor impostor to sleep
  51595. */
  51596. sleepBody(impostor: PhysicsImpostor): void;
  51597. /**
  51598. * Activates the physics body
  51599. * @param impostor impostor to activate
  51600. */
  51601. wakeUpBody(impostor: PhysicsImpostor): void;
  51602. /**
  51603. * Updates the distance parameters of the joint
  51604. * @param joint joint to update
  51605. * @param maxDistance maximum distance of the joint
  51606. * @param minDistance minimum distance of the joint
  51607. */
  51608. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51609. /**
  51610. * Sets a motor on the joint
  51611. * @param joint joint to set motor on
  51612. * @param speed speed of the motor
  51613. * @param maxForce maximum force of the motor
  51614. * @param motorIndex index of the motor
  51615. */
  51616. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51617. /**
  51618. * Sets the motors limit
  51619. * @param joint joint to set limit on
  51620. * @param upperLimit upper limit
  51621. * @param lowerLimit lower limit
  51622. */
  51623. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51624. /**
  51625. * Syncs the position and rotation of a mesh with the impostor
  51626. * @param mesh mesh to sync
  51627. * @param impostor impostor to update the mesh with
  51628. */
  51629. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51630. /**
  51631. * Gets the radius of the impostor
  51632. * @param impostor impostor to get radius from
  51633. * @returns the radius
  51634. */
  51635. getRadius(impostor: PhysicsImpostor): number;
  51636. /**
  51637. * Gets the box size of the impostor
  51638. * @param impostor impostor to get box size from
  51639. * @param result the resulting box size
  51640. */
  51641. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51642. /**
  51643. * Disposes of the impostor
  51644. */
  51645. dispose(): void;
  51646. /**
  51647. * Does a raycast in the physics world
  51648. * @param from when should the ray start?
  51649. * @param to when should the ray end?
  51650. * @returns PhysicsRaycastResult
  51651. */
  51652. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51653. }
  51654. }
  51655. declare module "babylonjs/Probes/reflectionProbe" {
  51656. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51657. import { Vector3 } from "babylonjs/Maths/math";
  51658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51659. import { Nullable } from "babylonjs/types";
  51660. import { Scene } from "babylonjs/scene";
  51661. module "babylonjs/abstractScene" {
  51662. interface AbstractScene {
  51663. /**
  51664. * The list of reflection probes added to the scene
  51665. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51666. */
  51667. reflectionProbes: Array<ReflectionProbe>;
  51668. /**
  51669. * Removes the given reflection probe from this scene.
  51670. * @param toRemove The reflection probe to remove
  51671. * @returns The index of the removed reflection probe
  51672. */
  51673. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51674. /**
  51675. * Adds the given reflection probe to this scene.
  51676. * @param newReflectionProbe The reflection probe to add
  51677. */
  51678. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51679. }
  51680. }
  51681. /**
  51682. * Class used to generate realtime reflection / refraction cube textures
  51683. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51684. */
  51685. export class ReflectionProbe {
  51686. /** defines the name of the probe */
  51687. name: string;
  51688. private _scene;
  51689. private _renderTargetTexture;
  51690. private _projectionMatrix;
  51691. private _viewMatrix;
  51692. private _target;
  51693. private _add;
  51694. private _attachedMesh;
  51695. private _invertYAxis;
  51696. /** Gets or sets probe position (center of the cube map) */
  51697. position: Vector3;
  51698. /**
  51699. * Creates a new reflection probe
  51700. * @param name defines the name of the probe
  51701. * @param size defines the texture resolution (for each face)
  51702. * @param scene defines the hosting scene
  51703. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51704. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51705. */
  51706. constructor(
  51707. /** defines the name of the probe */
  51708. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51709. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51710. samples: number;
  51711. /** Gets or sets the refresh rate to use (on every frame by default) */
  51712. refreshRate: number;
  51713. /**
  51714. * Gets the hosting scene
  51715. * @returns a Scene
  51716. */
  51717. getScene(): Scene;
  51718. /** Gets the internal CubeTexture used to render to */
  51719. readonly cubeTexture: RenderTargetTexture;
  51720. /** Gets the list of meshes to render */
  51721. readonly renderList: Nullable<AbstractMesh[]>;
  51722. /**
  51723. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51724. * @param mesh defines the mesh to attach to
  51725. */
  51726. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51727. /**
  51728. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51729. * @param renderingGroupId The rendering group id corresponding to its index
  51730. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51731. */
  51732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51733. /**
  51734. * Clean all associated resources
  51735. */
  51736. dispose(): void;
  51737. /**
  51738. * Converts the reflection probe information to a readable string for debug purpose.
  51739. * @param fullDetails Supports for multiple levels of logging within scene loading
  51740. * @returns the human readable reflection probe info
  51741. */
  51742. toString(fullDetails?: boolean): string;
  51743. /**
  51744. * Get the class name of the relfection probe.
  51745. * @returns "ReflectionProbe"
  51746. */
  51747. getClassName(): string;
  51748. /**
  51749. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51750. * @returns The JSON representation of the texture
  51751. */
  51752. serialize(): any;
  51753. /**
  51754. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51755. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51756. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51757. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51758. * @returns The parsed reflection probe if successful
  51759. */
  51760. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51761. }
  51762. }
  51763. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51764. /** @hidden */
  51765. export var _BabylonLoaderRegistered: boolean;
  51766. }
  51767. declare module "babylonjs/Loading/Plugins/index" {
  51768. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51769. }
  51770. declare module "babylonjs/Loading/index" {
  51771. export * from "babylonjs/Loading/loadingScreen";
  51772. export * from "babylonjs/Loading/Plugins/index";
  51773. export * from "babylonjs/Loading/sceneLoader";
  51774. export * from "babylonjs/Loading/sceneLoaderFlags";
  51775. }
  51776. declare module "babylonjs/Materials/Background/index" {
  51777. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51778. }
  51779. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51780. import { Scene } from "babylonjs/scene";
  51781. import { Color3 } from "babylonjs/Maths/math";
  51782. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51784. /**
  51785. * The Physically based simple base material of BJS.
  51786. *
  51787. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51788. * It is used as the base class for both the specGloss and metalRough conventions.
  51789. */
  51790. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51791. /**
  51792. * Number of Simultaneous lights allowed on the material.
  51793. */
  51794. maxSimultaneousLights: number;
  51795. /**
  51796. * If sets to true, disables all the lights affecting the material.
  51797. */
  51798. disableLighting: boolean;
  51799. /**
  51800. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51801. */
  51802. environmentTexture: BaseTexture;
  51803. /**
  51804. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51805. */
  51806. invertNormalMapX: boolean;
  51807. /**
  51808. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51809. */
  51810. invertNormalMapY: boolean;
  51811. /**
  51812. * Normal map used in the model.
  51813. */
  51814. normalTexture: BaseTexture;
  51815. /**
  51816. * Emissivie color used to self-illuminate the model.
  51817. */
  51818. emissiveColor: Color3;
  51819. /**
  51820. * Emissivie texture used to self-illuminate the model.
  51821. */
  51822. emissiveTexture: BaseTexture;
  51823. /**
  51824. * Occlusion Channel Strenght.
  51825. */
  51826. occlusionStrength: number;
  51827. /**
  51828. * Occlusion Texture of the material (adding extra occlusion effects).
  51829. */
  51830. occlusionTexture: BaseTexture;
  51831. /**
  51832. * Defines the alpha limits in alpha test mode.
  51833. */
  51834. alphaCutOff: number;
  51835. /**
  51836. * Gets the current double sided mode.
  51837. */
  51838. /**
  51839. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51840. */
  51841. doubleSided: boolean;
  51842. /**
  51843. * Stores the pre-calculated light information of a mesh in a texture.
  51844. */
  51845. lightmapTexture: BaseTexture;
  51846. /**
  51847. * If true, the light map contains occlusion information instead of lighting info.
  51848. */
  51849. useLightmapAsShadowmap: boolean;
  51850. /**
  51851. * Instantiates a new PBRMaterial instance.
  51852. *
  51853. * @param name The material name
  51854. * @param scene The scene the material will be use in.
  51855. */
  51856. constructor(name: string, scene: Scene);
  51857. getClassName(): string;
  51858. }
  51859. }
  51860. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51861. import { Scene } from "babylonjs/scene";
  51862. import { Color3 } from "babylonjs/Maths/math";
  51863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51864. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51865. /**
  51866. * The PBR material of BJS following the metal roughness convention.
  51867. *
  51868. * This fits to the PBR convention in the GLTF definition:
  51869. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51870. */
  51871. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51872. /**
  51873. * The base color has two different interpretations depending on the value of metalness.
  51874. * When the material is a metal, the base color is the specific measured reflectance value
  51875. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51876. * of the material.
  51877. */
  51878. baseColor: Color3;
  51879. /**
  51880. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51881. * well as opacity information in the alpha channel.
  51882. */
  51883. baseTexture: BaseTexture;
  51884. /**
  51885. * Specifies the metallic scalar value of the material.
  51886. * Can also be used to scale the metalness values of the metallic texture.
  51887. */
  51888. metallic: number;
  51889. /**
  51890. * Specifies the roughness scalar value of the material.
  51891. * Can also be used to scale the roughness values of the metallic texture.
  51892. */
  51893. roughness: number;
  51894. /**
  51895. * Texture containing both the metallic value in the B channel and the
  51896. * roughness value in the G channel to keep better precision.
  51897. */
  51898. metallicRoughnessTexture: BaseTexture;
  51899. /**
  51900. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51901. *
  51902. * @param name The material name
  51903. * @param scene The scene the material will be use in.
  51904. */
  51905. constructor(name: string, scene: Scene);
  51906. /**
  51907. * Return the currrent class name of the material.
  51908. */
  51909. getClassName(): string;
  51910. /**
  51911. * Makes a duplicate of the current material.
  51912. * @param name - name to use for the new material.
  51913. */
  51914. clone(name: string): PBRMetallicRoughnessMaterial;
  51915. /**
  51916. * Serialize the material to a parsable JSON object.
  51917. */
  51918. serialize(): any;
  51919. /**
  51920. * Parses a JSON object correponding to the serialize function.
  51921. */
  51922. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51923. }
  51924. }
  51925. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51926. import { Scene } from "babylonjs/scene";
  51927. import { Color3 } from "babylonjs/Maths/math";
  51928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51929. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51930. /**
  51931. * The PBR material of BJS following the specular glossiness convention.
  51932. *
  51933. * This fits to the PBR convention in the GLTF definition:
  51934. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51935. */
  51936. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51937. /**
  51938. * Specifies the diffuse color of the material.
  51939. */
  51940. diffuseColor: Color3;
  51941. /**
  51942. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51943. * channel.
  51944. */
  51945. diffuseTexture: BaseTexture;
  51946. /**
  51947. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51948. */
  51949. specularColor: Color3;
  51950. /**
  51951. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51952. */
  51953. glossiness: number;
  51954. /**
  51955. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51956. */
  51957. specularGlossinessTexture: BaseTexture;
  51958. /**
  51959. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51960. *
  51961. * @param name The material name
  51962. * @param scene The scene the material will be use in.
  51963. */
  51964. constructor(name: string, scene: Scene);
  51965. /**
  51966. * Return the currrent class name of the material.
  51967. */
  51968. getClassName(): string;
  51969. /**
  51970. * Makes a duplicate of the current material.
  51971. * @param name - name to use for the new material.
  51972. */
  51973. clone(name: string): PBRSpecularGlossinessMaterial;
  51974. /**
  51975. * Serialize the material to a parsable JSON object.
  51976. */
  51977. serialize(): any;
  51978. /**
  51979. * Parses a JSON object correponding to the serialize function.
  51980. */
  51981. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51982. }
  51983. }
  51984. declare module "babylonjs/Materials/PBR/index" {
  51985. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51986. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51987. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51988. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51989. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51990. }
  51991. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51992. import { Nullable } from "babylonjs/types";
  51993. import { Scene } from "babylonjs/scene";
  51994. import { Matrix } from "babylonjs/Maths/math";
  51995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51996. /**
  51997. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51998. * It can help converting any input color in a desired output one. This can then be used to create effects
  51999. * from sepia, black and white to sixties or futuristic rendering...
  52000. *
  52001. * The only supported format is currently 3dl.
  52002. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52003. */
  52004. export class ColorGradingTexture extends BaseTexture {
  52005. /**
  52006. * The current texture matrix. (will always be identity in color grading texture)
  52007. */
  52008. private _textureMatrix;
  52009. /**
  52010. * The texture URL.
  52011. */
  52012. url: string;
  52013. /**
  52014. * Empty line regex stored for GC.
  52015. */
  52016. private static _noneEmptyLineRegex;
  52017. private _engine;
  52018. /**
  52019. * Instantiates a ColorGradingTexture from the following parameters.
  52020. *
  52021. * @param url The location of the color gradind data (currently only supporting 3dl)
  52022. * @param scene The scene the texture will be used in
  52023. */
  52024. constructor(url: string, scene: Scene);
  52025. /**
  52026. * Returns the texture matrix used in most of the material.
  52027. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52028. */
  52029. getTextureMatrix(): Matrix;
  52030. /**
  52031. * Occurs when the file being loaded is a .3dl LUT file.
  52032. */
  52033. private load3dlTexture;
  52034. /**
  52035. * Starts the loading process of the texture.
  52036. */
  52037. private loadTexture;
  52038. /**
  52039. * Clones the color gradind texture.
  52040. */
  52041. clone(): ColorGradingTexture;
  52042. /**
  52043. * Called during delayed load for textures.
  52044. */
  52045. delayLoad(): void;
  52046. /**
  52047. * Parses a color grading texture serialized by Babylon.
  52048. * @param parsedTexture The texture information being parsedTexture
  52049. * @param scene The scene to load the texture in
  52050. * @param rootUrl The root url of the data assets to load
  52051. * @return A color gradind texture
  52052. */
  52053. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52054. /**
  52055. * Serializes the LUT texture to json format.
  52056. */
  52057. serialize(): any;
  52058. }
  52059. }
  52060. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52062. import { Scene } from "babylonjs/scene";
  52063. import { Nullable } from "babylonjs/types";
  52064. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52065. /**
  52066. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52067. */
  52068. export class EquiRectangularCubeTexture extends BaseTexture {
  52069. /** The six faces of the cube. */
  52070. private static _FacesMapping;
  52071. private _noMipmap;
  52072. private _onLoad;
  52073. private _onError;
  52074. /** The size of the cubemap. */
  52075. private _size;
  52076. /** The buffer of the image. */
  52077. private _buffer;
  52078. /** The width of the input image. */
  52079. private _width;
  52080. /** The height of the input image. */
  52081. private _height;
  52082. /** The URL to the image. */
  52083. url: string;
  52084. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52085. coordinatesMode: number;
  52086. /**
  52087. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52088. * @param url The location of the image
  52089. * @param scene The scene the texture will be used in
  52090. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52091. * @param noMipmap Forces to not generate the mipmap if true
  52092. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52093. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52094. * @param onLoad — defines a callback called when texture is loaded
  52095. * @param onError — defines a callback called if there is an error
  52096. */
  52097. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52098. /**
  52099. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52100. */
  52101. private loadImage;
  52102. /**
  52103. * Convert the image buffer into a cubemap and create a CubeTexture.
  52104. */
  52105. private loadTexture;
  52106. /**
  52107. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52108. * @param buffer The ArrayBuffer that should be converted.
  52109. * @returns The buffer as Float32Array.
  52110. */
  52111. private getFloat32ArrayFromArrayBuffer;
  52112. /**
  52113. * Get the current class name of the texture useful for serialization or dynamic coding.
  52114. * @returns "EquiRectangularCubeTexture"
  52115. */
  52116. getClassName(): string;
  52117. /**
  52118. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52119. * @returns A clone of the current EquiRectangularCubeTexture.
  52120. */
  52121. clone(): EquiRectangularCubeTexture;
  52122. }
  52123. }
  52124. declare module "babylonjs/Misc/tga" {
  52125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52126. /**
  52127. * Based on jsTGALoader - Javascript loader for TGA file
  52128. * By Vincent Thibault
  52129. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52130. */
  52131. export class TGATools {
  52132. private static _TYPE_INDEXED;
  52133. private static _TYPE_RGB;
  52134. private static _TYPE_GREY;
  52135. private static _TYPE_RLE_INDEXED;
  52136. private static _TYPE_RLE_RGB;
  52137. private static _TYPE_RLE_GREY;
  52138. private static _ORIGIN_MASK;
  52139. private static _ORIGIN_SHIFT;
  52140. private static _ORIGIN_BL;
  52141. private static _ORIGIN_BR;
  52142. private static _ORIGIN_UL;
  52143. private static _ORIGIN_UR;
  52144. /**
  52145. * Gets the header of a TGA file
  52146. * @param data defines the TGA data
  52147. * @returns the header
  52148. */
  52149. static GetTGAHeader(data: Uint8Array): any;
  52150. /**
  52151. * Uploads TGA content to a Babylon Texture
  52152. * @hidden
  52153. */
  52154. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52155. /** @hidden */
  52156. 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;
  52157. /** @hidden */
  52158. 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;
  52159. /** @hidden */
  52160. 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;
  52161. /** @hidden */
  52162. 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;
  52163. /** @hidden */
  52164. 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;
  52165. /** @hidden */
  52166. 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;
  52167. }
  52168. }
  52169. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52170. import { Nullable } from "babylonjs/types";
  52171. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52172. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52173. /**
  52174. * Implementation of the TGA Texture Loader.
  52175. * @hidden
  52176. */
  52177. export class _TGATextureLoader implements IInternalTextureLoader {
  52178. /**
  52179. * Defines wether the loader supports cascade loading the different faces.
  52180. */
  52181. readonly supportCascades: boolean;
  52182. /**
  52183. * This returns if the loader support the current file information.
  52184. * @param extension defines the file extension of the file being loaded
  52185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52186. * @param fallback defines the fallback internal texture if any
  52187. * @param isBase64 defines whether the texture is encoded as a base64
  52188. * @param isBuffer defines whether the texture data are stored as a buffer
  52189. * @returns true if the loader can load the specified file
  52190. */
  52191. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52192. /**
  52193. * Transform the url before loading if required.
  52194. * @param rootUrl the url of the texture
  52195. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52196. * @returns the transformed texture
  52197. */
  52198. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52199. /**
  52200. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52201. * @param rootUrl the url of the texture
  52202. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52203. * @returns the fallback texture
  52204. */
  52205. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52206. /**
  52207. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52208. * @param data contains the texture data
  52209. * @param texture defines the BabylonJS internal texture
  52210. * @param createPolynomials will be true if polynomials have been requested
  52211. * @param onLoad defines the callback to trigger once the texture is ready
  52212. * @param onError defines the callback to trigger in case of error
  52213. */
  52214. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52215. /**
  52216. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52217. * @param data contains the texture data
  52218. * @param texture defines the BabylonJS internal texture
  52219. * @param callback defines the method to call once ready to upload
  52220. */
  52221. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52222. }
  52223. }
  52224. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52225. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52226. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52227. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52228. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52229. }
  52230. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52231. import { Scene } from "babylonjs/scene";
  52232. import { Texture } from "babylonjs/Materials/Textures/texture";
  52233. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52234. /**
  52235. * 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.
  52236. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52237. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52238. */
  52239. export class CustomProceduralTexture extends ProceduralTexture {
  52240. private _animate;
  52241. private _time;
  52242. private _config;
  52243. private _texturePath;
  52244. /**
  52245. * Instantiates a new Custom Procedural Texture.
  52246. * 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.
  52247. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52248. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52249. * @param name Define the name of the texture
  52250. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52251. * @param size Define the size of the texture to create
  52252. * @param scene Define the scene the texture belongs to
  52253. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52254. * @param generateMipMaps Define if the texture should creates mip maps or not
  52255. */
  52256. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52257. private _loadJson;
  52258. /**
  52259. * Is the texture ready to be used ? (rendered at least once)
  52260. * @returns true if ready, otherwise, false.
  52261. */
  52262. isReady(): boolean;
  52263. /**
  52264. * Render the texture to its associated render target.
  52265. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52266. */
  52267. render(useCameraPostProcess?: boolean): void;
  52268. /**
  52269. * Update the list of dependant textures samplers in the shader.
  52270. */
  52271. updateTextures(): void;
  52272. /**
  52273. * Update the uniform values of the procedural texture in the shader.
  52274. */
  52275. updateShaderUniforms(): void;
  52276. /**
  52277. * Define if the texture animates or not.
  52278. */
  52279. animate: boolean;
  52280. }
  52281. }
  52282. declare module "babylonjs/Shaders/noise.fragment" {
  52283. /** @hidden */
  52284. export var noisePixelShader: {
  52285. name: string;
  52286. shader: string;
  52287. };
  52288. }
  52289. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52290. import { Nullable } from "babylonjs/types";
  52291. import { Scene } from "babylonjs/scene";
  52292. import { Texture } from "babylonjs/Materials/Textures/texture";
  52293. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52294. import "babylonjs/Shaders/noise.fragment";
  52295. /**
  52296. * Class used to generate noise procedural textures
  52297. */
  52298. export class NoiseProceduralTexture extends ProceduralTexture {
  52299. private _time;
  52300. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52301. brightness: number;
  52302. /** Defines the number of octaves to process */
  52303. octaves: number;
  52304. /** Defines the level of persistence (0.8 by default) */
  52305. persistence: number;
  52306. /** Gets or sets animation speed factor (default is 1) */
  52307. animationSpeedFactor: number;
  52308. /**
  52309. * Creates a new NoiseProceduralTexture
  52310. * @param name defines the name fo the texture
  52311. * @param size defines the size of the texture (default is 256)
  52312. * @param scene defines the hosting scene
  52313. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52314. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52315. */
  52316. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52317. private _updateShaderUniforms;
  52318. protected _getDefines(): string;
  52319. /** Generate the current state of the procedural texture */
  52320. render(useCameraPostProcess?: boolean): void;
  52321. /**
  52322. * Serializes this noise procedural texture
  52323. * @returns a serialized noise procedural texture object
  52324. */
  52325. serialize(): any;
  52326. /**
  52327. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52328. * @param parsedTexture defines parsed texture data
  52329. * @param scene defines the current scene
  52330. * @param rootUrl defines the root URL containing noise procedural texture information
  52331. * @returns a parsed NoiseProceduralTexture
  52332. */
  52333. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52334. }
  52335. }
  52336. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52337. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52338. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52339. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52340. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52341. }
  52342. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52343. import { Nullable } from "babylonjs/types";
  52344. import { Scene } from "babylonjs/scene";
  52345. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52347. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52348. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52349. /**
  52350. * Raw cube texture where the raw buffers are passed in
  52351. */
  52352. export class RawCubeTexture extends CubeTexture {
  52353. /**
  52354. * Creates a cube texture where the raw buffers are passed in.
  52355. * @param scene defines the scene the texture is attached to
  52356. * @param data defines the array of data to use to create each face
  52357. * @param size defines the size of the textures
  52358. * @param format defines the format of the data
  52359. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52360. * @param generateMipMaps defines if the engine should generate the mip levels
  52361. * @param invertY defines if data must be stored with Y axis inverted
  52362. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52363. * @param compression defines the compression used (null by default)
  52364. */
  52365. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52366. /**
  52367. * Updates the raw cube texture.
  52368. * @param data defines the data to store
  52369. * @param format defines the data format
  52370. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52371. * @param invertY defines if data must be stored with Y axis inverted
  52372. * @param compression defines the compression used (null by default)
  52373. * @param level defines which level of the texture to update
  52374. */
  52375. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52376. /**
  52377. * Updates a raw cube texture with RGBD encoded data.
  52378. * @param data defines the array of data [mipmap][face] to use to create each face
  52379. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52380. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52381. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52382. * @returns a promsie that resolves when the operation is complete
  52383. */
  52384. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52385. /**
  52386. * Clones the raw cube texture.
  52387. * @return a new cube texture
  52388. */
  52389. clone(): CubeTexture;
  52390. /** @hidden */
  52391. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52392. }
  52393. }
  52394. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52395. import { Scene } from "babylonjs/scene";
  52396. import { Texture } from "babylonjs/Materials/Textures/texture";
  52397. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52398. /**
  52399. * Class used to store 3D textures containing user data
  52400. */
  52401. export class RawTexture3D extends Texture {
  52402. /** Gets or sets the texture format to use */
  52403. format: number;
  52404. private _engine;
  52405. /**
  52406. * Create a new RawTexture3D
  52407. * @param data defines the data of the texture
  52408. * @param width defines the width of the texture
  52409. * @param height defines the height of the texture
  52410. * @param depth defines the depth of the texture
  52411. * @param format defines the texture format to use
  52412. * @param scene defines the hosting scene
  52413. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52414. * @param invertY defines if texture must be stored with Y axis inverted
  52415. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52416. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52417. */
  52418. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52419. /** Gets or sets the texture format to use */
  52420. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52421. /**
  52422. * Update the texture with new data
  52423. * @param data defines the data to store in the texture
  52424. */
  52425. update(data: ArrayBufferView): void;
  52426. }
  52427. }
  52428. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52429. import { Scene } from "babylonjs/scene";
  52430. import { Plane } from "babylonjs/Maths/math";
  52431. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52432. /**
  52433. * Creates a refraction texture used by refraction channel of the standard material.
  52434. * It is like a mirror but to see through a material.
  52435. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52436. */
  52437. export class RefractionTexture extends RenderTargetTexture {
  52438. /**
  52439. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52440. * 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.
  52441. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52442. */
  52443. refractionPlane: Plane;
  52444. /**
  52445. * Define how deep under the surface we should see.
  52446. */
  52447. depth: number;
  52448. /**
  52449. * Creates a refraction texture used by refraction channel of the standard material.
  52450. * It is like a mirror but to see through a material.
  52451. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52452. * @param name Define the texture name
  52453. * @param size Define the size of the underlying texture
  52454. * @param scene Define the scene the refraction belongs to
  52455. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52456. */
  52457. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52458. /**
  52459. * Clone the refraction texture.
  52460. * @returns the cloned texture
  52461. */
  52462. clone(): RefractionTexture;
  52463. /**
  52464. * Serialize the texture to a JSON representation you could use in Parse later on
  52465. * @returns the serialized JSON representation
  52466. */
  52467. serialize(): any;
  52468. }
  52469. }
  52470. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52471. import { Nullable } from "babylonjs/types";
  52472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52473. import { Matrix } from "babylonjs/Maths/math";
  52474. import { Engine } from "babylonjs/Engines/engine";
  52475. import { Scene } from "babylonjs/scene";
  52476. /**
  52477. * Defines the options related to the creation of an HtmlElementTexture
  52478. */
  52479. export interface IHtmlElementTextureOptions {
  52480. /**
  52481. * Defines wether mip maps should be created or not.
  52482. */
  52483. generateMipMaps?: boolean;
  52484. /**
  52485. * Defines the sampling mode of the texture.
  52486. */
  52487. samplingMode?: number;
  52488. /**
  52489. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52490. */
  52491. engine: Nullable<Engine>;
  52492. /**
  52493. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52494. */
  52495. scene: Nullable<Scene>;
  52496. }
  52497. /**
  52498. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52499. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52500. * is automatically managed.
  52501. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52502. * in your application.
  52503. *
  52504. * As the update is not automatic, you need to call them manually.
  52505. */
  52506. export class HtmlElementTexture extends BaseTexture {
  52507. /**
  52508. * The texture URL.
  52509. */
  52510. element: HTMLVideoElement | HTMLCanvasElement;
  52511. private static readonly DefaultOptions;
  52512. private _textureMatrix;
  52513. private _engine;
  52514. private _isVideo;
  52515. private _generateMipMaps;
  52516. private _samplingMode;
  52517. /**
  52518. * Instantiates a HtmlElementTexture from the following parameters.
  52519. *
  52520. * @param name Defines the name of the texture
  52521. * @param element Defines the video or canvas the texture is filled with
  52522. * @param options Defines the other none mandatory texture creation options
  52523. */
  52524. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52525. private _createInternalTexture;
  52526. /**
  52527. * Returns the texture matrix used in most of the material.
  52528. */
  52529. getTextureMatrix(): Matrix;
  52530. /**
  52531. * Updates the content of the texture.
  52532. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52533. */
  52534. update(invertY?: Nullable<boolean>): void;
  52535. }
  52536. }
  52537. declare module "babylonjs/Materials/Textures/index" {
  52538. export * from "babylonjs/Materials/Textures/baseTexture";
  52539. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52540. export * from "babylonjs/Materials/Textures/cubeTexture";
  52541. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52542. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52543. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52544. export * from "babylonjs/Materials/Textures/internalTexture";
  52545. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52546. export * from "babylonjs/Materials/Textures/Loaders/index";
  52547. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52548. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52549. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52550. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52551. export * from "babylonjs/Materials/Textures/rawTexture";
  52552. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52553. export * from "babylonjs/Materials/Textures/refractionTexture";
  52554. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52555. export * from "babylonjs/Materials/Textures/texture";
  52556. export * from "babylonjs/Materials/Textures/videoTexture";
  52557. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52558. }
  52559. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52560. /**
  52561. * Enum used to define the target of a block
  52562. */
  52563. export enum NodeMaterialBlockTargets {
  52564. /** Vertex shader */
  52565. Vertex = 1,
  52566. /** Fragment shader */
  52567. Fragment = 2,
  52568. /** Vertex and Fragment */
  52569. VertexAndFragment = 3
  52570. }
  52571. }
  52572. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52573. /**
  52574. * Defines the kind of connection point for node based material
  52575. */
  52576. export enum NodeMaterialBlockConnectionPointTypes {
  52577. /** Float */
  52578. Float = 1,
  52579. /** Int */
  52580. Int = 2,
  52581. /** Vector2 */
  52582. Vector2 = 4,
  52583. /** Vector3 */
  52584. Vector3 = 8,
  52585. /** Vector4 */
  52586. Vector4 = 16,
  52587. /** Color3 */
  52588. Color3 = 32,
  52589. /** Color4 */
  52590. Color4 = 64,
  52591. /** Matrix */
  52592. Matrix = 128,
  52593. /** Texture */
  52594. Texture = 256,
  52595. /** Texture3D */
  52596. Texture3D = 512,
  52597. /** Vector3 or Color3 */
  52598. Vector3OrColor3 = 40,
  52599. /** Vector3 or Vector4 */
  52600. Vector3OrVector4 = 24,
  52601. /** Vector4 or Color4 */
  52602. Vector4OrColor4 = 80,
  52603. /** Color3 or Color4 */
  52604. Color3OrColor4 = 96,
  52605. /** Vector3 or Color3 */
  52606. Vector3OrColor3OrVector4OrColor4 = 120
  52607. }
  52608. }
  52609. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52610. /**
  52611. * Enum used to define well known values e.g. values automatically provided by the system
  52612. */
  52613. export enum NodeMaterialWellKnownValues {
  52614. /** World */
  52615. World = 1,
  52616. /** View */
  52617. View = 2,
  52618. /** Projection */
  52619. Projection = 3,
  52620. /** ViewProjection */
  52621. ViewProjection = 4,
  52622. /** WorldView */
  52623. WorldView = 5,
  52624. /** WorldViewProjection */
  52625. WorldViewProjection = 6,
  52626. /** Will be filled by the block itself */
  52627. Automatic = 7
  52628. }
  52629. }
  52630. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52631. /**
  52632. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52633. */
  52634. export enum NodeMaterialBlockConnectionPointMode {
  52635. /** Value is an uniform */
  52636. Uniform = 0,
  52637. /** Value is a mesh attribute */
  52638. Attribute = 1,
  52639. /** Value is a varying between vertex and fragment shaders */
  52640. Varying = 2,
  52641. /** Mode is undefined */
  52642. Undefined = 3
  52643. }
  52644. }
  52645. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52647. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52648. /**
  52649. * Class used to store shared data between 2 NodeMaterialBuildState
  52650. */
  52651. export class NodeMaterialBuildStateSharedData {
  52652. /**
  52653. * Gets the list of emitted varyings
  52654. */
  52655. varyings: string[];
  52656. /**
  52657. * Gets the varying declaration string
  52658. */
  52659. varyingDeclaration: string;
  52660. /**
  52661. * Uniform connection points
  52662. */
  52663. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52664. /**
  52665. * Bindable blocks (Blocks that need to set data to the effect)
  52666. */
  52667. bindableBlocks: NodeMaterialBlock[];
  52668. /**
  52669. * List of blocks that can provide a compilation fallback
  52670. */
  52671. blocksWithFallbacks: NodeMaterialBlock[];
  52672. /**
  52673. * List of blocks that can provide a define update
  52674. */
  52675. blocksWithDefines: NodeMaterialBlock[];
  52676. /**
  52677. * List of blocks that can provide a repeatable content
  52678. */
  52679. repeatableContentBlocks: NodeMaterialBlock[];
  52680. /**
  52681. * List of blocks that can block the isReady function for the material
  52682. */
  52683. blockingBlocks: NodeMaterialBlock[];
  52684. /**
  52685. * Build Id used to avoid multiple recompilations
  52686. */
  52687. buildId: number;
  52688. /** List of emitted variables */
  52689. variableNames: {
  52690. [key: string]: number;
  52691. };
  52692. /** List of emitted defines */
  52693. defineNames: {
  52694. [key: string]: number;
  52695. };
  52696. /** Should emit comments? */
  52697. emitComments: boolean;
  52698. /** Emit build activity */
  52699. verbose: boolean;
  52700. /**
  52701. * Gets the compilation hints emitted at compilation time
  52702. */
  52703. hints: {
  52704. needWorldViewMatrix: boolean;
  52705. needWorldViewProjectionMatrix: boolean;
  52706. needAlphaBlending: boolean;
  52707. needAlphaTesting: boolean;
  52708. };
  52709. /**
  52710. * List of compilation checks
  52711. */
  52712. checks: {
  52713. emitVertex: boolean;
  52714. emitFragment: boolean;
  52715. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52716. };
  52717. /** Creates a new shared data */
  52718. constructor();
  52719. /**
  52720. * Emits console errors and exceptions if there is a failing check
  52721. */
  52722. emitErrors(): void;
  52723. }
  52724. }
  52725. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52727. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52728. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52729. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52730. /**
  52731. * Class used to store node based material build state
  52732. */
  52733. export class NodeMaterialBuildState {
  52734. /**
  52735. * Gets the list of emitted attributes
  52736. */
  52737. attributes: string[];
  52738. /**
  52739. * Gets the list of emitted uniforms
  52740. */
  52741. uniforms: string[];
  52742. /**
  52743. * Gets the list of emitted samplers
  52744. */
  52745. samplers: string[];
  52746. /**
  52747. * Gets the list of emitted functions
  52748. */
  52749. functions: {
  52750. [key: string]: string;
  52751. };
  52752. /**
  52753. * Gets the target of the compilation state
  52754. */
  52755. target: NodeMaterialBlockTargets;
  52756. /**
  52757. * Shared data between multiple NodeMaterialBuildState instances
  52758. */
  52759. sharedData: NodeMaterialBuildStateSharedData;
  52760. /** @hidden */
  52761. _vertexState: NodeMaterialBuildState;
  52762. private _attributeDeclaration;
  52763. private _uniformDeclaration;
  52764. private _samplerDeclaration;
  52765. private _varyingTransfer;
  52766. private _repeatableContentAnchorIndex;
  52767. /** @hidden */
  52768. _builtCompilationString: string;
  52769. /**
  52770. * Gets the emitted compilation strings
  52771. */
  52772. compilationString: string;
  52773. /**
  52774. * Finalize the compilation strings
  52775. * @param state defines the current compilation state
  52776. */
  52777. finalize(state: NodeMaterialBuildState): void;
  52778. /** @hidden */
  52779. readonly _repeatableContentAnchor: string;
  52780. /** @hidden */
  52781. _getFreeVariableName(prefix: string): string;
  52782. /** @hidden */
  52783. _getFreeDefineName(prefix: string): string;
  52784. /** @hidden */
  52785. _excludeVariableName(name: string): void;
  52786. /** @hidden */
  52787. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52788. /** @hidden */
  52789. _emitFunction(name: string, code: string, comments: string): void;
  52790. /** @hidden */
  52791. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52792. replaceStrings?: {
  52793. search: RegExp;
  52794. replace: string;
  52795. }[];
  52796. }): string;
  52797. /** @hidden */
  52798. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52799. repeatKey?: string;
  52800. removeAttributes?: boolean;
  52801. removeUniforms?: boolean;
  52802. removeVaryings?: boolean;
  52803. removeIfDef?: boolean;
  52804. replaceStrings?: {
  52805. search: RegExp;
  52806. replace: string;
  52807. }[];
  52808. }): void;
  52809. /** @hidden */
  52810. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52811. private _emitDefine;
  52812. /** @hidden */
  52813. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52814. }
  52815. }
  52816. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52817. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52818. /**
  52819. * Root class for all node material optimizers
  52820. */
  52821. export class NodeMaterialOptimizer {
  52822. /**
  52823. * Function used to optimize a NodeMaterial graph
  52824. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52825. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52826. */
  52827. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52828. }
  52829. }
  52830. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  52831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52834. /**
  52835. * Block used to transform a vector4 with a matrix
  52836. */
  52837. export class Vector4TransformBlock extends NodeMaterialBlock {
  52838. /**
  52839. * Defines the value to use to complement Vector3 to transform it to a Vector4
  52840. */
  52841. complementW: number;
  52842. /**
  52843. * Creates a new Vector4TransformBlock
  52844. * @param name defines the block name
  52845. */
  52846. constructor(name: string);
  52847. /**
  52848. * Gets the current class name
  52849. * @returns the class name
  52850. */
  52851. getClassName(): string;
  52852. /**
  52853. * Gets the vector input
  52854. */
  52855. readonly vector: NodeMaterialConnectionPoint;
  52856. /**
  52857. * Gets the matrix transform input
  52858. */
  52859. readonly transform: NodeMaterialConnectionPoint;
  52860. protected _buildBlock(state: NodeMaterialBuildState): this;
  52861. }
  52862. }
  52863. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  52864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52867. /**
  52868. * Block used to output the vertex position
  52869. */
  52870. export class VertexOutputBlock extends NodeMaterialBlock {
  52871. /**
  52872. * Creates a new VertexOutputBlock
  52873. * @param name defines the block name
  52874. */
  52875. constructor(name: string);
  52876. /**
  52877. * Gets the current class name
  52878. * @returns the class name
  52879. */
  52880. getClassName(): string;
  52881. /**
  52882. * Gets the vector input component
  52883. */
  52884. readonly vector: NodeMaterialConnectionPoint;
  52885. protected _buildBlock(state: NodeMaterialBuildState): this;
  52886. }
  52887. }
  52888. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  52889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52892. /**
  52893. * Block used to output the final color
  52894. */
  52895. export class FragmentOutputBlock extends NodeMaterialBlock {
  52896. /**
  52897. * Gets or sets a boolean indicating if this block will output an alpha value
  52898. */
  52899. alphaBlendingEnabled: boolean;
  52900. /**
  52901. * Create a new FragmentOutputBlock
  52902. * @param name defines the block name
  52903. */
  52904. constructor(name: string);
  52905. /**
  52906. * Gets the current class name
  52907. * @returns the class name
  52908. */
  52909. getClassName(): string;
  52910. /**
  52911. * Gets the color input component
  52912. */
  52913. readonly color: NodeMaterialConnectionPoint;
  52914. protected _buildBlock(state: NodeMaterialBuildState): this;
  52915. }
  52916. }
  52917. declare module "babylonjs/Materials/Node/nodeMaterial" {
  52918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52919. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52920. import { Scene } from "babylonjs/scene";
  52921. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52922. import { Matrix } from "babylonjs/Maths/math";
  52923. import { Mesh } from "babylonjs/Meshes/mesh";
  52924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52925. import { Observable } from "babylonjs/Misc/observable";
  52926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52927. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52928. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  52929. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52930. import { Nullable } from "babylonjs/types";
  52931. /**
  52932. * Interface used to configure the node material editor
  52933. */
  52934. export interface INodeMaterialEditorOptions {
  52935. /** Define the URl to load node editor script */
  52936. editorURL?: string;
  52937. }
  52938. /** @hidden */
  52939. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52940. /** BONES */
  52941. NUM_BONE_INFLUENCERS: number;
  52942. BonesPerMesh: number;
  52943. BONETEXTURE: boolean;
  52944. /** MORPH TARGETS */
  52945. MORPHTARGETS: boolean;
  52946. MORPHTARGETS_NORMAL: boolean;
  52947. MORPHTARGETS_TANGENT: boolean;
  52948. NUM_MORPH_INFLUENCERS: number;
  52949. /** IMAGE PROCESSING */
  52950. IMAGEPROCESSING: boolean;
  52951. VIGNETTE: boolean;
  52952. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52953. VIGNETTEBLENDMODEOPAQUE: boolean;
  52954. TONEMAPPING: boolean;
  52955. TONEMAPPING_ACES: boolean;
  52956. CONTRAST: boolean;
  52957. EXPOSURE: boolean;
  52958. COLORCURVES: boolean;
  52959. COLORGRADING: boolean;
  52960. COLORGRADING3D: boolean;
  52961. SAMPLER3DGREENDEPTH: boolean;
  52962. SAMPLER3DBGRMAP: boolean;
  52963. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52964. constructor();
  52965. setValue(name: string, value: boolean): void;
  52966. }
  52967. /**
  52968. * Class used to configure NodeMaterial
  52969. */
  52970. export interface INodeMaterialOptions {
  52971. /**
  52972. * Defines if blocks should emit comments
  52973. */
  52974. emitComments: boolean;
  52975. }
  52976. /**
  52977. * Class used to create a node based material built by assembling shader blocks
  52978. */
  52979. export class NodeMaterial extends PushMaterial {
  52980. private _options;
  52981. private _vertexCompilationState;
  52982. private _fragmentCompilationState;
  52983. private _sharedData;
  52984. private _buildId;
  52985. private _buildWasSuccessful;
  52986. private _cachedWorldViewMatrix;
  52987. private _cachedWorldViewProjectionMatrix;
  52988. private _textureConnectionPoints;
  52989. private _optimizers;
  52990. /** Define the URl to load node editor script */
  52991. static EditorURL: string;
  52992. private BJSNODEMATERIALEDITOR;
  52993. /** Get the inspector from bundle or global */
  52994. private _getGlobalNodeMaterialEditor;
  52995. /**
  52996. * Defines the maximum number of lights that can be used in the material
  52997. */
  52998. maxSimultaneousLights: number;
  52999. /**
  53000. * Observable raised when the material is built
  53001. */
  53002. onBuildObservable: Observable<NodeMaterial>;
  53003. /**
  53004. * Gets or sets the root nodes of the material vertex shader
  53005. */
  53006. _vertexOutputNodes: NodeMaterialBlock[];
  53007. /**
  53008. * Gets or sets the root nodes of the material fragment (pixel) shader
  53009. */
  53010. _fragmentOutputNodes: NodeMaterialBlock[];
  53011. /** Gets or sets options to control the node material overall behavior */
  53012. options: INodeMaterialOptions;
  53013. /**
  53014. * Default configuration related to image processing available in the standard Material.
  53015. */
  53016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53017. /**
  53018. * Gets the image processing configuration used either in this material.
  53019. */
  53020. /**
  53021. * Sets the Default image processing configuration used either in the this material.
  53022. *
  53023. * If sets to null, the scene one is in use.
  53024. */
  53025. imageProcessingConfiguration: ImageProcessingConfiguration;
  53026. /**
  53027. * Create a new node based material
  53028. * @param name defines the material name
  53029. * @param scene defines the hosting scene
  53030. * @param options defines creation option
  53031. */
  53032. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53033. /**
  53034. * Gets the current class name of the material e.g. "NodeMaterial"
  53035. * @returns the class name
  53036. */
  53037. getClassName(): string;
  53038. /**
  53039. * Keep track of the image processing observer to allow dispose and replace.
  53040. */
  53041. private _imageProcessingObserver;
  53042. /**
  53043. * Attaches a new image processing configuration to the Standard Material.
  53044. * @param configuration
  53045. */
  53046. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53047. /**
  53048. * Adds a new optimizer to the list of optimizers
  53049. * @param optimizer defines the optimizers to add
  53050. * @returns the current material
  53051. */
  53052. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53053. /**
  53054. * Remove an optimizer from the list of optimizers
  53055. * @param optimizer defines the optimizers to remove
  53056. * @returns the current material
  53057. */
  53058. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53059. /**
  53060. * Add a new block to the list of output nodes
  53061. * @param node defines the node to add
  53062. * @returns the current material
  53063. */
  53064. addOutputNode(node: NodeMaterialBlock): this;
  53065. /**
  53066. * Remove a block from the list of root nodes
  53067. * @param node defines the node to remove
  53068. * @returns the current material
  53069. */
  53070. removeOutputNode(node: NodeMaterialBlock): this;
  53071. private _addVertexOutputNode;
  53072. private _removeVertexOutputNode;
  53073. private _addFragmentOutputNode;
  53074. private _removeFragmentOutputNode;
  53075. /**
  53076. * Specifies if the material will require alpha blending
  53077. * @returns a boolean specifying if alpha blending is needed
  53078. */
  53079. needAlphaBlending(): boolean;
  53080. /**
  53081. * Specifies if this material should be rendered in alpha test mode
  53082. * @returns a boolean specifying if an alpha test is needed.
  53083. */
  53084. needAlphaTesting(): boolean;
  53085. private _initializeBlock;
  53086. private _resetDualBlocks;
  53087. /**
  53088. * Build the material and generates the inner effect
  53089. * @param verbose defines if the build should log activity
  53090. */
  53091. build(verbose?: boolean): void;
  53092. /**
  53093. * Runs an otpimization phase to try to improve the shader code
  53094. */
  53095. optimize(): void;
  53096. private _prepareDefinesForAttributes;
  53097. /**
  53098. * Get if the submesh is ready to be used and all its information available.
  53099. * Child classes can use it to update shaders
  53100. * @param mesh defines the mesh to check
  53101. * @param subMesh defines which submesh to check
  53102. * @param useInstances specifies that instances should be used
  53103. * @returns a boolean indicating that the submesh is ready or not
  53104. */
  53105. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53106. /**
  53107. * Binds the world matrix to the material
  53108. * @param world defines the world transformation matrix
  53109. */
  53110. bindOnlyWorldMatrix(world: Matrix): void;
  53111. /**
  53112. * Binds the submesh to this material by preparing the effect and shader to draw
  53113. * @param world defines the world transformation matrix
  53114. * @param mesh defines the mesh containing the submesh
  53115. * @param subMesh defines the submesh to bind the material to
  53116. */
  53117. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53118. /**
  53119. * Gets the active textures from the material
  53120. * @returns an array of textures
  53121. */
  53122. getActiveTextures(): BaseTexture[];
  53123. /**
  53124. * Specifies if the material uses a texture
  53125. * @param texture defines the texture to check against the material
  53126. * @returns a boolean specifying if the material uses the texture
  53127. */
  53128. hasTexture(texture: BaseTexture): boolean;
  53129. /**
  53130. * Disposes the material
  53131. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53132. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53133. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53134. */
  53135. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53136. /** Creates the node editor window. */
  53137. private _createNodeEditor;
  53138. /**
  53139. * Launch the node material editor
  53140. * @param config Define the configuration of the editor
  53141. * @return a promise fulfilled when the node editor is visible
  53142. */
  53143. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53144. /**
  53145. * Clear the current material
  53146. */
  53147. clear(): void;
  53148. /**
  53149. * Clear the current material and set it to a default state
  53150. */
  53151. setToDefault(): void;
  53152. }
  53153. }
  53154. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53155. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53157. import { Nullable } from "babylonjs/types";
  53158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53159. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53160. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53162. import { Mesh } from "babylonjs/Meshes/mesh";
  53163. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53164. /**
  53165. * Defines a block that can be used inside a node based material
  53166. */
  53167. export class NodeMaterialBlock {
  53168. private _buildId;
  53169. private _target;
  53170. private _isFinalMerger;
  53171. /** @hidden */
  53172. _inputs: NodeMaterialConnectionPoint[];
  53173. /** @hidden */
  53174. _outputs: NodeMaterialConnectionPoint[];
  53175. /**
  53176. * Gets or sets the name of the block
  53177. */
  53178. name: string;
  53179. /**
  53180. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53181. */
  53182. readonly isFinalMerger: boolean;
  53183. /**
  53184. * Gets or sets the build Id
  53185. */
  53186. buildId: number;
  53187. /**
  53188. * Gets or sets the target of the block
  53189. */
  53190. target: NodeMaterialBlockTargets;
  53191. /**
  53192. * Gets the list of input points
  53193. */
  53194. readonly inputs: NodeMaterialConnectionPoint[];
  53195. /** Gets the list of output points */
  53196. readonly outputs: NodeMaterialConnectionPoint[];
  53197. /**
  53198. * Find an input by its name
  53199. * @param name defines the name of the input to look for
  53200. * @returns the input or null if not found
  53201. */
  53202. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53203. /**
  53204. * Find an output by its name
  53205. * @param name defines the name of the outputto look for
  53206. * @returns the output or null if not found
  53207. */
  53208. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53209. /**
  53210. * Creates a new NodeMaterialBlock
  53211. * @param name defines the block name
  53212. * @param target defines the target of that block (Vertex by default)
  53213. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53214. */
  53215. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53216. /**
  53217. * Initialize the block and prepare the context for build
  53218. * @param state defines the state that will be used for the build
  53219. */
  53220. initialize(state: NodeMaterialBuildState): void;
  53221. /**
  53222. * Bind data to effect. Will only be called for blocks with isBindable === true
  53223. * @param effect defines the effect to bind data to
  53224. * @param nodeMaterial defines the hosting NodeMaterial
  53225. * @param mesh defines the mesh that will be rendered
  53226. */
  53227. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53228. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53229. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53230. protected _writeFloat(value: number): string;
  53231. /**
  53232. * Gets the current class name e.g. "NodeMaterialBlock"
  53233. * @returns the class name
  53234. */
  53235. getClassName(): string;
  53236. /**
  53237. * Register a new input. Must be called inside a block constructor
  53238. * @param name defines the connection point name
  53239. * @param type defines the connection point type
  53240. * @param isOptional defines a boolean indicating that this input can be omitted
  53241. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53242. * @returns the current block
  53243. */
  53244. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53245. /**
  53246. * Register a new output. Must be called inside a block constructor
  53247. * @param name defines the connection point name
  53248. * @param type defines the connection point type
  53249. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53250. * @returns the current block
  53251. */
  53252. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53253. /**
  53254. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53255. * @param forOutput defines an optional connection point to check compatibility with
  53256. * @returns the first available input or null
  53257. */
  53258. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53259. /**
  53260. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53261. * @param forBlock defines an optional block to check compatibility with
  53262. * @returns the first available input or null
  53263. */
  53264. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53265. /**
  53266. * Connect current block with another block
  53267. * @param other defines the block to connect with
  53268. * @param options define the various options to help pick the right connections
  53269. * @returns the current block
  53270. */
  53271. connectTo(other: NodeMaterialBlock, options?: {
  53272. input?: string;
  53273. output?: string;
  53274. outputSwizzle?: string;
  53275. }): this | undefined;
  53276. protected _buildBlock(state: NodeMaterialBuildState): void;
  53277. /**
  53278. * Add potential fallbacks if shader compilation fails
  53279. * @param mesh defines the mesh to be rendered
  53280. * @param fallbacks defines the current prioritized list of fallbacks
  53281. */
  53282. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53283. /**
  53284. * Update defines for shader compilation
  53285. * @param mesh defines the mesh to be rendered
  53286. * @param nodeMaterial defines the node material requesting the update
  53287. * @param defines defines the material defines to update
  53288. * @param useInstances specifies that instances should be used
  53289. */
  53290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53291. /**
  53292. * Lets the block try to connect some inputs automatically
  53293. */
  53294. autoConfigure(): void;
  53295. /**
  53296. * Function called when a block is declared as repeatable content generator
  53297. * @param vertexShaderState defines the current compilation state for the vertex shader
  53298. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53299. * @param mesh defines the mesh to be rendered
  53300. * @param defines defines the material defines to update
  53301. */
  53302. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53303. /**
  53304. * Checks if the block is ready
  53305. * @param mesh defines the mesh to be rendered
  53306. * @param nodeMaterial defines the node material requesting the update
  53307. * @param defines defines the material defines to update
  53308. * @param useInstances specifies that instances should be used
  53309. * @returns true if the block is ready
  53310. */
  53311. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53312. /**
  53313. * Compile the current node and generate the shader code
  53314. * @param state defines the current compilation state (uniforms, samplers, current string)
  53315. * @returns the current block
  53316. */
  53317. build(state: NodeMaterialBuildState): this | undefined;
  53318. }
  53319. }
  53320. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53321. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53322. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53323. import { Nullable } from "babylonjs/types";
  53324. import { Effect } from "babylonjs/Materials/effect";
  53325. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53326. import { Scene } from "babylonjs/scene";
  53327. import { Matrix } from "babylonjs/Maths/math";
  53328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53329. /**
  53330. * Defines a connection point for a block
  53331. */
  53332. export class NodeMaterialConnectionPoint {
  53333. /** @hidden */
  53334. _ownerBlock: NodeMaterialBlock;
  53335. /** @hidden */
  53336. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53337. private _associatedVariableName;
  53338. private _endpoints;
  53339. private _storedValue;
  53340. private _valueCallback;
  53341. private _mode;
  53342. /** @hidden */
  53343. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53344. /** @hidden */
  53345. _needToEmitVarying: boolean;
  53346. /**
  53347. * Gets or sets the connection point type (default is float)
  53348. */
  53349. type: NodeMaterialBlockConnectionPointTypes;
  53350. /**
  53351. * Gets or sets the connection point name
  53352. */
  53353. name: string;
  53354. /**
  53355. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53356. */
  53357. swizzle: string;
  53358. /**
  53359. * Gets or sets a boolean indicating that this connection point can be omitted
  53360. */
  53361. isOptional: boolean;
  53362. /**
  53363. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53364. */
  53365. define: string;
  53366. /** Gets or sets the target of that connection point */
  53367. target: NodeMaterialBlockTargets;
  53368. /**
  53369. * Gets or sets the value of that point.
  53370. * Please note that this value will be ignored if valueCallback is defined
  53371. */
  53372. value: any;
  53373. /**
  53374. * Gets or sets a callback used to get the value of that point.
  53375. * Please note that setting this value will force the connection point to ignore the value property
  53376. */
  53377. valueCallback: () => any;
  53378. /**
  53379. * Gets or sets the associated variable name in the shader
  53380. */
  53381. associatedVariableName: string;
  53382. /**
  53383. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53384. * In this case the connection point name must be the name of the uniform to use.
  53385. * Can only be set on inputs
  53386. */
  53387. isUniform: boolean;
  53388. /**
  53389. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53390. * In this case the connection point name must be the name of the attribute to use
  53391. * Can only be set on inputs
  53392. */
  53393. isAttribute: boolean;
  53394. /**
  53395. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53396. * Can only be set on exit points
  53397. */
  53398. isVarying: boolean;
  53399. /** Get the other side of the connection (if any) */
  53400. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53401. /** Get the block that owns this connection point */
  53402. readonly ownerBlock: NodeMaterialBlock;
  53403. /** Get the block connected on the other side of this connection (if any) */
  53404. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53405. /** Get the block connected on the endpoints of this connection (if any) */
  53406. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53407. /**
  53408. * Creates a new connection point
  53409. * @param name defines the connection point name
  53410. * @param ownerBlock defines the block hosting this connection point
  53411. */
  53412. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53413. /**
  53414. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53415. * @returns the class name
  53416. */
  53417. getClassName(): string;
  53418. /**
  53419. * Set the source of this connection point to a vertex attribute
  53420. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53421. * @returns the current connection point
  53422. */
  53423. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53424. /**
  53425. * Set the source of this connection point to a well known value
  53426. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53427. * @returns the current connection point
  53428. */
  53429. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53430. /**
  53431. * Gets a boolean indicating that the current connection point is a well known value
  53432. */
  53433. readonly isWellKnownValue: boolean;
  53434. /**
  53435. * Gets or sets the current well known value or null if not defined as well know value
  53436. */
  53437. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53438. private _getTypeLength;
  53439. /**
  53440. * Connect this point to another connection point
  53441. * @param connectionPoint defines the other connection point
  53442. * @returns the current connection point
  53443. */
  53444. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53445. /**
  53446. * Disconnect this point from one of his endpoint
  53447. * @param endpoint defines the other connection point
  53448. * @returns the current connection point
  53449. */
  53450. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53451. /**
  53452. * When connection point is an uniform, this function will send its value to the effect
  53453. * @param effect defines the effect to transmit value to
  53454. * @param world defines the world matrix
  53455. * @param worldView defines the worldxview matrix
  53456. * @param worldViewProjection defines the worldxviewxprojection matrix
  53457. */
  53458. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53459. /**
  53460. * When connection point is an uniform, this function will send its value to the effect
  53461. * @param effect defines the effect to transmit value to
  53462. * @param scene defines the hosting scene
  53463. */
  53464. transmit(effect: Effect, scene: Scene): void;
  53465. }
  53466. }
  53467. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53471. import { Mesh } from "babylonjs/Meshes/mesh";
  53472. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53473. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53474. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53475. /**
  53476. * Block used to add support for vertex skinning (bones)
  53477. */
  53478. export class BonesBlock extends NodeMaterialBlock {
  53479. /**
  53480. * Creates a new BonesBlock
  53481. * @param name defines the block name
  53482. */
  53483. constructor(name: string);
  53484. /**
  53485. * Initialize the block and prepare the context for build
  53486. * @param state defines the state that will be used for the build
  53487. */
  53488. initialize(state: NodeMaterialBuildState): void;
  53489. /**
  53490. * Gets the current class name
  53491. * @returns the class name
  53492. */
  53493. getClassName(): string;
  53494. /**
  53495. * Gets the matrix indices input component
  53496. */
  53497. readonly matricesIndices: NodeMaterialConnectionPoint;
  53498. /**
  53499. * Gets the matrix weights input component
  53500. */
  53501. readonly matricesWeights: NodeMaterialConnectionPoint;
  53502. /**
  53503. * Gets the extra matrix indices input component
  53504. */
  53505. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53506. /**
  53507. * Gets the extra matrix weights input component
  53508. */
  53509. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53510. /**
  53511. * Gets the world input component
  53512. */
  53513. readonly world: NodeMaterialConnectionPoint;
  53514. autoConfigure(): void;
  53515. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53516. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53518. protected _buildBlock(state: NodeMaterialBuildState): this;
  53519. }
  53520. }
  53521. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53523. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53527. /**
  53528. * Block used to add support for instances
  53529. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53530. */
  53531. export class InstancesBlock extends NodeMaterialBlock {
  53532. /**
  53533. * Creates a new InstancesBlock
  53534. * @param name defines the block name
  53535. */
  53536. constructor(name: string);
  53537. /**
  53538. * Gets the current class name
  53539. * @returns the class name
  53540. */
  53541. getClassName(): string;
  53542. /**
  53543. * Gets the first world row input component
  53544. */
  53545. readonly world0: NodeMaterialConnectionPoint;
  53546. /**
  53547. * Gets the second world row input component
  53548. */
  53549. readonly world1: NodeMaterialConnectionPoint;
  53550. /**
  53551. * Gets the third world row input component
  53552. */
  53553. readonly world2: NodeMaterialConnectionPoint;
  53554. /**
  53555. * Gets the forth world row input component
  53556. */
  53557. readonly world3: NodeMaterialConnectionPoint;
  53558. /**
  53559. * Gets the world input component
  53560. */
  53561. readonly world: NodeMaterialConnectionPoint;
  53562. /**
  53563. * Gets the output component
  53564. */
  53565. readonly output: NodeMaterialConnectionPoint;
  53566. autoConfigure(): void;
  53567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53568. protected _buildBlock(state: NodeMaterialBuildState): this;
  53569. }
  53570. }
  53571. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53572. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53573. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53576. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53577. import { Effect } from "babylonjs/Materials/effect";
  53578. import { Mesh } from "babylonjs/Meshes/mesh";
  53579. /**
  53580. * Block used to add morph targets support to vertex shader
  53581. */
  53582. export class MorphTargetsBlock extends NodeMaterialBlock {
  53583. private _repeatableContentAnchor;
  53584. private _repeatebleContentGenerated;
  53585. /**
  53586. * Create a new MorphTargetsBlock
  53587. * @param name defines the block name
  53588. */
  53589. constructor(name: string);
  53590. /**
  53591. * Gets the current class name
  53592. * @returns the class name
  53593. */
  53594. getClassName(): string;
  53595. /**
  53596. * Gets the position input component
  53597. */
  53598. readonly position: NodeMaterialConnectionPoint;
  53599. /**
  53600. * Gets the normal input component
  53601. */
  53602. readonly normal: NodeMaterialConnectionPoint;
  53603. /**
  53604. * Gets the tangent input component
  53605. */
  53606. readonly tangent: NodeMaterialConnectionPoint;
  53607. /**
  53608. * Gets the position output component
  53609. */
  53610. readonly positionOutput: NodeMaterialConnectionPoint;
  53611. /**
  53612. * Gets the normal output component
  53613. */
  53614. readonly normalOutput: NodeMaterialConnectionPoint;
  53615. /**
  53616. * Gets the tangent output component
  53617. */
  53618. readonly tangentOutput: NodeMaterialConnectionPoint;
  53619. initialize(state: NodeMaterialBuildState): void;
  53620. autoConfigure(): void;
  53621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53623. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53624. protected _buildBlock(state: NodeMaterialBuildState): this;
  53625. }
  53626. }
  53627. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53628. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53629. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53630. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53631. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53632. }
  53633. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53634. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53635. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53636. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53637. /**
  53638. * Block used to add an alpha test in the fragment shader
  53639. */
  53640. export class AlphaTestBlock extends NodeMaterialBlock {
  53641. /**
  53642. * Gets or sets the alpha value where alpha testing happens
  53643. */
  53644. alphaCutOff: number;
  53645. /**
  53646. * Create a new AlphaTestBlock
  53647. * @param name defines the block name
  53648. */
  53649. constructor(name: string);
  53650. /**
  53651. * Gets the current class name
  53652. * @returns the class name
  53653. */
  53654. getClassName(): string;
  53655. /**
  53656. * Gets the color input component
  53657. */
  53658. readonly color: NodeMaterialConnectionPoint;
  53659. protected _buildBlock(state: NodeMaterialBuildState): this;
  53660. }
  53661. }
  53662. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  53663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53666. /**
  53667. * Block used to create a Color4 out of 4 inputs (one for each component)
  53668. */
  53669. export class RGBAMergerBlock extends NodeMaterialBlock {
  53670. /**
  53671. * Create a new RGBAMergerBlock
  53672. * @param name defines the block name
  53673. */
  53674. constructor(name: string);
  53675. /**
  53676. * Gets the current class name
  53677. * @returns the class name
  53678. */
  53679. getClassName(): string;
  53680. /**
  53681. * Gets the R input component
  53682. */
  53683. readonly r: NodeMaterialConnectionPoint;
  53684. /**
  53685. * Gets the G input component
  53686. */
  53687. readonly g: NodeMaterialConnectionPoint;
  53688. /**
  53689. * Gets the B input component
  53690. */
  53691. readonly b: NodeMaterialConnectionPoint;
  53692. /**
  53693. * Gets the RGB input component
  53694. */
  53695. readonly rgb: NodeMaterialConnectionPoint;
  53696. /**
  53697. * Gets the R input component
  53698. */
  53699. readonly a: NodeMaterialConnectionPoint;
  53700. protected _buildBlock(state: NodeMaterialBuildState): this;
  53701. }
  53702. }
  53703. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53707. /**
  53708. * Block used to create a Color3 out of 3 inputs (one for each component)
  53709. */
  53710. export class RGBMergerBlock extends NodeMaterialBlock {
  53711. /**
  53712. * Create a new RGBMergerBlock
  53713. * @param name defines the block name
  53714. */
  53715. constructor(name: string);
  53716. /**
  53717. * Gets the current class name
  53718. * @returns the class name
  53719. */
  53720. getClassName(): string;
  53721. /**
  53722. * Gets the R component input
  53723. */
  53724. readonly r: NodeMaterialConnectionPoint;
  53725. /**
  53726. * Gets the G component input
  53727. */
  53728. readonly g: NodeMaterialConnectionPoint;
  53729. /**
  53730. * Gets the B component input
  53731. */
  53732. readonly b: NodeMaterialConnectionPoint;
  53733. protected _buildBlock(state: NodeMaterialBuildState): this;
  53734. }
  53735. }
  53736. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53740. /**
  53741. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53742. */
  53743. export class RGBASplitterBlock extends NodeMaterialBlock {
  53744. /**
  53745. * Create a new RGBASplitterBlock
  53746. * @param name defines the block name
  53747. */
  53748. constructor(name: string);
  53749. /**
  53750. * Gets the current class name
  53751. * @returns the class name
  53752. */
  53753. getClassName(): string;
  53754. /**
  53755. * Gets the input component
  53756. */
  53757. readonly input: NodeMaterialConnectionPoint;
  53758. protected _buildBlock(state: NodeMaterialBuildState): this;
  53759. }
  53760. }
  53761. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53765. /**
  53766. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53767. */
  53768. export class RGBSplitterBlock extends NodeMaterialBlock {
  53769. /**
  53770. * Create a new RGBSplitterBlock
  53771. * @param name defines the block name
  53772. */
  53773. constructor(name: string);
  53774. /**
  53775. * Gets the current class name
  53776. * @returns the class name
  53777. */
  53778. getClassName(): string;
  53779. /**
  53780. * Gets the input component
  53781. */
  53782. readonly input: NodeMaterialConnectionPoint;
  53783. protected _buildBlock(state: NodeMaterialBuildState): this;
  53784. }
  53785. }
  53786. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53791. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53792. /**
  53793. * Block used to read a texture from a sampler
  53794. */
  53795. export class TextureBlock extends NodeMaterialBlock {
  53796. private _defineName;
  53797. /**
  53798. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53799. */
  53800. autoConnectTextureMatrix: boolean;
  53801. /**
  53802. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53803. */
  53804. autoSelectUV: boolean;
  53805. /**
  53806. * Create a new TextureBlock
  53807. * @param name defines the block name
  53808. */
  53809. constructor(name: string);
  53810. /**
  53811. * Gets the current class name
  53812. * @returns the class name
  53813. */
  53814. getClassName(): string;
  53815. /**
  53816. * Gets the uv input component
  53817. */
  53818. readonly uv: NodeMaterialConnectionPoint;
  53819. /**
  53820. * Gets the texture information input component
  53821. */
  53822. readonly textureInfo: NodeMaterialConnectionPoint;
  53823. /**
  53824. * Gets the transformed uv input component
  53825. */
  53826. readonly transformedUV: NodeMaterialConnectionPoint;
  53827. /**
  53828. * Gets the texture input component
  53829. */
  53830. readonly texture: NodeMaterialConnectionPoint;
  53831. /**
  53832. * Gets the texture transform input component
  53833. */
  53834. readonly textureTransform: NodeMaterialConnectionPoint;
  53835. autoConfigure(): void;
  53836. initialize(state: NodeMaterialBuildState): void;
  53837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53838. isReady(): boolean;
  53839. private _injectVertexCode;
  53840. protected _buildBlock(state: NodeMaterialBuildState): this;
  53841. }
  53842. }
  53843. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  53844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53848. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53849. import { Effect } from "babylonjs/Materials/effect";
  53850. import { Mesh } from "babylonjs/Meshes/mesh";
  53851. /**
  53852. * Block used to add image processing support to fragment shader
  53853. */
  53854. export class ImageProcessingBlock extends NodeMaterialBlock {
  53855. /**
  53856. * Create a new ImageProcessingBlock
  53857. * @param name defines the block name
  53858. */
  53859. constructor(name: string);
  53860. /**
  53861. * Gets the current class name
  53862. * @returns the class name
  53863. */
  53864. getClassName(): string;
  53865. /**
  53866. * Gets the color input component
  53867. */
  53868. readonly color: NodeMaterialConnectionPoint;
  53869. /**
  53870. * Initialize the block and prepare the context for build
  53871. * @param state defines the state that will be used for the build
  53872. */
  53873. initialize(state: NodeMaterialBuildState): void;
  53874. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53877. protected _buildBlock(state: NodeMaterialBuildState): this;
  53878. }
  53879. }
  53880. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  53881. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  53882. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  53883. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  53884. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  53885. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  53886. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  53887. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  53888. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  53889. }
  53890. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  53891. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53892. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53893. import { Mesh } from "babylonjs/Meshes/mesh";
  53894. import { Effect } from "babylonjs/Materials/effect";
  53895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53897. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53898. /**
  53899. * Block used to add support for scene fog
  53900. */
  53901. export class FogBlock extends NodeMaterialBlock {
  53902. /**
  53903. * Create a new FogBlock
  53904. * @param name defines the block name
  53905. */
  53906. constructor(name: string);
  53907. /**
  53908. * Gets the current class name
  53909. * @returns the class name
  53910. */
  53911. getClassName(): string;
  53912. /**
  53913. * Gets the world position input component
  53914. */
  53915. readonly worldPosition: NodeMaterialConnectionPoint;
  53916. /**
  53917. * Gets the view input component
  53918. */
  53919. readonly view: NodeMaterialConnectionPoint;
  53920. /**
  53921. * Gets the color input component
  53922. */
  53923. readonly color: NodeMaterialConnectionPoint;
  53924. /**
  53925. * Gets the fog color input component
  53926. */
  53927. readonly fogColor: NodeMaterialConnectionPoint;
  53928. /**
  53929. * Gets the for parameter input component
  53930. */
  53931. readonly fogParameters: NodeMaterialConnectionPoint;
  53932. autoConfigure(): void;
  53933. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53935. protected _buildBlock(state: NodeMaterialBuildState): this;
  53936. }
  53937. }
  53938. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  53939. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  53940. }
  53941. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  53942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53945. /**
  53946. * Block used to multiply 2 vector4
  53947. */
  53948. export class MultiplyBlock extends NodeMaterialBlock {
  53949. /**
  53950. * Creates a new MultiplyBlock
  53951. * @param name defines the block name
  53952. */
  53953. constructor(name: string);
  53954. /**
  53955. * Gets the current class name
  53956. * @returns the class name
  53957. */
  53958. getClassName(): string;
  53959. /**
  53960. * Gets the left operand input component
  53961. */
  53962. readonly left: NodeMaterialConnectionPoint;
  53963. /**
  53964. * Gets the right operand input component
  53965. */
  53966. readonly right: NodeMaterialConnectionPoint;
  53967. protected _buildBlock(state: NodeMaterialBuildState): this;
  53968. }
  53969. }
  53970. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  53971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53974. /**
  53975. * Block used to add 2 vector4
  53976. */
  53977. export class AddBlock extends NodeMaterialBlock {
  53978. /**
  53979. * Creates a new AddBlock
  53980. * @param name defines the block name
  53981. */
  53982. constructor(name: string);
  53983. /**
  53984. * Gets the current class name
  53985. * @returns the class name
  53986. */
  53987. getClassName(): string;
  53988. /**
  53989. * Gets the left operand input component
  53990. */
  53991. readonly left: NodeMaterialConnectionPoint;
  53992. /**
  53993. * Gets the right operand input component
  53994. */
  53995. readonly right: NodeMaterialConnectionPoint;
  53996. protected _buildBlock(state: NodeMaterialBuildState): this;
  53997. }
  53998. }
  53999. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54003. /**
  54004. * Block used to clamp a float
  54005. */
  54006. export class ClampBlock extends NodeMaterialBlock {
  54007. /** Gets or sets the minimum range */
  54008. minimum: number;
  54009. /** Gets or sets the maximum range */
  54010. maximum: number;
  54011. /**
  54012. * Creates a new ClampBlock
  54013. * @param name defines the block name
  54014. */
  54015. constructor(name: string);
  54016. /**
  54017. * Gets the current class name
  54018. * @returns the class name
  54019. */
  54020. getClassName(): string;
  54021. /**
  54022. * Gets the value input component
  54023. */
  54024. readonly value: NodeMaterialConnectionPoint;
  54025. protected _buildBlock(state: NodeMaterialBuildState): this;
  54026. }
  54027. }
  54028. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54032. /**
  54033. * Block used to transform a vector2 with a matrix
  54034. */
  54035. export class Vector2TransformBlock extends NodeMaterialBlock {
  54036. /**
  54037. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54038. */
  54039. complementZ: number;
  54040. /**
  54041. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54042. */
  54043. complementW: number;
  54044. /**
  54045. * Creates a new Vector2TransformBlock
  54046. * @param name defines the block name
  54047. */
  54048. constructor(name: string);
  54049. /**
  54050. * Gets the vector input
  54051. */
  54052. readonly vector: NodeMaterialConnectionPoint;
  54053. /**
  54054. * Gets the matrix transform input
  54055. */
  54056. readonly transform: NodeMaterialConnectionPoint;
  54057. /**
  54058. * Gets the current class name
  54059. * @returns the class name
  54060. */
  54061. getClassName(): string;
  54062. protected _buildBlock(state: NodeMaterialBuildState): this;
  54063. }
  54064. }
  54065. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54069. /**
  54070. * Block used to transform a vector3 with a matrix
  54071. */
  54072. export class Vector3TransformBlock extends NodeMaterialBlock {
  54073. /**
  54074. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54075. */
  54076. complement: number;
  54077. /**
  54078. * Creates a new Vector3TransformBlock
  54079. * @param name defines the block name
  54080. */
  54081. constructor(name: string);
  54082. /**
  54083. * Gets the vector input
  54084. */
  54085. readonly vector: NodeMaterialConnectionPoint;
  54086. /**
  54087. * Gets the matrix transform input
  54088. */
  54089. readonly transform: NodeMaterialConnectionPoint;
  54090. /**
  54091. * Gets the current class name
  54092. * @returns the class name
  54093. */
  54094. getClassName(): string;
  54095. protected _buildBlock(state: NodeMaterialBuildState): this;
  54096. }
  54097. }
  54098. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  54099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54102. /**
  54103. * Block used to multiply two matrices
  54104. */
  54105. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  54106. /**
  54107. * Creates a new MatrixMultiplicationBlock
  54108. * @param name defines the block name
  54109. */
  54110. constructor(name: string);
  54111. /**
  54112. * Gets the left operand
  54113. */
  54114. readonly left: NodeMaterialConnectionPoint;
  54115. /**
  54116. * Gets the right operand
  54117. */
  54118. readonly right: NodeMaterialConnectionPoint;
  54119. /**
  54120. * Gets the current class name
  54121. * @returns the class name
  54122. */
  54123. getClassName(): string;
  54124. protected _buildBlock(state: NodeMaterialBuildState): this;
  54125. }
  54126. }
  54127. declare module "babylonjs/Materials/Node/Blocks/index" {
  54128. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54129. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54130. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54131. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54132. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54133. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54134. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54135. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54136. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54137. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  54138. }
  54139. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54140. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54141. }
  54142. declare module "babylonjs/Materials/Node/index" {
  54143. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54144. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54145. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54146. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54147. export * from "babylonjs/Materials/Node/nodeMaterial";
  54148. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54149. export * from "babylonjs/Materials/Node/Blocks/index";
  54150. export * from "babylonjs/Materials/Node/Optimizers/index";
  54151. }
  54152. declare module "babylonjs/Materials/index" {
  54153. export * from "babylonjs/Materials/Background/index";
  54154. export * from "babylonjs/Materials/colorCurves";
  54155. export * from "babylonjs/Materials/effect";
  54156. export * from "babylonjs/Materials/fresnelParameters";
  54157. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54158. export * from "babylonjs/Materials/material";
  54159. export * from "babylonjs/Materials/materialDefines";
  54160. export * from "babylonjs/Materials/materialHelper";
  54161. export * from "babylonjs/Materials/multiMaterial";
  54162. export * from "babylonjs/Materials/PBR/index";
  54163. export * from "babylonjs/Materials/pushMaterial";
  54164. export * from "babylonjs/Materials/shaderMaterial";
  54165. export * from "babylonjs/Materials/standardMaterial";
  54166. export * from "babylonjs/Materials/Textures/index";
  54167. export * from "babylonjs/Materials/uniformBuffer";
  54168. export * from "babylonjs/Materials/materialFlags";
  54169. export * from "babylonjs/Materials/Node/index";
  54170. }
  54171. declare module "babylonjs/Maths/index" {
  54172. export * from "babylonjs/Maths/math.scalar";
  54173. export * from "babylonjs/Maths/math";
  54174. export * from "babylonjs/Maths/sphericalPolynomial";
  54175. }
  54176. declare module "babylonjs/Misc/workerPool" {
  54177. import { IDisposable } from "babylonjs/scene";
  54178. /**
  54179. * Helper class to push actions to a pool of workers.
  54180. */
  54181. export class WorkerPool implements IDisposable {
  54182. private _workerInfos;
  54183. private _pendingActions;
  54184. /**
  54185. * Constructor
  54186. * @param workers Array of workers to use for actions
  54187. */
  54188. constructor(workers: Array<Worker>);
  54189. /**
  54190. * Terminates all workers and clears any pending actions.
  54191. */
  54192. dispose(): void;
  54193. /**
  54194. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54195. * pended until a worker has completed its action.
  54196. * @param action The action to perform. Call onComplete when the action is complete.
  54197. */
  54198. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54199. private _execute;
  54200. }
  54201. }
  54202. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54203. import { IDisposable } from "babylonjs/scene";
  54204. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54205. /**
  54206. * Configuration for Draco compression
  54207. */
  54208. export interface IDracoCompressionConfiguration {
  54209. /**
  54210. * Configuration for the decoder.
  54211. */
  54212. decoder: {
  54213. /**
  54214. * The url to the WebAssembly module.
  54215. */
  54216. wasmUrl?: string;
  54217. /**
  54218. * The url to the WebAssembly binary.
  54219. */
  54220. wasmBinaryUrl?: string;
  54221. /**
  54222. * The url to the fallback JavaScript module.
  54223. */
  54224. fallbackUrl?: string;
  54225. };
  54226. }
  54227. /**
  54228. * Draco compression (https://google.github.io/draco/)
  54229. *
  54230. * This class wraps the Draco module.
  54231. *
  54232. * **Encoder**
  54233. *
  54234. * The encoder is not currently implemented.
  54235. *
  54236. * **Decoder**
  54237. *
  54238. * 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.
  54239. *
  54240. * To update the configuration, use the following code:
  54241. * ```javascript
  54242. * DracoCompression.Configuration = {
  54243. * decoder: {
  54244. * wasmUrl: "<url to the WebAssembly library>",
  54245. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54246. * fallbackUrl: "<url to the fallback JavaScript library>",
  54247. * }
  54248. * };
  54249. * ```
  54250. *
  54251. * 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.
  54252. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54253. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54254. *
  54255. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54256. * ```javascript
  54257. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54258. * ```
  54259. *
  54260. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54261. */
  54262. export class DracoCompression implements IDisposable {
  54263. private _workerPoolPromise?;
  54264. private _decoderModulePromise?;
  54265. /**
  54266. * The configuration. Defaults to the following urls:
  54267. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54268. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54269. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54270. */
  54271. static Configuration: IDracoCompressionConfiguration;
  54272. /**
  54273. * Returns true if the decoder configuration is available.
  54274. */
  54275. static readonly DecoderAvailable: boolean;
  54276. /**
  54277. * Default number of workers to create when creating the draco compression object.
  54278. */
  54279. static DefaultNumWorkers: number;
  54280. private static GetDefaultNumWorkers;
  54281. private static _Default;
  54282. /**
  54283. * Default instance for the draco compression object.
  54284. */
  54285. static readonly Default: DracoCompression;
  54286. /**
  54287. * Constructor
  54288. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54289. */
  54290. constructor(numWorkers?: number);
  54291. /**
  54292. * Stop all async operations and release resources.
  54293. */
  54294. dispose(): void;
  54295. /**
  54296. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54297. * @returns a promise that resolves when ready
  54298. */
  54299. whenReadyAsync(): Promise<void>;
  54300. /**
  54301. * Decode Draco compressed mesh data to vertex data.
  54302. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54303. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54304. * @returns A promise that resolves with the decoded vertex data
  54305. */
  54306. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54307. [kind: string]: number;
  54308. }): Promise<VertexData>;
  54309. }
  54310. }
  54311. declare module "babylonjs/Meshes/Compression/index" {
  54312. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54313. }
  54314. declare module "babylonjs/Meshes/csg" {
  54315. import { Nullable } from "babylonjs/types";
  54316. import { Scene } from "babylonjs/scene";
  54317. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54318. import { Mesh } from "babylonjs/Meshes/mesh";
  54319. import { Material } from "babylonjs/Materials/material";
  54320. /**
  54321. * Class for building Constructive Solid Geometry
  54322. */
  54323. export class CSG {
  54324. private polygons;
  54325. /**
  54326. * The world matrix
  54327. */
  54328. matrix: Matrix;
  54329. /**
  54330. * Stores the position
  54331. */
  54332. position: Vector3;
  54333. /**
  54334. * Stores the rotation
  54335. */
  54336. rotation: Vector3;
  54337. /**
  54338. * Stores the rotation quaternion
  54339. */
  54340. rotationQuaternion: Nullable<Quaternion>;
  54341. /**
  54342. * Stores the scaling vector
  54343. */
  54344. scaling: Vector3;
  54345. /**
  54346. * Convert the Mesh to CSG
  54347. * @param mesh The Mesh to convert to CSG
  54348. * @returns A new CSG from the Mesh
  54349. */
  54350. static FromMesh(mesh: Mesh): CSG;
  54351. /**
  54352. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54353. * @param polygons Polygons used to construct a CSG solid
  54354. */
  54355. private static FromPolygons;
  54356. /**
  54357. * Clones, or makes a deep copy, of the CSG
  54358. * @returns A new CSG
  54359. */
  54360. clone(): CSG;
  54361. /**
  54362. * Unions this CSG with another CSG
  54363. * @param csg The CSG to union against this CSG
  54364. * @returns The unioned CSG
  54365. */
  54366. union(csg: CSG): CSG;
  54367. /**
  54368. * Unions this CSG with another CSG in place
  54369. * @param csg The CSG to union against this CSG
  54370. */
  54371. unionInPlace(csg: CSG): void;
  54372. /**
  54373. * Subtracts this CSG with another CSG
  54374. * @param csg The CSG to subtract against this CSG
  54375. * @returns A new CSG
  54376. */
  54377. subtract(csg: CSG): CSG;
  54378. /**
  54379. * Subtracts this CSG with another CSG in place
  54380. * @param csg The CSG to subtact against this CSG
  54381. */
  54382. subtractInPlace(csg: CSG): void;
  54383. /**
  54384. * Intersect this CSG with another CSG
  54385. * @param csg The CSG to intersect against this CSG
  54386. * @returns A new CSG
  54387. */
  54388. intersect(csg: CSG): CSG;
  54389. /**
  54390. * Intersects this CSG with another CSG in place
  54391. * @param csg The CSG to intersect against this CSG
  54392. */
  54393. intersectInPlace(csg: CSG): void;
  54394. /**
  54395. * Return a new CSG solid with solid and empty space switched. This solid is
  54396. * not modified.
  54397. * @returns A new CSG solid with solid and empty space switched
  54398. */
  54399. inverse(): CSG;
  54400. /**
  54401. * Inverses the CSG in place
  54402. */
  54403. inverseInPlace(): void;
  54404. /**
  54405. * This is used to keep meshes transformations so they can be restored
  54406. * when we build back a Babylon Mesh
  54407. * NB : All CSG operations are performed in world coordinates
  54408. * @param csg The CSG to copy the transform attributes from
  54409. * @returns This CSG
  54410. */
  54411. copyTransformAttributes(csg: CSG): CSG;
  54412. /**
  54413. * Build Raw mesh from CSG
  54414. * Coordinates here are in world space
  54415. * @param name The name of the mesh geometry
  54416. * @param scene The Scene
  54417. * @param keepSubMeshes Specifies if the submeshes should be kept
  54418. * @returns A new Mesh
  54419. */
  54420. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54421. /**
  54422. * Build Mesh from CSG taking material and transforms into account
  54423. * @param name The name of the Mesh
  54424. * @param material The material of the Mesh
  54425. * @param scene The Scene
  54426. * @param keepSubMeshes Specifies if submeshes should be kept
  54427. * @returns The new Mesh
  54428. */
  54429. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54430. }
  54431. }
  54432. declare module "babylonjs/Meshes/trailMesh" {
  54433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54434. import { Mesh } from "babylonjs/Meshes/mesh";
  54435. import { Scene } from "babylonjs/scene";
  54436. /**
  54437. * Class used to create a trail following a mesh
  54438. */
  54439. export class TrailMesh extends Mesh {
  54440. private _generator;
  54441. private _autoStart;
  54442. private _running;
  54443. private _diameter;
  54444. private _length;
  54445. private _sectionPolygonPointsCount;
  54446. private _sectionVectors;
  54447. private _sectionNormalVectors;
  54448. private _beforeRenderObserver;
  54449. /**
  54450. * @constructor
  54451. * @param name The value used by scene.getMeshByName() to do a lookup.
  54452. * @param generator The mesh to generate a trail.
  54453. * @param scene The scene to add this mesh to.
  54454. * @param diameter Diameter of trailing mesh. Default is 1.
  54455. * @param length Length of trailing mesh. Default is 60.
  54456. * @param autoStart Automatically start trailing mesh. Default true.
  54457. */
  54458. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54459. /**
  54460. * "TrailMesh"
  54461. * @returns "TrailMesh"
  54462. */
  54463. getClassName(): string;
  54464. private _createMesh;
  54465. /**
  54466. * Start trailing mesh.
  54467. */
  54468. start(): void;
  54469. /**
  54470. * Stop trailing mesh.
  54471. */
  54472. stop(): void;
  54473. /**
  54474. * Update trailing mesh geometry.
  54475. */
  54476. update(): void;
  54477. /**
  54478. * Returns a new TrailMesh object.
  54479. * @param name is a string, the name given to the new mesh
  54480. * @param newGenerator use new generator object for cloned trail mesh
  54481. * @returns a new mesh
  54482. */
  54483. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54484. /**
  54485. * Serializes this trail mesh
  54486. * @param serializationObject object to write serialization to
  54487. */
  54488. serialize(serializationObject: any): void;
  54489. /**
  54490. * Parses a serialized trail mesh
  54491. * @param parsedMesh the serialized mesh
  54492. * @param scene the scene to create the trail mesh in
  54493. * @returns the created trail mesh
  54494. */
  54495. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54496. }
  54497. }
  54498. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54499. import { Nullable } from "babylonjs/types";
  54500. import { Scene } from "babylonjs/scene";
  54501. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54502. import { Mesh } from "babylonjs/Meshes/mesh";
  54503. /**
  54504. * Class containing static functions to help procedurally build meshes
  54505. */
  54506. export class TiledBoxBuilder {
  54507. /**
  54508. * Creates a box mesh
  54509. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  54510. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54514. * @param name defines the name of the mesh
  54515. * @param options defines the options used to create the mesh
  54516. * @param scene defines the hosting scene
  54517. * @returns the box mesh
  54518. */
  54519. static CreateTiledBox(name: string, options: {
  54520. pattern?: number;
  54521. width?: number;
  54522. height?: number;
  54523. depth?: number;
  54524. tileSize?: number;
  54525. tileWidth?: number;
  54526. tileHeight?: number;
  54527. alignHorizontal?: number;
  54528. alignVertical?: number;
  54529. faceUV?: Vector4[];
  54530. faceColors?: Color4[];
  54531. sideOrientation?: number;
  54532. updatable?: boolean;
  54533. }, scene?: Nullable<Scene>): Mesh;
  54534. }
  54535. }
  54536. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54537. import { Vector4 } from "babylonjs/Maths/math";
  54538. import { Mesh } from "babylonjs/Meshes/mesh";
  54539. /**
  54540. * Class containing static functions to help procedurally build meshes
  54541. */
  54542. export class TorusKnotBuilder {
  54543. /**
  54544. * Creates a torus knot mesh
  54545. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54546. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54547. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54548. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54552. * @param name defines the name of the mesh
  54553. * @param options defines the options used to create the mesh
  54554. * @param scene defines the hosting scene
  54555. * @returns the torus knot mesh
  54556. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54557. */
  54558. static CreateTorusKnot(name: string, options: {
  54559. radius?: number;
  54560. tube?: number;
  54561. radialSegments?: number;
  54562. tubularSegments?: number;
  54563. p?: number;
  54564. q?: number;
  54565. updatable?: boolean;
  54566. sideOrientation?: number;
  54567. frontUVs?: Vector4;
  54568. backUVs?: Vector4;
  54569. }, scene: any): Mesh;
  54570. }
  54571. }
  54572. declare module "babylonjs/Meshes/polygonMesh" {
  54573. import { Scene } from "babylonjs/scene";
  54574. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54575. import { Mesh } from "babylonjs/Meshes/mesh";
  54576. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54577. /**
  54578. * Polygon
  54579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54580. */
  54581. export class Polygon {
  54582. /**
  54583. * Creates a rectangle
  54584. * @param xmin bottom X coord
  54585. * @param ymin bottom Y coord
  54586. * @param xmax top X coord
  54587. * @param ymax top Y coord
  54588. * @returns points that make the resulting rectation
  54589. */
  54590. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54591. /**
  54592. * Creates a circle
  54593. * @param radius radius of circle
  54594. * @param cx scale in x
  54595. * @param cy scale in y
  54596. * @param numberOfSides number of sides that make up the circle
  54597. * @returns points that make the resulting circle
  54598. */
  54599. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54600. /**
  54601. * Creates a polygon from input string
  54602. * @param input Input polygon data
  54603. * @returns the parsed points
  54604. */
  54605. static Parse(input: string): Vector2[];
  54606. /**
  54607. * Starts building a polygon from x and y coordinates
  54608. * @param x x coordinate
  54609. * @param y y coordinate
  54610. * @returns the started path2
  54611. */
  54612. static StartingAt(x: number, y: number): Path2;
  54613. }
  54614. /**
  54615. * Builds a polygon
  54616. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54617. */
  54618. export class PolygonMeshBuilder {
  54619. private _points;
  54620. private _outlinepoints;
  54621. private _holes;
  54622. private _name;
  54623. private _scene;
  54624. private _epoints;
  54625. private _eholes;
  54626. private _addToepoint;
  54627. /**
  54628. * Babylon reference to the earcut plugin.
  54629. */
  54630. bjsEarcut: any;
  54631. /**
  54632. * Creates a PolygonMeshBuilder
  54633. * @param name name of the builder
  54634. * @param contours Path of the polygon
  54635. * @param scene scene to add to when creating the mesh
  54636. * @param earcutInjection can be used to inject your own earcut reference
  54637. */
  54638. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54639. /**
  54640. * Adds a whole within the polygon
  54641. * @param hole Array of points defining the hole
  54642. * @returns this
  54643. */
  54644. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54645. /**
  54646. * Creates the polygon
  54647. * @param updatable If the mesh should be updatable
  54648. * @param depth The depth of the mesh created
  54649. * @returns the created mesh
  54650. */
  54651. build(updatable?: boolean, depth?: number): Mesh;
  54652. /**
  54653. * Creates the polygon
  54654. * @param depth The depth of the mesh created
  54655. * @returns the created VertexData
  54656. */
  54657. buildVertexData(depth?: number): VertexData;
  54658. /**
  54659. * Adds a side to the polygon
  54660. * @param positions points that make the polygon
  54661. * @param normals normals of the polygon
  54662. * @param uvs uvs of the polygon
  54663. * @param indices indices of the polygon
  54664. * @param bounds bounds of the polygon
  54665. * @param points points of the polygon
  54666. * @param depth depth of the polygon
  54667. * @param flip flip of the polygon
  54668. */
  54669. private addSide;
  54670. }
  54671. }
  54672. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54673. import { Scene } from "babylonjs/scene";
  54674. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54675. import { Mesh } from "babylonjs/Meshes/mesh";
  54676. import { Nullable } from "babylonjs/types";
  54677. /**
  54678. * Class containing static functions to help procedurally build meshes
  54679. */
  54680. export class PolygonBuilder {
  54681. /**
  54682. * Creates a polygon mesh
  54683. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54684. * * 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
  54685. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54688. * * Remember you can only change the shape positions, not their number when updating a polygon
  54689. * @param name defines the name of the mesh
  54690. * @param options defines the options used to create the mesh
  54691. * @param scene defines the hosting scene
  54692. * @param earcutInjection can be used to inject your own earcut reference
  54693. * @returns the polygon mesh
  54694. */
  54695. static CreatePolygon(name: string, options: {
  54696. shape: Vector3[];
  54697. holes?: Vector3[][];
  54698. depth?: number;
  54699. faceUV?: Vector4[];
  54700. faceColors?: Color4[];
  54701. updatable?: boolean;
  54702. sideOrientation?: number;
  54703. frontUVs?: Vector4;
  54704. backUVs?: Vector4;
  54705. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54706. /**
  54707. * Creates an extruded polygon mesh, with depth in the Y direction.
  54708. * * 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)
  54709. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54710. * @param name defines the name of the mesh
  54711. * @param options defines the options used to create the mesh
  54712. * @param scene defines the hosting scene
  54713. * @param earcutInjection can be used to inject your own earcut reference
  54714. * @returns the polygon mesh
  54715. */
  54716. static ExtrudePolygon(name: string, options: {
  54717. shape: Vector3[];
  54718. holes?: Vector3[][];
  54719. depth?: number;
  54720. faceUV?: Vector4[];
  54721. faceColors?: Color4[];
  54722. updatable?: boolean;
  54723. sideOrientation?: number;
  54724. frontUVs?: Vector4;
  54725. backUVs?: Vector4;
  54726. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54727. }
  54728. }
  54729. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54730. import { Scene } from "babylonjs/scene";
  54731. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54732. import { Mesh } from "babylonjs/Meshes/mesh";
  54733. import { Nullable } from "babylonjs/types";
  54734. /**
  54735. * Class containing static functions to help procedurally build meshes
  54736. */
  54737. export class LatheBuilder {
  54738. /**
  54739. * Creates lathe mesh.
  54740. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54741. * * 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
  54742. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54743. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54744. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54745. * * 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
  54746. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54747. * * 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
  54748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54752. * @param name defines the name of the mesh
  54753. * @param options defines the options used to create the mesh
  54754. * @param scene defines the hosting scene
  54755. * @returns the lathe mesh
  54756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54757. */
  54758. static CreateLathe(name: string, options: {
  54759. shape: Vector3[];
  54760. radius?: number;
  54761. tessellation?: number;
  54762. clip?: number;
  54763. arc?: number;
  54764. closed?: boolean;
  54765. updatable?: boolean;
  54766. sideOrientation?: number;
  54767. frontUVs?: Vector4;
  54768. backUVs?: Vector4;
  54769. cap?: number;
  54770. invertUV?: boolean;
  54771. }, scene?: Nullable<Scene>): Mesh;
  54772. }
  54773. }
  54774. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54775. import { Nullable } from "babylonjs/types";
  54776. import { Scene } from "babylonjs/scene";
  54777. import { Vector4 } from "babylonjs/Maths/math";
  54778. import { Mesh } from "babylonjs/Meshes/mesh";
  54779. /**
  54780. * Class containing static functions to help procedurally build meshes
  54781. */
  54782. export class TiledPlaneBuilder {
  54783. /**
  54784. * Creates a tiled plane mesh
  54785. * * The parameter `pattern` will, depending on value, do nothing or
  54786. * * * flip (reflect about central vertical) alternate tiles across and up
  54787. * * * flip every tile on alternate rows
  54788. * * * rotate (180 degs) alternate tiles across and up
  54789. * * * rotate every tile on alternate rows
  54790. * * * flip and rotate alternate tiles across and up
  54791. * * * flip and rotate every tile on alternate rows
  54792. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54793. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54796. * * 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)
  54797. * * 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)
  54798. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54799. * @param name defines the name of the mesh
  54800. * @param options defines the options used to create the mesh
  54801. * @param scene defines the hosting scene
  54802. * @returns the box mesh
  54803. */
  54804. static CreateTiledPlane(name: string, options: {
  54805. pattern?: number;
  54806. tileSize?: number;
  54807. tileWidth?: number;
  54808. tileHeight?: number;
  54809. size?: number;
  54810. width?: number;
  54811. height?: number;
  54812. alignHorizontal?: number;
  54813. alignVertical?: number;
  54814. sideOrientation?: number;
  54815. frontUVs?: Vector4;
  54816. backUVs?: Vector4;
  54817. updatable?: boolean;
  54818. }, scene?: Nullable<Scene>): Mesh;
  54819. }
  54820. }
  54821. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54822. import { Nullable } from "babylonjs/types";
  54823. import { Scene } from "babylonjs/scene";
  54824. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54825. import { Mesh } from "babylonjs/Meshes/mesh";
  54826. /**
  54827. * Class containing static functions to help procedurally build meshes
  54828. */
  54829. export class TubeBuilder {
  54830. /**
  54831. * Creates a tube mesh.
  54832. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54833. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54834. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54835. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54836. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54837. * * 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)
  54838. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54839. * * 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
  54840. * * 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
  54841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54845. * @param name defines the name of the mesh
  54846. * @param options defines the options used to create the mesh
  54847. * @param scene defines the hosting scene
  54848. * @returns the tube mesh
  54849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54850. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54851. */
  54852. static CreateTube(name: string, options: {
  54853. path: Vector3[];
  54854. radius?: number;
  54855. tessellation?: number;
  54856. radiusFunction?: {
  54857. (i: number, distance: number): number;
  54858. };
  54859. cap?: number;
  54860. arc?: number;
  54861. updatable?: boolean;
  54862. sideOrientation?: number;
  54863. frontUVs?: Vector4;
  54864. backUVs?: Vector4;
  54865. instance?: Mesh;
  54866. invertUV?: boolean;
  54867. }, scene?: Nullable<Scene>): Mesh;
  54868. }
  54869. }
  54870. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  54871. import { Scene } from "babylonjs/scene";
  54872. import { Vector4 } from "babylonjs/Maths/math";
  54873. import { Mesh } from "babylonjs/Meshes/mesh";
  54874. import { Nullable } from "babylonjs/types";
  54875. /**
  54876. * Class containing static functions to help procedurally build meshes
  54877. */
  54878. export class IcoSphereBuilder {
  54879. /**
  54880. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54881. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54882. * * 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`)
  54883. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54884. * * 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
  54885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54888. * @param name defines the name of the mesh
  54889. * @param options defines the options used to create the mesh
  54890. * @param scene defines the hosting scene
  54891. * @returns the icosahedron mesh
  54892. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54893. */
  54894. static CreateIcoSphere(name: string, options: {
  54895. radius?: number;
  54896. radiusX?: number;
  54897. radiusY?: number;
  54898. radiusZ?: number;
  54899. flat?: boolean;
  54900. subdivisions?: number;
  54901. sideOrientation?: number;
  54902. frontUVs?: Vector4;
  54903. backUVs?: Vector4;
  54904. updatable?: boolean;
  54905. }, scene?: Nullable<Scene>): Mesh;
  54906. }
  54907. }
  54908. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  54909. import { Vector3 } from "babylonjs/Maths/math";
  54910. import { Mesh } from "babylonjs/Meshes/mesh";
  54911. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54912. /**
  54913. * Class containing static functions to help procedurally build meshes
  54914. */
  54915. export class DecalBuilder {
  54916. /**
  54917. * Creates a decal mesh.
  54918. * 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
  54919. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54920. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54921. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54922. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54923. * @param name defines the name of the mesh
  54924. * @param sourceMesh defines the mesh where the decal must be applied
  54925. * @param options defines the options used to create the mesh
  54926. * @param scene defines the hosting scene
  54927. * @returns the decal mesh
  54928. * @see https://doc.babylonjs.com/how_to/decals
  54929. */
  54930. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54931. position?: Vector3;
  54932. normal?: Vector3;
  54933. size?: Vector3;
  54934. angle?: number;
  54935. }): Mesh;
  54936. }
  54937. }
  54938. declare module "babylonjs/Meshes/meshBuilder" {
  54939. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  54940. import { Nullable } from "babylonjs/types";
  54941. import { Scene } from "babylonjs/scene";
  54942. import { Mesh } from "babylonjs/Meshes/mesh";
  54943. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54944. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  54945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54946. /**
  54947. * Class containing static functions to help procedurally build meshes
  54948. */
  54949. export class MeshBuilder {
  54950. /**
  54951. * Creates a box mesh
  54952. * * The parameter `size` sets the size (float) of each box side (default 1)
  54953. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54954. * * 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)
  54955. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54957. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54959. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54960. * @param name defines the name of the mesh
  54961. * @param options defines the options used to create the mesh
  54962. * @param scene defines the hosting scene
  54963. * @returns the box mesh
  54964. */
  54965. static CreateBox(name: string, options: {
  54966. size?: number;
  54967. width?: number;
  54968. height?: number;
  54969. depth?: number;
  54970. faceUV?: Vector4[];
  54971. faceColors?: Color4[];
  54972. sideOrientation?: number;
  54973. frontUVs?: Vector4;
  54974. backUVs?: Vector4;
  54975. updatable?: boolean;
  54976. }, scene?: Nullable<Scene>): Mesh;
  54977. /**
  54978. * Creates a tiled box mesh
  54979. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54981. * @param name defines the name of the mesh
  54982. * @param options defines the options used to create the mesh
  54983. * @param scene defines the hosting scene
  54984. * @returns the tiled box mesh
  54985. */
  54986. static CreateTiledBox(name: string, options: {
  54987. pattern?: number;
  54988. size?: number;
  54989. width?: number;
  54990. height?: number;
  54991. depth: number;
  54992. tileSize?: number;
  54993. tileWidth?: number;
  54994. tileHeight?: number;
  54995. faceUV?: Vector4[];
  54996. faceColors?: Color4[];
  54997. alignHorizontal?: number;
  54998. alignVertical?: number;
  54999. sideOrientation?: number;
  55000. updatable?: boolean;
  55001. }, scene?: Nullable<Scene>): Mesh;
  55002. /**
  55003. * Creates a sphere mesh
  55004. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55005. * * 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`)
  55006. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55007. * * 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
  55008. * * 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)
  55009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55012. * @param name defines the name of the mesh
  55013. * @param options defines the options used to create the mesh
  55014. * @param scene defines the hosting scene
  55015. * @returns the sphere mesh
  55016. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55017. */
  55018. static CreateSphere(name: string, options: {
  55019. segments?: number;
  55020. diameter?: number;
  55021. diameterX?: number;
  55022. diameterY?: number;
  55023. diameterZ?: number;
  55024. arc?: number;
  55025. slice?: number;
  55026. sideOrientation?: number;
  55027. frontUVs?: Vector4;
  55028. backUVs?: Vector4;
  55029. updatable?: boolean;
  55030. }, scene?: Nullable<Scene>): Mesh;
  55031. /**
  55032. * Creates a plane polygonal mesh. By default, this is a disc
  55033. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55034. * * 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
  55035. * * 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
  55036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55039. * @param name defines the name of the mesh
  55040. * @param options defines the options used to create the mesh
  55041. * @param scene defines the hosting scene
  55042. * @returns the plane polygonal mesh
  55043. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55044. */
  55045. static CreateDisc(name: string, options: {
  55046. radius?: number;
  55047. tessellation?: number;
  55048. arc?: number;
  55049. updatable?: boolean;
  55050. sideOrientation?: number;
  55051. frontUVs?: Vector4;
  55052. backUVs?: Vector4;
  55053. }, scene?: Nullable<Scene>): Mesh;
  55054. /**
  55055. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55056. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55057. * * 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`)
  55058. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55059. * * 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
  55060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55061. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55063. * @param name defines the name of the mesh
  55064. * @param options defines the options used to create the mesh
  55065. * @param scene defines the hosting scene
  55066. * @returns the icosahedron mesh
  55067. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55068. */
  55069. static CreateIcoSphere(name: string, options: {
  55070. radius?: number;
  55071. radiusX?: number;
  55072. radiusY?: number;
  55073. radiusZ?: number;
  55074. flat?: boolean;
  55075. subdivisions?: number;
  55076. sideOrientation?: number;
  55077. frontUVs?: Vector4;
  55078. backUVs?: Vector4;
  55079. updatable?: boolean;
  55080. }, scene?: Nullable<Scene>): Mesh;
  55081. /**
  55082. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55083. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55084. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55085. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55086. * * 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
  55087. * * 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
  55088. * * 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
  55089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55092. * * 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
  55093. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55094. * * 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
  55095. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55097. * @param name defines the name of the mesh
  55098. * @param options defines the options used to create the mesh
  55099. * @param scene defines the hosting scene
  55100. * @returns the ribbon mesh
  55101. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55102. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55103. */
  55104. static CreateRibbon(name: string, options: {
  55105. pathArray: Vector3[][];
  55106. closeArray?: boolean;
  55107. closePath?: boolean;
  55108. offset?: number;
  55109. updatable?: boolean;
  55110. sideOrientation?: number;
  55111. frontUVs?: Vector4;
  55112. backUVs?: Vector4;
  55113. instance?: Mesh;
  55114. invertUV?: boolean;
  55115. uvs?: Vector2[];
  55116. colors?: Color4[];
  55117. }, scene?: Nullable<Scene>): Mesh;
  55118. /**
  55119. * Creates a cylinder or a cone mesh
  55120. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55121. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55122. * * 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.
  55123. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55124. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55125. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55126. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55127. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55128. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55129. * * 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).
  55130. * * 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
  55131. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55132. * * 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
  55133. * * 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.
  55134. * * If `enclose` is false, a ring surface is one element.
  55135. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55136. * * 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
  55137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55140. * @param name defines the name of the mesh
  55141. * @param options defines the options used to create the mesh
  55142. * @param scene defines the hosting scene
  55143. * @returns the cylinder mesh
  55144. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55145. */
  55146. static CreateCylinder(name: string, options: {
  55147. height?: number;
  55148. diameterTop?: number;
  55149. diameterBottom?: number;
  55150. diameter?: number;
  55151. tessellation?: number;
  55152. subdivisions?: number;
  55153. arc?: number;
  55154. faceColors?: Color4[];
  55155. faceUV?: Vector4[];
  55156. updatable?: boolean;
  55157. hasRings?: boolean;
  55158. enclose?: boolean;
  55159. cap?: number;
  55160. sideOrientation?: number;
  55161. frontUVs?: Vector4;
  55162. backUVs?: Vector4;
  55163. }, scene?: Nullable<Scene>): Mesh;
  55164. /**
  55165. * Creates a torus mesh
  55166. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55167. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55168. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55169. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55170. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55172. * @param name defines the name of the mesh
  55173. * @param options defines the options used to create the mesh
  55174. * @param scene defines the hosting scene
  55175. * @returns the torus mesh
  55176. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55177. */
  55178. static CreateTorus(name: string, options: {
  55179. diameter?: number;
  55180. thickness?: number;
  55181. tessellation?: number;
  55182. updatable?: boolean;
  55183. sideOrientation?: number;
  55184. frontUVs?: Vector4;
  55185. backUVs?: Vector4;
  55186. }, scene?: Nullable<Scene>): Mesh;
  55187. /**
  55188. * Creates a torus knot mesh
  55189. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55190. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55191. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55192. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55196. * @param name defines the name of the mesh
  55197. * @param options defines the options used to create the mesh
  55198. * @param scene defines the hosting scene
  55199. * @returns the torus knot mesh
  55200. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55201. */
  55202. static CreateTorusKnot(name: string, options: {
  55203. radius?: number;
  55204. tube?: number;
  55205. radialSegments?: number;
  55206. tubularSegments?: number;
  55207. p?: number;
  55208. q?: number;
  55209. updatable?: boolean;
  55210. sideOrientation?: number;
  55211. frontUVs?: Vector4;
  55212. backUVs?: Vector4;
  55213. }, scene?: Nullable<Scene>): Mesh;
  55214. /**
  55215. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55216. * * 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
  55217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55218. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55219. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55220. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55222. * * 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
  55223. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55226. * @param name defines the name of the new line system
  55227. * @param options defines the options used to create the line system
  55228. * @param scene defines the hosting scene
  55229. * @returns a new line system mesh
  55230. */
  55231. static CreateLineSystem(name: string, options: {
  55232. lines: Vector3[][];
  55233. updatable?: boolean;
  55234. instance?: Nullable<LinesMesh>;
  55235. colors?: Nullable<Color4[][]>;
  55236. useVertexAlpha?: boolean;
  55237. }, scene: Nullable<Scene>): LinesMesh;
  55238. /**
  55239. * Creates a line mesh
  55240. * 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
  55241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55242. * * The parameter `points` is an array successive Vector3
  55243. * * 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
  55244. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55246. * * When updating an instance, remember that only point positions can change, not the number of points
  55247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55249. * @param name defines the name of the new line system
  55250. * @param options defines the options used to create the line system
  55251. * @param scene defines the hosting scene
  55252. * @returns a new line mesh
  55253. */
  55254. static CreateLines(name: string, options: {
  55255. points: Vector3[];
  55256. updatable?: boolean;
  55257. instance?: Nullable<LinesMesh>;
  55258. colors?: Color4[];
  55259. useVertexAlpha?: boolean;
  55260. }, scene?: Nullable<Scene>): LinesMesh;
  55261. /**
  55262. * Creates a dashed line mesh
  55263. * * 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
  55264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55265. * * The parameter `points` is an array successive Vector3
  55266. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55267. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55268. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55269. * * 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
  55270. * * When updating an instance, remember that only point positions can change, not the number of points
  55271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55272. * @param name defines the name of the mesh
  55273. * @param options defines the options used to create the mesh
  55274. * @param scene defines the hosting scene
  55275. * @returns the dashed line mesh
  55276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55277. */
  55278. static CreateDashedLines(name: string, options: {
  55279. points: Vector3[];
  55280. dashSize?: number;
  55281. gapSize?: number;
  55282. dashNb?: number;
  55283. updatable?: boolean;
  55284. instance?: LinesMesh;
  55285. }, scene?: Nullable<Scene>): LinesMesh;
  55286. /**
  55287. * 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.
  55288. * * 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.
  55289. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55290. * * 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.
  55291. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55292. * * 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
  55293. * * 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
  55294. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55297. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55299. * @param name defines the name of the mesh
  55300. * @param options defines the options used to create the mesh
  55301. * @param scene defines the hosting scene
  55302. * @returns the extruded shape mesh
  55303. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55305. */
  55306. static ExtrudeShape(name: string, options: {
  55307. shape: Vector3[];
  55308. path: Vector3[];
  55309. scale?: number;
  55310. rotation?: number;
  55311. cap?: number;
  55312. updatable?: boolean;
  55313. sideOrientation?: number;
  55314. frontUVs?: Vector4;
  55315. backUVs?: Vector4;
  55316. instance?: Mesh;
  55317. invertUV?: boolean;
  55318. }, scene?: Nullable<Scene>): Mesh;
  55319. /**
  55320. * Creates an custom extruded shape mesh.
  55321. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55322. * * 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.
  55323. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55324. * * 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
  55325. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55326. * * 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
  55327. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55328. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55329. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55330. * * 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
  55331. * * 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
  55332. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55337. * @param name defines the name of the mesh
  55338. * @param options defines the options used to create the mesh
  55339. * @param scene defines the hosting scene
  55340. * @returns the custom extruded shape mesh
  55341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55342. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55343. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55344. */
  55345. static ExtrudeShapeCustom(name: string, options: {
  55346. shape: Vector3[];
  55347. path: Vector3[];
  55348. scaleFunction?: any;
  55349. rotationFunction?: any;
  55350. ribbonCloseArray?: boolean;
  55351. ribbonClosePath?: boolean;
  55352. cap?: number;
  55353. updatable?: boolean;
  55354. sideOrientation?: number;
  55355. frontUVs?: Vector4;
  55356. backUVs?: Vector4;
  55357. instance?: Mesh;
  55358. invertUV?: boolean;
  55359. }, scene?: Nullable<Scene>): Mesh;
  55360. /**
  55361. * Creates lathe mesh.
  55362. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55363. * * 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
  55364. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55365. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55366. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55367. * * 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
  55368. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55369. * * 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
  55370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55372. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55374. * @param name defines the name of the mesh
  55375. * @param options defines the options used to create the mesh
  55376. * @param scene defines the hosting scene
  55377. * @returns the lathe mesh
  55378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55379. */
  55380. static CreateLathe(name: string, options: {
  55381. shape: Vector3[];
  55382. radius?: number;
  55383. tessellation?: number;
  55384. clip?: number;
  55385. arc?: number;
  55386. closed?: boolean;
  55387. updatable?: boolean;
  55388. sideOrientation?: number;
  55389. frontUVs?: Vector4;
  55390. backUVs?: Vector4;
  55391. cap?: number;
  55392. invertUV?: boolean;
  55393. }, scene?: Nullable<Scene>): Mesh;
  55394. /**
  55395. * Creates a tiled plane mesh
  55396. * * You can set a limited pattern arrangement with the tiles
  55397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55400. * @param name defines the name of the mesh
  55401. * @param options defines the options used to create the mesh
  55402. * @param scene defines the hosting scene
  55403. * @returns the plane mesh
  55404. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55405. */
  55406. static CreateTiledPlane(name: string, options: {
  55407. pattern?: number;
  55408. tileSize?: number;
  55409. tileWidth?: number;
  55410. tileHeight?: number;
  55411. size?: number;
  55412. width?: number;
  55413. height?: number;
  55414. alignHorizontal?: number;
  55415. alignVertical?: number;
  55416. sideOrientation?: number;
  55417. frontUVs?: Vector4;
  55418. backUVs?: Vector4;
  55419. updatable?: boolean;
  55420. }, scene?: Nullable<Scene>): Mesh;
  55421. /**
  55422. * Creates a plane mesh
  55423. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55424. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55425. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55429. * @param name defines the name of the mesh
  55430. * @param options defines the options used to create the mesh
  55431. * @param scene defines the hosting scene
  55432. * @returns the plane mesh
  55433. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55434. */
  55435. static CreatePlane(name: string, options: {
  55436. size?: number;
  55437. width?: number;
  55438. height?: number;
  55439. sideOrientation?: number;
  55440. frontUVs?: Vector4;
  55441. backUVs?: Vector4;
  55442. updatable?: boolean;
  55443. sourcePlane?: Plane;
  55444. }, scene?: Nullable<Scene>): Mesh;
  55445. /**
  55446. * Creates a ground mesh
  55447. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55448. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55450. * @param name defines the name of the mesh
  55451. * @param options defines the options used to create the mesh
  55452. * @param scene defines the hosting scene
  55453. * @returns the ground mesh
  55454. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55455. */
  55456. static CreateGround(name: string, options: {
  55457. width?: number;
  55458. height?: number;
  55459. subdivisions?: number;
  55460. subdivisionsX?: number;
  55461. subdivisionsY?: number;
  55462. updatable?: boolean;
  55463. }, scene?: Nullable<Scene>): Mesh;
  55464. /**
  55465. * Creates a tiled ground mesh
  55466. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55467. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55468. * * 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
  55469. * * 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
  55470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55471. * @param name defines the name of the mesh
  55472. * @param options defines the options used to create the mesh
  55473. * @param scene defines the hosting scene
  55474. * @returns the tiled ground mesh
  55475. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55476. */
  55477. static CreateTiledGround(name: string, options: {
  55478. xmin: number;
  55479. zmin: number;
  55480. xmax: number;
  55481. zmax: number;
  55482. subdivisions?: {
  55483. w: number;
  55484. h: number;
  55485. };
  55486. precision?: {
  55487. w: number;
  55488. h: number;
  55489. };
  55490. updatable?: boolean;
  55491. }, scene?: Nullable<Scene>): Mesh;
  55492. /**
  55493. * Creates a ground mesh from a height map
  55494. * * The parameter `url` sets the URL of the height map image resource.
  55495. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55496. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55497. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55498. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55499. * * 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.
  55500. * * 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).
  55501. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55503. * @param name defines the name of the mesh
  55504. * @param url defines the url to the height map
  55505. * @param options defines the options used to create the mesh
  55506. * @param scene defines the hosting scene
  55507. * @returns the ground mesh
  55508. * @see https://doc.babylonjs.com/babylon101/height_map
  55509. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55510. */
  55511. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55512. width?: number;
  55513. height?: number;
  55514. subdivisions?: number;
  55515. minHeight?: number;
  55516. maxHeight?: number;
  55517. colorFilter?: Color3;
  55518. alphaFilter?: number;
  55519. updatable?: boolean;
  55520. onReady?: (mesh: GroundMesh) => void;
  55521. }, scene?: Nullable<Scene>): GroundMesh;
  55522. /**
  55523. * Creates a polygon mesh
  55524. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55525. * * 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
  55526. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55529. * * Remember you can only change the shape positions, not their number when updating a polygon
  55530. * @param name defines the name of the mesh
  55531. * @param options defines the options used to create the mesh
  55532. * @param scene defines the hosting scene
  55533. * @param earcutInjection can be used to inject your own earcut reference
  55534. * @returns the polygon mesh
  55535. */
  55536. static CreatePolygon(name: string, options: {
  55537. shape: Vector3[];
  55538. holes?: Vector3[][];
  55539. depth?: number;
  55540. faceUV?: Vector4[];
  55541. faceColors?: Color4[];
  55542. updatable?: boolean;
  55543. sideOrientation?: number;
  55544. frontUVs?: Vector4;
  55545. backUVs?: Vector4;
  55546. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55547. /**
  55548. * Creates an extruded polygon mesh, with depth in the Y direction.
  55549. * * 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)
  55550. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55551. * @param name defines the name of the mesh
  55552. * @param options defines the options used to create the mesh
  55553. * @param scene defines the hosting scene
  55554. * @param earcutInjection can be used to inject your own earcut reference
  55555. * @returns the polygon mesh
  55556. */
  55557. static ExtrudePolygon(name: string, options: {
  55558. shape: Vector3[];
  55559. holes?: Vector3[][];
  55560. depth?: number;
  55561. faceUV?: Vector4[];
  55562. faceColors?: Color4[];
  55563. updatable?: boolean;
  55564. sideOrientation?: number;
  55565. frontUVs?: Vector4;
  55566. backUVs?: Vector4;
  55567. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55568. /**
  55569. * Creates a tube mesh.
  55570. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55571. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55572. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55573. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55574. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55575. * * 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)
  55576. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55577. * * 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
  55578. * * 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
  55579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55583. * @param name defines the name of the mesh
  55584. * @param options defines the options used to create the mesh
  55585. * @param scene defines the hosting scene
  55586. * @returns the tube mesh
  55587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55588. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55589. */
  55590. static CreateTube(name: string, options: {
  55591. path: Vector3[];
  55592. radius?: number;
  55593. tessellation?: number;
  55594. radiusFunction?: {
  55595. (i: number, distance: number): number;
  55596. };
  55597. cap?: number;
  55598. arc?: number;
  55599. updatable?: boolean;
  55600. sideOrientation?: number;
  55601. frontUVs?: Vector4;
  55602. backUVs?: Vector4;
  55603. instance?: Mesh;
  55604. invertUV?: boolean;
  55605. }, scene?: Nullable<Scene>): Mesh;
  55606. /**
  55607. * Creates a polyhedron mesh
  55608. * * 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
  55609. * * The parameter `size` (positive float, default 1) sets the polygon size
  55610. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55611. * * 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`
  55612. * * 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
  55613. * * 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)`)
  55614. * * 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
  55615. * * 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
  55616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55619. * @param name defines the name of the mesh
  55620. * @param options defines the options used to create the mesh
  55621. * @param scene defines the hosting scene
  55622. * @returns the polyhedron mesh
  55623. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55624. */
  55625. static CreatePolyhedron(name: string, options: {
  55626. type?: number;
  55627. size?: number;
  55628. sizeX?: number;
  55629. sizeY?: number;
  55630. sizeZ?: number;
  55631. custom?: any;
  55632. faceUV?: Vector4[];
  55633. faceColors?: Color4[];
  55634. flat?: boolean;
  55635. updatable?: boolean;
  55636. sideOrientation?: number;
  55637. frontUVs?: Vector4;
  55638. backUVs?: Vector4;
  55639. }, scene?: Nullable<Scene>): Mesh;
  55640. /**
  55641. * Creates a decal mesh.
  55642. * 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
  55643. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55644. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55645. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55646. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55647. * @param name defines the name of the mesh
  55648. * @param sourceMesh defines the mesh where the decal must be applied
  55649. * @param options defines the options used to create the mesh
  55650. * @param scene defines the hosting scene
  55651. * @returns the decal mesh
  55652. * @see https://doc.babylonjs.com/how_to/decals
  55653. */
  55654. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55655. position?: Vector3;
  55656. normal?: Vector3;
  55657. size?: Vector3;
  55658. angle?: number;
  55659. }): Mesh;
  55660. }
  55661. }
  55662. declare module "babylonjs/Meshes/meshSimplification" {
  55663. import { Mesh } from "babylonjs/Meshes/mesh";
  55664. /**
  55665. * A simplifier interface for future simplification implementations
  55666. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55667. */
  55668. export interface ISimplifier {
  55669. /**
  55670. * Simplification of a given mesh according to the given settings.
  55671. * Since this requires computation, it is assumed that the function runs async.
  55672. * @param settings The settings of the simplification, including quality and distance
  55673. * @param successCallback A callback that will be called after the mesh was simplified.
  55674. * @param errorCallback in case of an error, this callback will be called. optional.
  55675. */
  55676. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55677. }
  55678. /**
  55679. * Expected simplification settings.
  55680. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55681. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55682. */
  55683. export interface ISimplificationSettings {
  55684. /**
  55685. * Gets or sets the expected quality
  55686. */
  55687. quality: number;
  55688. /**
  55689. * Gets or sets the distance when this optimized version should be used
  55690. */
  55691. distance: number;
  55692. /**
  55693. * Gets an already optimized mesh
  55694. */
  55695. optimizeMesh?: boolean;
  55696. }
  55697. /**
  55698. * Class used to specify simplification options
  55699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55700. */
  55701. export class SimplificationSettings implements ISimplificationSettings {
  55702. /** expected quality */
  55703. quality: number;
  55704. /** distance when this optimized version should be used */
  55705. distance: number;
  55706. /** already optimized mesh */
  55707. optimizeMesh?: boolean | undefined;
  55708. /**
  55709. * Creates a SimplificationSettings
  55710. * @param quality expected quality
  55711. * @param distance distance when this optimized version should be used
  55712. * @param optimizeMesh already optimized mesh
  55713. */
  55714. constructor(
  55715. /** expected quality */
  55716. quality: number,
  55717. /** distance when this optimized version should be used */
  55718. distance: number,
  55719. /** already optimized mesh */
  55720. optimizeMesh?: boolean | undefined);
  55721. }
  55722. /**
  55723. * Interface used to define a simplification task
  55724. */
  55725. export interface ISimplificationTask {
  55726. /**
  55727. * Array of settings
  55728. */
  55729. settings: Array<ISimplificationSettings>;
  55730. /**
  55731. * Simplification type
  55732. */
  55733. simplificationType: SimplificationType;
  55734. /**
  55735. * Mesh to simplify
  55736. */
  55737. mesh: Mesh;
  55738. /**
  55739. * Callback called on success
  55740. */
  55741. successCallback?: () => void;
  55742. /**
  55743. * Defines if parallel processing can be used
  55744. */
  55745. parallelProcessing: boolean;
  55746. }
  55747. /**
  55748. * Queue used to order the simplification tasks
  55749. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55750. */
  55751. export class SimplificationQueue {
  55752. private _simplificationArray;
  55753. /**
  55754. * Gets a boolean indicating that the process is still running
  55755. */
  55756. running: boolean;
  55757. /**
  55758. * Creates a new queue
  55759. */
  55760. constructor();
  55761. /**
  55762. * Adds a new simplification task
  55763. * @param task defines a task to add
  55764. */
  55765. addTask(task: ISimplificationTask): void;
  55766. /**
  55767. * Execute next task
  55768. */
  55769. executeNext(): void;
  55770. /**
  55771. * Execute a simplification task
  55772. * @param task defines the task to run
  55773. */
  55774. runSimplification(task: ISimplificationTask): void;
  55775. private getSimplifier;
  55776. }
  55777. /**
  55778. * The implemented types of simplification
  55779. * At the moment only Quadratic Error Decimation is implemented
  55780. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55781. */
  55782. export enum SimplificationType {
  55783. /** Quadratic error decimation */
  55784. QUADRATIC = 0
  55785. }
  55786. }
  55787. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55788. import { Scene } from "babylonjs/scene";
  55789. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55790. import { ISceneComponent } from "babylonjs/sceneComponent";
  55791. module "babylonjs/scene" {
  55792. interface Scene {
  55793. /** @hidden (Backing field) */
  55794. _simplificationQueue: SimplificationQueue;
  55795. /**
  55796. * Gets or sets the simplification queue attached to the scene
  55797. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55798. */
  55799. simplificationQueue: SimplificationQueue;
  55800. }
  55801. }
  55802. module "babylonjs/Meshes/mesh" {
  55803. interface Mesh {
  55804. /**
  55805. * Simplify the mesh according to the given array of settings.
  55806. * Function will return immediately and will simplify async
  55807. * @param settings a collection of simplification settings
  55808. * @param parallelProcessing should all levels calculate parallel or one after the other
  55809. * @param simplificationType the type of simplification to run
  55810. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55811. * @returns the current mesh
  55812. */
  55813. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55814. }
  55815. }
  55816. /**
  55817. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55818. * created in a scene
  55819. */
  55820. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55821. /**
  55822. * The component name helpfull to identify the component in the list of scene components.
  55823. */
  55824. readonly name: string;
  55825. /**
  55826. * The scene the component belongs to.
  55827. */
  55828. scene: Scene;
  55829. /**
  55830. * Creates a new instance of the component for the given scene
  55831. * @param scene Defines the scene to register the component in
  55832. */
  55833. constructor(scene: Scene);
  55834. /**
  55835. * Registers the component in a given scene
  55836. */
  55837. register(): void;
  55838. /**
  55839. * Rebuilds the elements related to this component in case of
  55840. * context lost for instance.
  55841. */
  55842. rebuild(): void;
  55843. /**
  55844. * Disposes the component and the associated ressources
  55845. */
  55846. dispose(): void;
  55847. private _beforeCameraUpdate;
  55848. }
  55849. }
  55850. declare module "babylonjs/Meshes/Builders/index" {
  55851. export * from "babylonjs/Meshes/Builders/boxBuilder";
  55852. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  55853. export * from "babylonjs/Meshes/Builders/discBuilder";
  55854. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  55855. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  55856. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  55857. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  55858. export * from "babylonjs/Meshes/Builders/torusBuilder";
  55859. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  55860. export * from "babylonjs/Meshes/Builders/linesBuilder";
  55861. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  55862. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  55863. export * from "babylonjs/Meshes/Builders/latheBuilder";
  55864. export * from "babylonjs/Meshes/Builders/planeBuilder";
  55865. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  55866. export * from "babylonjs/Meshes/Builders/groundBuilder";
  55867. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  55868. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  55869. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  55870. export * from "babylonjs/Meshes/Builders/decalBuilder";
  55871. }
  55872. declare module "babylonjs/Meshes/index" {
  55873. export * from "babylonjs/Meshes/abstractMesh";
  55874. export * from "babylonjs/Meshes/buffer";
  55875. export * from "babylonjs/Meshes/Compression/index";
  55876. export * from "babylonjs/Meshes/csg";
  55877. export * from "babylonjs/Meshes/geometry";
  55878. export * from "babylonjs/Meshes/groundMesh";
  55879. export * from "babylonjs/Meshes/trailMesh";
  55880. export * from "babylonjs/Meshes/instancedMesh";
  55881. export * from "babylonjs/Meshes/linesMesh";
  55882. export * from "babylonjs/Meshes/mesh";
  55883. export * from "babylonjs/Meshes/mesh.vertexData";
  55884. export * from "babylonjs/Meshes/meshBuilder";
  55885. export * from "babylonjs/Meshes/meshSimplification";
  55886. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  55887. export * from "babylonjs/Meshes/polygonMesh";
  55888. export * from "babylonjs/Meshes/subMesh";
  55889. export * from "babylonjs/Meshes/meshLODLevel";
  55890. export * from "babylonjs/Meshes/transformNode";
  55891. export * from "babylonjs/Meshes/Builders/index";
  55892. export * from "babylonjs/Meshes/dataBuffer";
  55893. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  55894. }
  55895. declare module "babylonjs/Morph/index" {
  55896. export * from "babylonjs/Morph/morphTarget";
  55897. export * from "babylonjs/Morph/morphTargetManager";
  55898. }
  55899. declare module "babylonjs/Offline/database" {
  55900. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  55901. /**
  55902. * Class used to enable access to IndexedDB
  55903. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55904. */
  55905. export class Database implements IOfflineProvider {
  55906. private _callbackManifestChecked;
  55907. private _currentSceneUrl;
  55908. private _db;
  55909. private _enableSceneOffline;
  55910. private _enableTexturesOffline;
  55911. private _manifestVersionFound;
  55912. private _mustUpdateRessources;
  55913. private _hasReachedQuota;
  55914. private _isSupported;
  55915. private _idbFactory;
  55916. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55917. private static IsUASupportingBlobStorage;
  55918. /**
  55919. * Gets a boolean indicating if Database storate is enabled (off by default)
  55920. */
  55921. static IDBStorageEnabled: boolean;
  55922. /**
  55923. * Gets a boolean indicating if scene must be saved in the database
  55924. */
  55925. readonly enableSceneOffline: boolean;
  55926. /**
  55927. * Gets a boolean indicating if textures must be saved in the database
  55928. */
  55929. readonly enableTexturesOffline: boolean;
  55930. /**
  55931. * Creates a new Database
  55932. * @param urlToScene defines the url to load the scene
  55933. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55934. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55935. */
  55936. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55937. private static _ParseURL;
  55938. private static _ReturnFullUrlLocation;
  55939. private _checkManifestFile;
  55940. /**
  55941. * Open the database and make it available
  55942. * @param successCallback defines the callback to call on success
  55943. * @param errorCallback defines the callback to call on error
  55944. */
  55945. open(successCallback: () => void, errorCallback: () => void): void;
  55946. /**
  55947. * Loads an image from the database
  55948. * @param url defines the url to load from
  55949. * @param image defines the target DOM image
  55950. */
  55951. loadImage(url: string, image: HTMLImageElement): void;
  55952. private _loadImageFromDBAsync;
  55953. private _saveImageIntoDBAsync;
  55954. private _checkVersionFromDB;
  55955. private _loadVersionFromDBAsync;
  55956. private _saveVersionIntoDBAsync;
  55957. /**
  55958. * Loads a file from database
  55959. * @param url defines the URL to load from
  55960. * @param sceneLoaded defines a callback to call on success
  55961. * @param progressCallBack defines a callback to call when progress changed
  55962. * @param errorCallback defines a callback to call on error
  55963. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55964. */
  55965. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55966. private _loadFileAsync;
  55967. private _saveFileAsync;
  55968. /**
  55969. * Validates if xhr data is correct
  55970. * @param xhr defines the request to validate
  55971. * @param dataType defines the expected data type
  55972. * @returns true if data is correct
  55973. */
  55974. private static _ValidateXHRData;
  55975. }
  55976. }
  55977. declare module "babylonjs/Offline/index" {
  55978. export * from "babylonjs/Offline/database";
  55979. export * from "babylonjs/Offline/IOfflineProvider";
  55980. }
  55981. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  55982. /** @hidden */
  55983. export var gpuUpdateParticlesPixelShader: {
  55984. name: string;
  55985. shader: string;
  55986. };
  55987. }
  55988. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  55989. /** @hidden */
  55990. export var gpuUpdateParticlesVertexShader: {
  55991. name: string;
  55992. shader: string;
  55993. };
  55994. }
  55995. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  55996. /** @hidden */
  55997. export var clipPlaneFragmentDeclaration2: {
  55998. name: string;
  55999. shader: string;
  56000. };
  56001. }
  56002. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56003. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56004. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56005. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56006. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56007. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56008. /** @hidden */
  56009. export var gpuRenderParticlesPixelShader: {
  56010. name: string;
  56011. shader: string;
  56012. };
  56013. }
  56014. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56015. /** @hidden */
  56016. export var clipPlaneVertexDeclaration2: {
  56017. name: string;
  56018. shader: string;
  56019. };
  56020. }
  56021. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56022. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56023. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56024. /** @hidden */
  56025. export var gpuRenderParticlesVertexShader: {
  56026. name: string;
  56027. shader: string;
  56028. };
  56029. }
  56030. declare module "babylonjs/Particles/gpuParticleSystem" {
  56031. import { Nullable } from "babylonjs/types";
  56032. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56033. import { Observable } from "babylonjs/Misc/observable";
  56034. import { Color4, Color3 } from "babylonjs/Maths/math";
  56035. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56036. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56037. import { Scene, IDisposable } from "babylonjs/scene";
  56038. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56039. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56040. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56041. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56042. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56043. /**
  56044. * This represents a GPU particle system in Babylon
  56045. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56046. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56047. */
  56048. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56049. /**
  56050. * The layer mask we are rendering the particles through.
  56051. */
  56052. layerMask: number;
  56053. private _capacity;
  56054. private _activeCount;
  56055. private _currentActiveCount;
  56056. private _accumulatedCount;
  56057. private _renderEffect;
  56058. private _updateEffect;
  56059. private _buffer0;
  56060. private _buffer1;
  56061. private _spriteBuffer;
  56062. private _updateVAO;
  56063. private _renderVAO;
  56064. private _targetIndex;
  56065. private _sourceBuffer;
  56066. private _targetBuffer;
  56067. private _engine;
  56068. private _currentRenderId;
  56069. private _started;
  56070. private _stopped;
  56071. private _timeDelta;
  56072. private _randomTexture;
  56073. private _randomTexture2;
  56074. private _attributesStrideSize;
  56075. private _updateEffectOptions;
  56076. private _randomTextureSize;
  56077. private _actualFrame;
  56078. private readonly _rawTextureWidth;
  56079. /**
  56080. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56081. */
  56082. static readonly IsSupported: boolean;
  56083. /**
  56084. * An event triggered when the system is disposed.
  56085. */
  56086. onDisposeObservable: Observable<GPUParticleSystem>;
  56087. /**
  56088. * Gets the maximum number of particles active at the same time.
  56089. * @returns The max number of active particles.
  56090. */
  56091. getCapacity(): number;
  56092. /**
  56093. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56094. * to override the particles.
  56095. */
  56096. forceDepthWrite: boolean;
  56097. /**
  56098. * Gets or set the number of active particles
  56099. */
  56100. activeParticleCount: number;
  56101. private _preWarmDone;
  56102. /**
  56103. * Is this system ready to be used/rendered
  56104. * @return true if the system is ready
  56105. */
  56106. isReady(): boolean;
  56107. /**
  56108. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56109. * @returns True if it has been started, otherwise false.
  56110. */
  56111. isStarted(): boolean;
  56112. /**
  56113. * Starts the particle system and begins to emit
  56114. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56115. */
  56116. start(delay?: number): void;
  56117. /**
  56118. * Stops the particle system.
  56119. */
  56120. stop(): void;
  56121. /**
  56122. * Remove all active particles
  56123. */
  56124. reset(): void;
  56125. /**
  56126. * Returns the string "GPUParticleSystem"
  56127. * @returns a string containing the class name
  56128. */
  56129. getClassName(): string;
  56130. private _colorGradientsTexture;
  56131. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56132. /**
  56133. * Adds a new color gradient
  56134. * @param gradient defines the gradient to use (between 0 and 1)
  56135. * @param color1 defines the color to affect to the specified gradient
  56136. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56137. * @returns the current particle system
  56138. */
  56139. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56140. /**
  56141. * Remove a specific color gradient
  56142. * @param gradient defines the gradient to remove
  56143. * @returns the current particle system
  56144. */
  56145. removeColorGradient(gradient: number): GPUParticleSystem;
  56146. private _angularSpeedGradientsTexture;
  56147. private _sizeGradientsTexture;
  56148. private _velocityGradientsTexture;
  56149. private _limitVelocityGradientsTexture;
  56150. private _dragGradientsTexture;
  56151. private _addFactorGradient;
  56152. /**
  56153. * Adds a new size gradient
  56154. * @param gradient defines the gradient to use (between 0 and 1)
  56155. * @param factor defines the size factor to affect to the specified gradient
  56156. * @returns the current particle system
  56157. */
  56158. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56159. /**
  56160. * Remove a specific size gradient
  56161. * @param gradient defines the gradient to remove
  56162. * @returns the current particle system
  56163. */
  56164. removeSizeGradient(gradient: number): GPUParticleSystem;
  56165. /**
  56166. * Adds a new angular speed gradient
  56167. * @param gradient defines the gradient to use (between 0 and 1)
  56168. * @param factor defines the angular speed to affect to the specified gradient
  56169. * @returns the current particle system
  56170. */
  56171. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56172. /**
  56173. * Remove a specific angular speed gradient
  56174. * @param gradient defines the gradient to remove
  56175. * @returns the current particle system
  56176. */
  56177. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56178. /**
  56179. * Adds a new velocity gradient
  56180. * @param gradient defines the gradient to use (between 0 and 1)
  56181. * @param factor defines the velocity to affect to the specified gradient
  56182. * @returns the current particle system
  56183. */
  56184. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56185. /**
  56186. * Remove a specific velocity gradient
  56187. * @param gradient defines the gradient to remove
  56188. * @returns the current particle system
  56189. */
  56190. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56191. /**
  56192. * Adds a new limit velocity gradient
  56193. * @param gradient defines the gradient to use (between 0 and 1)
  56194. * @param factor defines the limit velocity value to affect to the specified gradient
  56195. * @returns the current particle system
  56196. */
  56197. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56198. /**
  56199. * Remove a specific limit velocity gradient
  56200. * @param gradient defines the gradient to remove
  56201. * @returns the current particle system
  56202. */
  56203. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56204. /**
  56205. * Adds a new drag gradient
  56206. * @param gradient defines the gradient to use (between 0 and 1)
  56207. * @param factor defines the drag value to affect to the specified gradient
  56208. * @returns the current particle system
  56209. */
  56210. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56211. /**
  56212. * Remove a specific drag gradient
  56213. * @param gradient defines the gradient to remove
  56214. * @returns the current particle system
  56215. */
  56216. removeDragGradient(gradient: number): GPUParticleSystem;
  56217. /**
  56218. * Not supported by GPUParticleSystem
  56219. * @param gradient defines the gradient to use (between 0 and 1)
  56220. * @param factor defines the emit rate value to affect to the specified gradient
  56221. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56222. * @returns the current particle system
  56223. */
  56224. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56225. /**
  56226. * Not supported by GPUParticleSystem
  56227. * @param gradient defines the gradient to remove
  56228. * @returns the current particle system
  56229. */
  56230. removeEmitRateGradient(gradient: number): IParticleSystem;
  56231. /**
  56232. * Not supported by GPUParticleSystem
  56233. * @param gradient defines the gradient to use (between 0 and 1)
  56234. * @param factor defines the start size value to affect to the specified gradient
  56235. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56236. * @returns the current particle system
  56237. */
  56238. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56239. /**
  56240. * Not supported by GPUParticleSystem
  56241. * @param gradient defines the gradient to remove
  56242. * @returns the current particle system
  56243. */
  56244. removeStartSizeGradient(gradient: number): IParticleSystem;
  56245. /**
  56246. * Not supported by GPUParticleSystem
  56247. * @param gradient defines the gradient to use (between 0 and 1)
  56248. * @param min defines the color remap minimal range
  56249. * @param max defines the color remap maximal range
  56250. * @returns the current particle system
  56251. */
  56252. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56253. /**
  56254. * Not supported by GPUParticleSystem
  56255. * @param gradient defines the gradient to remove
  56256. * @returns the current particle system
  56257. */
  56258. removeColorRemapGradient(): IParticleSystem;
  56259. /**
  56260. * Not supported by GPUParticleSystem
  56261. * @param gradient defines the gradient to use (between 0 and 1)
  56262. * @param min defines the alpha remap minimal range
  56263. * @param max defines the alpha remap maximal range
  56264. * @returns the current particle system
  56265. */
  56266. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56267. /**
  56268. * Not supported by GPUParticleSystem
  56269. * @param gradient defines the gradient to remove
  56270. * @returns the current particle system
  56271. */
  56272. removeAlphaRemapGradient(): IParticleSystem;
  56273. /**
  56274. * Not supported by GPUParticleSystem
  56275. * @param gradient defines the gradient to use (between 0 and 1)
  56276. * @param color defines the color to affect to the specified gradient
  56277. * @returns the current particle system
  56278. */
  56279. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56280. /**
  56281. * Not supported by GPUParticleSystem
  56282. * @param gradient defines the gradient to remove
  56283. * @returns the current particle system
  56284. */
  56285. removeRampGradient(): IParticleSystem;
  56286. /**
  56287. * Not supported by GPUParticleSystem
  56288. * @returns the list of ramp gradients
  56289. */
  56290. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56291. /**
  56292. * Not supported by GPUParticleSystem
  56293. * Gets or sets a boolean indicating that ramp gradients must be used
  56294. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56295. */
  56296. useRampGradients: boolean;
  56297. /**
  56298. * Not supported by GPUParticleSystem
  56299. * @param gradient defines the gradient to use (between 0 and 1)
  56300. * @param factor defines the life time factor to affect to the specified gradient
  56301. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56302. * @returns the current particle system
  56303. */
  56304. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56305. /**
  56306. * Not supported by GPUParticleSystem
  56307. * @param gradient defines the gradient to remove
  56308. * @returns the current particle system
  56309. */
  56310. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56311. /**
  56312. * Instantiates a GPU particle system.
  56313. * 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.
  56314. * @param name The name of the particle system
  56315. * @param options The options used to create the system
  56316. * @param scene The scene the particle system belongs to
  56317. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56318. */
  56319. constructor(name: string, options: Partial<{
  56320. capacity: number;
  56321. randomTextureSize: number;
  56322. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56323. protected _reset(): void;
  56324. private _createUpdateVAO;
  56325. private _createRenderVAO;
  56326. private _initialize;
  56327. /** @hidden */
  56328. _recreateUpdateEffect(): void;
  56329. /** @hidden */
  56330. _recreateRenderEffect(): void;
  56331. /**
  56332. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56333. * @param preWarm defines if we are in the pre-warmimg phase
  56334. */
  56335. animate(preWarm?: boolean): void;
  56336. private _createFactorGradientTexture;
  56337. private _createSizeGradientTexture;
  56338. private _createAngularSpeedGradientTexture;
  56339. private _createVelocityGradientTexture;
  56340. private _createLimitVelocityGradientTexture;
  56341. private _createDragGradientTexture;
  56342. private _createColorGradientTexture;
  56343. /**
  56344. * Renders the particle system in its current state
  56345. * @param preWarm defines if the system should only update the particles but not render them
  56346. * @returns the current number of particles
  56347. */
  56348. render(preWarm?: boolean): number;
  56349. /**
  56350. * Rebuilds the particle system
  56351. */
  56352. rebuild(): void;
  56353. private _releaseBuffers;
  56354. private _releaseVAOs;
  56355. /**
  56356. * Disposes the particle system and free the associated resources
  56357. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56358. */
  56359. dispose(disposeTexture?: boolean): void;
  56360. /**
  56361. * Clones the particle system.
  56362. * @param name The name of the cloned object
  56363. * @param newEmitter The new emitter to use
  56364. * @returns the cloned particle system
  56365. */
  56366. clone(name: string, newEmitter: any): GPUParticleSystem;
  56367. /**
  56368. * Serializes the particle system to a JSON object.
  56369. * @returns the JSON object
  56370. */
  56371. serialize(): any;
  56372. /**
  56373. * Parses a JSON object to create a GPU particle system.
  56374. * @param parsedParticleSystem The JSON object to parse
  56375. * @param scene The scene to create the particle system in
  56376. * @param rootUrl The root url to use to load external dependencies like texture
  56377. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56378. * @returns the parsed GPU particle system
  56379. */
  56380. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56381. }
  56382. }
  56383. declare module "babylonjs/Particles/particleSystemSet" {
  56384. import { Nullable } from "babylonjs/types";
  56385. import { Color3 } from "babylonjs/Maths/math";
  56386. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56388. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56389. import { Scene, IDisposable } from "babylonjs/scene";
  56390. /**
  56391. * Represents a set of particle systems working together to create a specific effect
  56392. */
  56393. export class ParticleSystemSet implements IDisposable {
  56394. private _emitterCreationOptions;
  56395. private _emitterNode;
  56396. /**
  56397. * Gets the particle system list
  56398. */
  56399. systems: IParticleSystem[];
  56400. /**
  56401. * Gets the emitter node used with this set
  56402. */
  56403. readonly emitterNode: Nullable<TransformNode>;
  56404. /**
  56405. * Creates a new emitter mesh as a sphere
  56406. * @param options defines the options used to create the sphere
  56407. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56408. * @param scene defines the hosting scene
  56409. */
  56410. setEmitterAsSphere(options: {
  56411. diameter: number;
  56412. segments: number;
  56413. color: Color3;
  56414. }, renderingGroupId: number, scene: Scene): void;
  56415. /**
  56416. * Starts all particle systems of the set
  56417. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56418. */
  56419. start(emitter?: AbstractMesh): void;
  56420. /**
  56421. * Release all associated resources
  56422. */
  56423. dispose(): void;
  56424. /**
  56425. * Serialize the set into a JSON compatible object
  56426. * @returns a JSON compatible representation of the set
  56427. */
  56428. serialize(): any;
  56429. /**
  56430. * Parse a new ParticleSystemSet from a serialized source
  56431. * @param data defines a JSON compatible representation of the set
  56432. * @param scene defines the hosting scene
  56433. * @param gpu defines if we want GPU particles or CPU particles
  56434. * @returns a new ParticleSystemSet
  56435. */
  56436. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56437. }
  56438. }
  56439. declare module "babylonjs/Particles/particleHelper" {
  56440. import { Nullable } from "babylonjs/types";
  56441. import { Scene } from "babylonjs/scene";
  56442. import { Vector3 } from "babylonjs/Maths/math";
  56443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56444. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56445. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56446. /**
  56447. * This class is made for on one-liner static method to help creating particle system set.
  56448. */
  56449. export class ParticleHelper {
  56450. /**
  56451. * Gets or sets base Assets URL
  56452. */
  56453. static BaseAssetsUrl: string;
  56454. /**
  56455. * Create a default particle system that you can tweak
  56456. * @param emitter defines the emitter to use
  56457. * @param capacity defines the system capacity (default is 500 particles)
  56458. * @param scene defines the hosting scene
  56459. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56460. * @returns the new Particle system
  56461. */
  56462. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56463. /**
  56464. * This is the main static method (one-liner) of this helper to create different particle systems
  56465. * @param type This string represents the type to the particle system to create
  56466. * @param scene The scene where the particle system should live
  56467. * @param gpu If the system will use gpu
  56468. * @returns the ParticleSystemSet created
  56469. */
  56470. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56471. /**
  56472. * Static function used to export a particle system to a ParticleSystemSet variable.
  56473. * Please note that the emitter shape is not exported
  56474. * @param systems defines the particle systems to export
  56475. * @returns the created particle system set
  56476. */
  56477. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56478. }
  56479. }
  56480. declare module "babylonjs/Particles/particleSystemComponent" {
  56481. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56482. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56483. import "babylonjs/Shaders/particles.vertex";
  56484. module "babylonjs/Engines/engine" {
  56485. interface Engine {
  56486. /**
  56487. * Create an effect to use with particle systems.
  56488. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56489. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56490. * @param uniformsNames defines a list of attribute names
  56491. * @param samplers defines an array of string used to represent textures
  56492. * @param defines defines the string containing the defines to use to compile the shaders
  56493. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56494. * @param onCompiled defines a function to call when the effect creation is successful
  56495. * @param onError defines a function to call when the effect creation has failed
  56496. * @returns the new Effect
  56497. */
  56498. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56499. }
  56500. }
  56501. module "babylonjs/Meshes/mesh" {
  56502. interface Mesh {
  56503. /**
  56504. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56505. * @returns an array of IParticleSystem
  56506. */
  56507. getEmittedParticleSystems(): IParticleSystem[];
  56508. /**
  56509. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56510. * @returns an array of IParticleSystem
  56511. */
  56512. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56513. }
  56514. }
  56515. /**
  56516. * @hidden
  56517. */
  56518. export var _IDoNeedToBeInTheBuild: number;
  56519. }
  56520. declare module "babylonjs/Particles/index" {
  56521. export * from "babylonjs/Particles/baseParticleSystem";
  56522. export * from "babylonjs/Particles/EmitterTypes/index";
  56523. export * from "babylonjs/Particles/gpuParticleSystem";
  56524. export * from "babylonjs/Particles/IParticleSystem";
  56525. export * from "babylonjs/Particles/particle";
  56526. export * from "babylonjs/Particles/particleHelper";
  56527. export * from "babylonjs/Particles/particleSystem";
  56528. export * from "babylonjs/Particles/particleSystemComponent";
  56529. export * from "babylonjs/Particles/particleSystemSet";
  56530. export * from "babylonjs/Particles/solidParticle";
  56531. export * from "babylonjs/Particles/solidParticleSystem";
  56532. export * from "babylonjs/Particles/subEmitter";
  56533. }
  56534. declare module "babylonjs/Physics/physicsEngineComponent" {
  56535. import { Nullable } from "babylonjs/types";
  56536. import { Observable, Observer } from "babylonjs/Misc/observable";
  56537. import { Vector3 } from "babylonjs/Maths/math";
  56538. import { Mesh } from "babylonjs/Meshes/mesh";
  56539. import { ISceneComponent } from "babylonjs/sceneComponent";
  56540. import { Scene } from "babylonjs/scene";
  56541. import { Node } from "babylonjs/node";
  56542. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56543. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56544. module "babylonjs/scene" {
  56545. interface Scene {
  56546. /** @hidden (Backing field) */
  56547. _physicsEngine: Nullable<IPhysicsEngine>;
  56548. /**
  56549. * Gets the current physics engine
  56550. * @returns a IPhysicsEngine or null if none attached
  56551. */
  56552. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56553. /**
  56554. * Enables physics to the current scene
  56555. * @param gravity defines the scene's gravity for the physics engine
  56556. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56557. * @return a boolean indicating if the physics engine was initialized
  56558. */
  56559. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56560. /**
  56561. * Disables and disposes the physics engine associated with the scene
  56562. */
  56563. disablePhysicsEngine(): void;
  56564. /**
  56565. * Gets a boolean indicating if there is an active physics engine
  56566. * @returns a boolean indicating if there is an active physics engine
  56567. */
  56568. isPhysicsEnabled(): boolean;
  56569. /**
  56570. * Deletes a physics compound impostor
  56571. * @param compound defines the compound to delete
  56572. */
  56573. deleteCompoundImpostor(compound: any): void;
  56574. /**
  56575. * An event triggered when physic simulation is about to be run
  56576. */
  56577. onBeforePhysicsObservable: Observable<Scene>;
  56578. /**
  56579. * An event triggered when physic simulation has been done
  56580. */
  56581. onAfterPhysicsObservable: Observable<Scene>;
  56582. }
  56583. }
  56584. module "babylonjs/Meshes/abstractMesh" {
  56585. interface AbstractMesh {
  56586. /** @hidden */
  56587. _physicsImpostor: Nullable<PhysicsImpostor>;
  56588. /**
  56589. * Gets or sets impostor used for physic simulation
  56590. * @see http://doc.babylonjs.com/features/physics_engine
  56591. */
  56592. physicsImpostor: Nullable<PhysicsImpostor>;
  56593. /**
  56594. * Gets the current physics impostor
  56595. * @see http://doc.babylonjs.com/features/physics_engine
  56596. * @returns a physics impostor or null
  56597. */
  56598. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56599. /** Apply a physic impulse to the mesh
  56600. * @param force defines the force to apply
  56601. * @param contactPoint defines where to apply the force
  56602. * @returns the current mesh
  56603. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56604. */
  56605. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56606. /**
  56607. * Creates a physic joint between two meshes
  56608. * @param otherMesh defines the other mesh to use
  56609. * @param pivot1 defines the pivot to use on this mesh
  56610. * @param pivot2 defines the pivot to use on the other mesh
  56611. * @param options defines additional options (can be plugin dependent)
  56612. * @returns the current mesh
  56613. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56614. */
  56615. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56616. /** @hidden */
  56617. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56618. }
  56619. }
  56620. /**
  56621. * Defines the physics engine scene component responsible to manage a physics engine
  56622. */
  56623. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56624. /**
  56625. * The component name helpful to identify the component in the list of scene components.
  56626. */
  56627. readonly name: string;
  56628. /**
  56629. * The scene the component belongs to.
  56630. */
  56631. scene: Scene;
  56632. /**
  56633. * Creates a new instance of the component for the given scene
  56634. * @param scene Defines the scene to register the component in
  56635. */
  56636. constructor(scene: Scene);
  56637. /**
  56638. * Registers the component in a given scene
  56639. */
  56640. register(): void;
  56641. /**
  56642. * Rebuilds the elements related to this component in case of
  56643. * context lost for instance.
  56644. */
  56645. rebuild(): void;
  56646. /**
  56647. * Disposes the component and the associated ressources
  56648. */
  56649. dispose(): void;
  56650. }
  56651. }
  56652. declare module "babylonjs/Physics/physicsHelper" {
  56653. import { Nullable } from "babylonjs/types";
  56654. import { Vector3 } from "babylonjs/Maths/math";
  56655. import { Mesh } from "babylonjs/Meshes/mesh";
  56656. import { Scene } from "babylonjs/scene";
  56657. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56658. /**
  56659. * A helper for physics simulations
  56660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56661. */
  56662. export class PhysicsHelper {
  56663. private _scene;
  56664. private _physicsEngine;
  56665. /**
  56666. * Initializes the Physics helper
  56667. * @param scene Babylon.js scene
  56668. */
  56669. constructor(scene: Scene);
  56670. /**
  56671. * Applies a radial explosion impulse
  56672. * @param origin the origin of the explosion
  56673. * @param radiusOrEventOptions the radius or the options of radial explosion
  56674. * @param strength the explosion strength
  56675. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56676. * @returns A physics radial explosion event, or null
  56677. */
  56678. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56679. /**
  56680. * Applies a radial explosion force
  56681. * @param origin the origin of the explosion
  56682. * @param radiusOrEventOptions the radius or the options of radial explosion
  56683. * @param strength the explosion strength
  56684. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56685. * @returns A physics radial explosion event, or null
  56686. */
  56687. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56688. /**
  56689. * Creates a gravitational field
  56690. * @param origin the origin of the explosion
  56691. * @param radiusOrEventOptions the radius or the options of radial explosion
  56692. * @param strength the explosion strength
  56693. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56694. * @returns A physics gravitational field event, or null
  56695. */
  56696. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56697. /**
  56698. * Creates a physics updraft event
  56699. * @param origin the origin of the updraft
  56700. * @param radiusOrEventOptions the radius or the options of the updraft
  56701. * @param strength the strength of the updraft
  56702. * @param height the height of the updraft
  56703. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56704. * @returns A physics updraft event, or null
  56705. */
  56706. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56707. /**
  56708. * Creates a physics vortex event
  56709. * @param origin the of the vortex
  56710. * @param radiusOrEventOptions the radius or the options of the vortex
  56711. * @param strength the strength of the vortex
  56712. * @param height the height of the vortex
  56713. * @returns a Physics vortex event, or null
  56714. * A physics vortex event or null
  56715. */
  56716. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56717. }
  56718. /**
  56719. * Represents a physics radial explosion event
  56720. */
  56721. class PhysicsRadialExplosionEvent {
  56722. private _scene;
  56723. private _options;
  56724. private _sphere;
  56725. private _dataFetched;
  56726. /**
  56727. * Initializes a radial explosioin event
  56728. * @param _scene BabylonJS scene
  56729. * @param _options The options for the vortex event
  56730. */
  56731. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56732. /**
  56733. * Returns the data related to the radial explosion event (sphere).
  56734. * @returns The radial explosion event data
  56735. */
  56736. getData(): PhysicsRadialExplosionEventData;
  56737. /**
  56738. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56739. * @param impostor A physics imposter
  56740. * @param origin the origin of the explosion
  56741. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56742. */
  56743. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56744. /**
  56745. * Triggers affecterd impostors callbacks
  56746. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56747. */
  56748. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56749. /**
  56750. * Disposes the sphere.
  56751. * @param force Specifies if the sphere should be disposed by force
  56752. */
  56753. dispose(force?: boolean): void;
  56754. /*** Helpers ***/
  56755. private _prepareSphere;
  56756. private _intersectsWithSphere;
  56757. }
  56758. /**
  56759. * Represents a gravitational field event
  56760. */
  56761. class PhysicsGravitationalFieldEvent {
  56762. private _physicsHelper;
  56763. private _scene;
  56764. private _origin;
  56765. private _options;
  56766. private _tickCallback;
  56767. private _sphere;
  56768. private _dataFetched;
  56769. /**
  56770. * Initializes the physics gravitational field event
  56771. * @param _physicsHelper A physics helper
  56772. * @param _scene BabylonJS scene
  56773. * @param _origin The origin position of the gravitational field event
  56774. * @param _options The options for the vortex event
  56775. */
  56776. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56777. /**
  56778. * Returns the data related to the gravitational field event (sphere).
  56779. * @returns A gravitational field event
  56780. */
  56781. getData(): PhysicsGravitationalFieldEventData;
  56782. /**
  56783. * Enables the gravitational field.
  56784. */
  56785. enable(): void;
  56786. /**
  56787. * Disables the gravitational field.
  56788. */
  56789. disable(): void;
  56790. /**
  56791. * Disposes the sphere.
  56792. * @param force The force to dispose from the gravitational field event
  56793. */
  56794. dispose(force?: boolean): void;
  56795. private _tick;
  56796. }
  56797. /**
  56798. * Represents a physics updraft event
  56799. */
  56800. class PhysicsUpdraftEvent {
  56801. private _scene;
  56802. private _origin;
  56803. private _options;
  56804. private _physicsEngine;
  56805. private _originTop;
  56806. private _originDirection;
  56807. private _tickCallback;
  56808. private _cylinder;
  56809. private _cylinderPosition;
  56810. private _dataFetched;
  56811. /**
  56812. * Initializes the physics updraft event
  56813. * @param _scene BabylonJS scene
  56814. * @param _origin The origin position of the updraft
  56815. * @param _options The options for the updraft event
  56816. */
  56817. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56818. /**
  56819. * Returns the data related to the updraft event (cylinder).
  56820. * @returns A physics updraft event
  56821. */
  56822. getData(): PhysicsUpdraftEventData;
  56823. /**
  56824. * Enables the updraft.
  56825. */
  56826. enable(): void;
  56827. /**
  56828. * Disables the updraft.
  56829. */
  56830. disable(): void;
  56831. /**
  56832. * Disposes the cylinder.
  56833. * @param force Specifies if the updraft should be disposed by force
  56834. */
  56835. dispose(force?: boolean): void;
  56836. private getImpostorHitData;
  56837. private _tick;
  56838. /*** Helpers ***/
  56839. private _prepareCylinder;
  56840. private _intersectsWithCylinder;
  56841. }
  56842. /**
  56843. * Represents a physics vortex event
  56844. */
  56845. class PhysicsVortexEvent {
  56846. private _scene;
  56847. private _origin;
  56848. private _options;
  56849. private _physicsEngine;
  56850. private _originTop;
  56851. private _tickCallback;
  56852. private _cylinder;
  56853. private _cylinderPosition;
  56854. private _dataFetched;
  56855. /**
  56856. * Initializes the physics vortex event
  56857. * @param _scene The BabylonJS scene
  56858. * @param _origin The origin position of the vortex
  56859. * @param _options The options for the vortex event
  56860. */
  56861. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56862. /**
  56863. * Returns the data related to the vortex event (cylinder).
  56864. * @returns The physics vortex event data
  56865. */
  56866. getData(): PhysicsVortexEventData;
  56867. /**
  56868. * Enables the vortex.
  56869. */
  56870. enable(): void;
  56871. /**
  56872. * Disables the cortex.
  56873. */
  56874. disable(): void;
  56875. /**
  56876. * Disposes the sphere.
  56877. * @param force
  56878. */
  56879. dispose(force?: boolean): void;
  56880. private getImpostorHitData;
  56881. private _tick;
  56882. /*** Helpers ***/
  56883. private _prepareCylinder;
  56884. private _intersectsWithCylinder;
  56885. }
  56886. /**
  56887. * Options fot the radial explosion event
  56888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56889. */
  56890. export class PhysicsRadialExplosionEventOptions {
  56891. /**
  56892. * The radius of the sphere for the radial explosion.
  56893. */
  56894. radius: number;
  56895. /**
  56896. * The strenth of the explosion.
  56897. */
  56898. strength: number;
  56899. /**
  56900. * The strenght of the force in correspondence to the distance of the affected object
  56901. */
  56902. falloff: PhysicsRadialImpulseFalloff;
  56903. /**
  56904. * Sphere options for the radial explosion.
  56905. */
  56906. sphere: {
  56907. segments: number;
  56908. diameter: number;
  56909. };
  56910. /**
  56911. * Sphere options for the radial explosion.
  56912. */
  56913. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56914. }
  56915. /**
  56916. * Options fot the updraft event
  56917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56918. */
  56919. export class PhysicsUpdraftEventOptions {
  56920. /**
  56921. * The radius of the cylinder for the vortex
  56922. */
  56923. radius: number;
  56924. /**
  56925. * The strenth of the updraft.
  56926. */
  56927. strength: number;
  56928. /**
  56929. * The height of the cylinder for the updraft.
  56930. */
  56931. height: number;
  56932. /**
  56933. * The mode for the the updraft.
  56934. */
  56935. updraftMode: PhysicsUpdraftMode;
  56936. }
  56937. /**
  56938. * Options fot the vortex event
  56939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56940. */
  56941. export class PhysicsVortexEventOptions {
  56942. /**
  56943. * The radius of the cylinder for the vortex
  56944. */
  56945. radius: number;
  56946. /**
  56947. * The strenth of the vortex.
  56948. */
  56949. strength: number;
  56950. /**
  56951. * The height of the cylinder for the vortex.
  56952. */
  56953. height: number;
  56954. /**
  56955. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56956. */
  56957. centripetalForceThreshold: number;
  56958. /**
  56959. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56960. */
  56961. centripetalForceMultiplier: number;
  56962. /**
  56963. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56964. */
  56965. centrifugalForceMultiplier: number;
  56966. /**
  56967. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56968. */
  56969. updraftForceMultiplier: number;
  56970. }
  56971. /**
  56972. * The strenght of the force in correspondence to the distance of the affected object
  56973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56974. */
  56975. export enum PhysicsRadialImpulseFalloff {
  56976. /** Defines that impulse is constant in strength across it's whole radius */
  56977. Constant = 0,
  56978. /** Defines that impulse gets weaker if it's further from the origin */
  56979. Linear = 1
  56980. }
  56981. /**
  56982. * The strength of the force in correspondence to the distance of the affected object
  56983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56984. */
  56985. export enum PhysicsUpdraftMode {
  56986. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56987. Center = 0,
  56988. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56989. Perpendicular = 1
  56990. }
  56991. /**
  56992. * Interface for a physics hit data
  56993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56994. */
  56995. export interface PhysicsHitData {
  56996. /**
  56997. * The force applied at the contact point
  56998. */
  56999. force: Vector3;
  57000. /**
  57001. * The contact point
  57002. */
  57003. contactPoint: Vector3;
  57004. /**
  57005. * The distance from the origin to the contact point
  57006. */
  57007. distanceFromOrigin: number;
  57008. }
  57009. /**
  57010. * Interface for radial explosion event data
  57011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57012. */
  57013. export interface PhysicsRadialExplosionEventData {
  57014. /**
  57015. * A sphere used for the radial explosion event
  57016. */
  57017. sphere: Mesh;
  57018. }
  57019. /**
  57020. * Interface for gravitational field event data
  57021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57022. */
  57023. export interface PhysicsGravitationalFieldEventData {
  57024. /**
  57025. * A sphere mesh used for the gravitational field event
  57026. */
  57027. sphere: Mesh;
  57028. }
  57029. /**
  57030. * Interface for updraft event data
  57031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57032. */
  57033. export interface PhysicsUpdraftEventData {
  57034. /**
  57035. * A cylinder used for the updraft event
  57036. */
  57037. cylinder: Mesh;
  57038. }
  57039. /**
  57040. * Interface for vortex event data
  57041. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57042. */
  57043. export interface PhysicsVortexEventData {
  57044. /**
  57045. * A cylinder used for the vortex event
  57046. */
  57047. cylinder: Mesh;
  57048. }
  57049. /**
  57050. * Interface for an affected physics impostor
  57051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57052. */
  57053. export interface PhysicsAffectedImpostorWithData {
  57054. /**
  57055. * The impostor affected by the effect
  57056. */
  57057. impostor: PhysicsImpostor;
  57058. /**
  57059. * The data about the hit/horce from the explosion
  57060. */
  57061. hitData: PhysicsHitData;
  57062. }
  57063. }
  57064. declare module "babylonjs/Physics/Plugins/index" {
  57065. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57066. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57067. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57068. }
  57069. declare module "babylonjs/Physics/index" {
  57070. export * from "babylonjs/Physics/IPhysicsEngine";
  57071. export * from "babylonjs/Physics/physicsEngine";
  57072. export * from "babylonjs/Physics/physicsEngineComponent";
  57073. export * from "babylonjs/Physics/physicsHelper";
  57074. export * from "babylonjs/Physics/physicsImpostor";
  57075. export * from "babylonjs/Physics/physicsJoint";
  57076. export * from "babylonjs/Physics/Plugins/index";
  57077. }
  57078. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57079. /** @hidden */
  57080. export var blackAndWhitePixelShader: {
  57081. name: string;
  57082. shader: string;
  57083. };
  57084. }
  57085. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57087. import { Camera } from "babylonjs/Cameras/camera";
  57088. import { Engine } from "babylonjs/Engines/engine";
  57089. import "babylonjs/Shaders/blackAndWhite.fragment";
  57090. /**
  57091. * Post process used to render in black and white
  57092. */
  57093. export class BlackAndWhitePostProcess extends PostProcess {
  57094. /**
  57095. * Linear about to convert he result to black and white (default: 1)
  57096. */
  57097. degree: number;
  57098. /**
  57099. * Creates a black and white post process
  57100. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57101. * @param name The name of the effect.
  57102. * @param options The required width/height ratio to downsize to before computing the render pass.
  57103. * @param camera The camera to apply the render pass to.
  57104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57105. * @param engine The engine which the post process will be applied. (default: current engine)
  57106. * @param reusable If the post process can be reused on the same frame. (default: false)
  57107. */
  57108. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57109. }
  57110. }
  57111. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57112. import { Nullable } from "babylonjs/types";
  57113. import { Camera } from "babylonjs/Cameras/camera";
  57114. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57115. import { Engine } from "babylonjs/Engines/engine";
  57116. /**
  57117. * This represents a set of one or more post processes in Babylon.
  57118. * A post process can be used to apply a shader to a texture after it is rendered.
  57119. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57120. */
  57121. export class PostProcessRenderEffect {
  57122. private _postProcesses;
  57123. private _getPostProcesses;
  57124. private _singleInstance;
  57125. private _cameras;
  57126. private _indicesForCamera;
  57127. /**
  57128. * Name of the effect
  57129. * @hidden
  57130. */
  57131. _name: string;
  57132. /**
  57133. * Instantiates a post process render effect.
  57134. * A post process can be used to apply a shader to a texture after it is rendered.
  57135. * @param engine The engine the effect is tied to
  57136. * @param name The name of the effect
  57137. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57138. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57139. */
  57140. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57141. /**
  57142. * Checks if all the post processes in the effect are supported.
  57143. */
  57144. readonly isSupported: boolean;
  57145. /**
  57146. * Updates the current state of the effect
  57147. * @hidden
  57148. */
  57149. _update(): void;
  57150. /**
  57151. * Attaches the effect on cameras
  57152. * @param cameras The camera to attach to.
  57153. * @hidden
  57154. */
  57155. _attachCameras(cameras: Camera): void;
  57156. /**
  57157. * Attaches the effect on cameras
  57158. * @param cameras The camera to attach to.
  57159. * @hidden
  57160. */
  57161. _attachCameras(cameras: Camera[]): void;
  57162. /**
  57163. * Detaches the effect on cameras
  57164. * @param cameras The camera to detatch from.
  57165. * @hidden
  57166. */
  57167. _detachCameras(cameras: Camera): void;
  57168. /**
  57169. * Detatches the effect on cameras
  57170. * @param cameras The camera to detatch from.
  57171. * @hidden
  57172. */
  57173. _detachCameras(cameras: Camera[]): void;
  57174. /**
  57175. * Enables the effect on given cameras
  57176. * @param cameras The camera to enable.
  57177. * @hidden
  57178. */
  57179. _enable(cameras: Camera): void;
  57180. /**
  57181. * Enables the effect on given cameras
  57182. * @param cameras The camera to enable.
  57183. * @hidden
  57184. */
  57185. _enable(cameras: Nullable<Camera[]>): void;
  57186. /**
  57187. * Disables the effect on the given cameras
  57188. * @param cameras The camera to disable.
  57189. * @hidden
  57190. */
  57191. _disable(cameras: Camera): void;
  57192. /**
  57193. * Disables the effect on the given cameras
  57194. * @param cameras The camera to disable.
  57195. * @hidden
  57196. */
  57197. _disable(cameras: Nullable<Camera[]>): void;
  57198. /**
  57199. * Gets a list of the post processes contained in the effect.
  57200. * @param camera The camera to get the post processes on.
  57201. * @returns The list of the post processes in the effect.
  57202. */
  57203. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57204. }
  57205. }
  57206. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57208. /** @hidden */
  57209. export var extractHighlightsPixelShader: {
  57210. name: string;
  57211. shader: string;
  57212. };
  57213. }
  57214. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57215. import { Nullable } from "babylonjs/types";
  57216. import { Camera } from "babylonjs/Cameras/camera";
  57217. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57218. import { Engine } from "babylonjs/Engines/engine";
  57219. import "babylonjs/Shaders/extractHighlights.fragment";
  57220. /**
  57221. * 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.
  57222. */
  57223. export class ExtractHighlightsPostProcess extends PostProcess {
  57224. /**
  57225. * The luminance threshold, pixels below this value will be set to black.
  57226. */
  57227. threshold: number;
  57228. /** @hidden */
  57229. _exposure: number;
  57230. /**
  57231. * Post process which has the input texture to be used when performing highlight extraction
  57232. * @hidden
  57233. */
  57234. _inputPostProcess: Nullable<PostProcess>;
  57235. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57236. }
  57237. }
  57238. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57239. /** @hidden */
  57240. export var bloomMergePixelShader: {
  57241. name: string;
  57242. shader: string;
  57243. };
  57244. }
  57245. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57246. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57247. import { Nullable } from "babylonjs/types";
  57248. import { Engine } from "babylonjs/Engines/engine";
  57249. import { Camera } from "babylonjs/Cameras/camera";
  57250. import "babylonjs/Shaders/bloomMerge.fragment";
  57251. /**
  57252. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57253. */
  57254. export class BloomMergePostProcess extends PostProcess {
  57255. /** Weight of the bloom to be added to the original input. */
  57256. weight: number;
  57257. /**
  57258. * Creates a new instance of @see BloomMergePostProcess
  57259. * @param name The name of the effect.
  57260. * @param originalFromInput Post process which's input will be used for the merge.
  57261. * @param blurred Blurred highlights post process which's output will be used.
  57262. * @param weight Weight of the bloom to be added to the original input.
  57263. * @param options The required width/height ratio to downsize to before computing the render pass.
  57264. * @param camera The camera to apply the render pass to.
  57265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57266. * @param engine The engine which the post process will be applied. (default: current engine)
  57267. * @param reusable If the post process can be reused on the same frame. (default: false)
  57268. * @param textureType Type of textures used when performing the post process. (default: 0)
  57269. * @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)
  57270. */
  57271. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57272. /** Weight of the bloom to be added to the original input. */
  57273. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57274. }
  57275. }
  57276. declare module "babylonjs/PostProcesses/bloomEffect" {
  57277. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57278. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57279. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57280. import { Camera } from "babylonjs/Cameras/camera";
  57281. import { Scene } from "babylonjs/scene";
  57282. /**
  57283. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57284. */
  57285. export class BloomEffect extends PostProcessRenderEffect {
  57286. private bloomScale;
  57287. /**
  57288. * @hidden Internal
  57289. */
  57290. _effects: Array<PostProcess>;
  57291. /**
  57292. * @hidden Internal
  57293. */
  57294. _downscale: ExtractHighlightsPostProcess;
  57295. private _blurX;
  57296. private _blurY;
  57297. private _merge;
  57298. /**
  57299. * The luminance threshold to find bright areas of the image to bloom.
  57300. */
  57301. threshold: number;
  57302. /**
  57303. * The strength of the bloom.
  57304. */
  57305. weight: number;
  57306. /**
  57307. * Specifies the size of the bloom blur kernel, relative to the final output size
  57308. */
  57309. kernel: number;
  57310. /**
  57311. * Creates a new instance of @see BloomEffect
  57312. * @param scene The scene the effect belongs to.
  57313. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57314. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57315. * @param bloomWeight The the strength of bloom.
  57316. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57317. * @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)
  57318. */
  57319. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57320. /**
  57321. * Disposes each of the internal effects for a given camera.
  57322. * @param camera The camera to dispose the effect on.
  57323. */
  57324. disposeEffects(camera: Camera): void;
  57325. /**
  57326. * @hidden Internal
  57327. */
  57328. _updateEffects(): void;
  57329. /**
  57330. * Internal
  57331. * @returns if all the contained post processes are ready.
  57332. * @hidden
  57333. */
  57334. _isReady(): boolean;
  57335. }
  57336. }
  57337. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57338. /** @hidden */
  57339. export var chromaticAberrationPixelShader: {
  57340. name: string;
  57341. shader: string;
  57342. };
  57343. }
  57344. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57345. import { Vector2 } from "babylonjs/Maths/math";
  57346. import { Nullable } from "babylonjs/types";
  57347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57348. import { Camera } from "babylonjs/Cameras/camera";
  57349. import { Engine } from "babylonjs/Engines/engine";
  57350. import "babylonjs/Shaders/chromaticAberration.fragment";
  57351. /**
  57352. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57353. */
  57354. export class ChromaticAberrationPostProcess extends PostProcess {
  57355. /**
  57356. * The amount of seperation of rgb channels (default: 30)
  57357. */
  57358. aberrationAmount: number;
  57359. /**
  57360. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57361. */
  57362. radialIntensity: number;
  57363. /**
  57364. * 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))
  57365. */
  57366. direction: Vector2;
  57367. /**
  57368. * 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))
  57369. */
  57370. centerPosition: Vector2;
  57371. /**
  57372. * Creates a new instance ChromaticAberrationPostProcess
  57373. * @param name The name of the effect.
  57374. * @param screenWidth The width of the screen to apply the effect on.
  57375. * @param screenHeight The height of the screen to apply the effect on.
  57376. * @param options The required width/height ratio to downsize to before computing the render pass.
  57377. * @param camera The camera to apply the render pass to.
  57378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57379. * @param engine The engine which the post process will be applied. (default: current engine)
  57380. * @param reusable If the post process can be reused on the same frame. (default: false)
  57381. * @param textureType Type of textures used when performing the post process. (default: 0)
  57382. * @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)
  57383. */
  57384. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57385. }
  57386. }
  57387. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57388. /** @hidden */
  57389. export var circleOfConfusionPixelShader: {
  57390. name: string;
  57391. shader: string;
  57392. };
  57393. }
  57394. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57395. import { Nullable } from "babylonjs/types";
  57396. import { Engine } from "babylonjs/Engines/engine";
  57397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57398. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57399. import { Camera } from "babylonjs/Cameras/camera";
  57400. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57401. /**
  57402. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57403. */
  57404. export class CircleOfConfusionPostProcess extends PostProcess {
  57405. /**
  57406. * 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.
  57407. */
  57408. lensSize: number;
  57409. /**
  57410. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57411. */
  57412. fStop: number;
  57413. /**
  57414. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57415. */
  57416. focusDistance: number;
  57417. /**
  57418. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57419. */
  57420. focalLength: number;
  57421. private _depthTexture;
  57422. /**
  57423. * Creates a new instance CircleOfConfusionPostProcess
  57424. * @param name The name of the effect.
  57425. * @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.
  57426. * @param options The required width/height ratio to downsize to before computing the render pass.
  57427. * @param camera The camera to apply the render pass to.
  57428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57429. * @param engine The engine which the post process will be applied. (default: current engine)
  57430. * @param reusable If the post process can be reused on the same frame. (default: false)
  57431. * @param textureType Type of textures used when performing the post process. (default: 0)
  57432. * @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)
  57433. */
  57434. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57435. /**
  57436. * 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.
  57437. */
  57438. depthTexture: RenderTargetTexture;
  57439. }
  57440. }
  57441. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57442. /** @hidden */
  57443. export var colorCorrectionPixelShader: {
  57444. name: string;
  57445. shader: string;
  57446. };
  57447. }
  57448. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57449. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57450. import { Engine } from "babylonjs/Engines/engine";
  57451. import { Camera } from "babylonjs/Cameras/camera";
  57452. import "babylonjs/Shaders/colorCorrection.fragment";
  57453. /**
  57454. *
  57455. * This post-process allows the modification of rendered colors by using
  57456. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57457. *
  57458. * The object needs to be provided an url to a texture containing the color
  57459. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57460. * Use an image editing software to tweak the LUT to match your needs.
  57461. *
  57462. * For an example of a color LUT, see here:
  57463. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57464. * For explanations on color grading, see here:
  57465. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57466. *
  57467. */
  57468. export class ColorCorrectionPostProcess extends PostProcess {
  57469. private _colorTableTexture;
  57470. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57471. }
  57472. }
  57473. declare module "babylonjs/Shaders/convolution.fragment" {
  57474. /** @hidden */
  57475. export var convolutionPixelShader: {
  57476. name: string;
  57477. shader: string;
  57478. };
  57479. }
  57480. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57482. import { Nullable } from "babylonjs/types";
  57483. import { Camera } from "babylonjs/Cameras/camera";
  57484. import { Engine } from "babylonjs/Engines/engine";
  57485. import "babylonjs/Shaders/convolution.fragment";
  57486. /**
  57487. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57488. * input texture to perform effects such as edge detection or sharpening
  57489. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57490. */
  57491. export class ConvolutionPostProcess extends PostProcess {
  57492. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57493. kernel: number[];
  57494. /**
  57495. * Creates a new instance ConvolutionPostProcess
  57496. * @param name The name of the effect.
  57497. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  57498. * @param options The required width/height ratio to downsize to before computing the render pass.
  57499. * @param camera The camera to apply the render pass to.
  57500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57501. * @param engine The engine which the post process will be applied. (default: current engine)
  57502. * @param reusable If the post process can be reused on the same frame. (default: false)
  57503. * @param textureType Type of textures used when performing the post process. (default: 0)
  57504. */
  57505. constructor(name: string,
  57506. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57507. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57508. /**
  57509. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57510. */
  57511. static EdgeDetect0Kernel: number[];
  57512. /**
  57513. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57514. */
  57515. static EdgeDetect1Kernel: number[];
  57516. /**
  57517. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57518. */
  57519. static EdgeDetect2Kernel: number[];
  57520. /**
  57521. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57522. */
  57523. static SharpenKernel: number[];
  57524. /**
  57525. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57526. */
  57527. static EmbossKernel: number[];
  57528. /**
  57529. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57530. */
  57531. static GaussianKernel: number[];
  57532. }
  57533. }
  57534. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57535. import { Nullable } from "babylonjs/types";
  57536. import { Vector2 } from "babylonjs/Maths/math";
  57537. import { Camera } from "babylonjs/Cameras/camera";
  57538. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57539. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57540. import { Engine } from "babylonjs/Engines/engine";
  57541. import { Scene } from "babylonjs/scene";
  57542. /**
  57543. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57544. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57545. * based on samples that have a large difference in distance than the center pixel.
  57546. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57547. */
  57548. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57549. direction: Vector2;
  57550. /**
  57551. * Creates a new instance CircleOfConfusionPostProcess
  57552. * @param name The name of the effect.
  57553. * @param scene The scene the effect belongs to.
  57554. * @param direction The direction the blur should be applied.
  57555. * @param kernel The size of the kernel used to blur.
  57556. * @param options The required width/height ratio to downsize to before computing the render pass.
  57557. * @param camera The camera to apply the render pass to.
  57558. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57559. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57561. * @param engine The engine which the post process will be applied. (default: current engine)
  57562. * @param reusable If the post process can be reused on the same frame. (default: false)
  57563. * @param textureType Type of textures used when performing the post process. (default: 0)
  57564. * @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)
  57565. */
  57566. 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);
  57567. }
  57568. }
  57569. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57570. /** @hidden */
  57571. export var depthOfFieldMergePixelShader: {
  57572. name: string;
  57573. shader: string;
  57574. };
  57575. }
  57576. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57577. import { Nullable } from "babylonjs/types";
  57578. import { Camera } from "babylonjs/Cameras/camera";
  57579. import { Effect } from "babylonjs/Materials/effect";
  57580. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57581. import { Engine } from "babylonjs/Engines/engine";
  57582. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57583. /**
  57584. * Options to be set when merging outputs from the default pipeline.
  57585. */
  57586. export class DepthOfFieldMergePostProcessOptions {
  57587. /**
  57588. * The original image to merge on top of
  57589. */
  57590. originalFromInput: PostProcess;
  57591. /**
  57592. * Parameters to perform the merge of the depth of field effect
  57593. */
  57594. depthOfField?: {
  57595. circleOfConfusion: PostProcess;
  57596. blurSteps: Array<PostProcess>;
  57597. };
  57598. /**
  57599. * Parameters to perform the merge of bloom effect
  57600. */
  57601. bloom?: {
  57602. blurred: PostProcess;
  57603. weight: number;
  57604. };
  57605. }
  57606. /**
  57607. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57608. */
  57609. export class DepthOfFieldMergePostProcess extends PostProcess {
  57610. private blurSteps;
  57611. /**
  57612. * Creates a new instance of DepthOfFieldMergePostProcess
  57613. * @param name The name of the effect.
  57614. * @param originalFromInput Post process which's input will be used for the merge.
  57615. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57616. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57617. * @param options The required width/height ratio to downsize to before computing the render pass.
  57618. * @param camera The camera to apply the render pass to.
  57619. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57620. * @param engine The engine which the post process will be applied. (default: current engine)
  57621. * @param reusable If the post process can be reused on the same frame. (default: false)
  57622. * @param textureType Type of textures used when performing the post process. (default: 0)
  57623. * @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)
  57624. */
  57625. 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);
  57626. /**
  57627. * Updates the effect with the current post process compile time values and recompiles the shader.
  57628. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57629. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57630. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57631. * @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
  57632. * @param onCompiled Called when the shader has been compiled.
  57633. * @param onError Called if there is an error when compiling a shader.
  57634. */
  57635. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57636. }
  57637. }
  57638. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57639. import { Nullable } from "babylonjs/types";
  57640. import { Camera } from "babylonjs/Cameras/camera";
  57641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57642. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57643. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57644. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57645. import { Scene } from "babylonjs/scene";
  57646. /**
  57647. * Specifies the level of max blur that should be applied when using the depth of field effect
  57648. */
  57649. export enum DepthOfFieldEffectBlurLevel {
  57650. /**
  57651. * Subtle blur
  57652. */
  57653. Low = 0,
  57654. /**
  57655. * Medium blur
  57656. */
  57657. Medium = 1,
  57658. /**
  57659. * Large blur
  57660. */
  57661. High = 2
  57662. }
  57663. /**
  57664. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57665. */
  57666. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57667. private _circleOfConfusion;
  57668. /**
  57669. * @hidden Internal, blurs from high to low
  57670. */
  57671. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57672. private _depthOfFieldBlurY;
  57673. private _dofMerge;
  57674. /**
  57675. * @hidden Internal post processes in depth of field effect
  57676. */
  57677. _effects: Array<PostProcess>;
  57678. /**
  57679. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57680. */
  57681. focalLength: number;
  57682. /**
  57683. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57684. */
  57685. fStop: number;
  57686. /**
  57687. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57688. */
  57689. focusDistance: number;
  57690. /**
  57691. * 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.
  57692. */
  57693. lensSize: number;
  57694. /**
  57695. * Creates a new instance DepthOfFieldEffect
  57696. * @param scene The scene the effect belongs to.
  57697. * @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.
  57698. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57699. * @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)
  57700. */
  57701. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57702. /**
  57703. * Get the current class name of the current effet
  57704. * @returns "DepthOfFieldEffect"
  57705. */
  57706. getClassName(): string;
  57707. /**
  57708. * 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.
  57709. */
  57710. depthTexture: RenderTargetTexture;
  57711. /**
  57712. * Disposes each of the internal effects for a given camera.
  57713. * @param camera The camera to dispose the effect on.
  57714. */
  57715. disposeEffects(camera: Camera): void;
  57716. /**
  57717. * @hidden Internal
  57718. */
  57719. _updateEffects(): void;
  57720. /**
  57721. * Internal
  57722. * @returns if all the contained post processes are ready.
  57723. * @hidden
  57724. */
  57725. _isReady(): boolean;
  57726. }
  57727. }
  57728. declare module "babylonjs/Shaders/displayPass.fragment" {
  57729. /** @hidden */
  57730. export var displayPassPixelShader: {
  57731. name: string;
  57732. shader: string;
  57733. };
  57734. }
  57735. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57736. import { Nullable } from "babylonjs/types";
  57737. import { Camera } from "babylonjs/Cameras/camera";
  57738. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57739. import { Engine } from "babylonjs/Engines/engine";
  57740. import "babylonjs/Shaders/displayPass.fragment";
  57741. /**
  57742. * DisplayPassPostProcess which produces an output the same as it's input
  57743. */
  57744. export class DisplayPassPostProcess extends PostProcess {
  57745. /**
  57746. * Creates the DisplayPassPostProcess
  57747. * @param name The name of the effect.
  57748. * @param options The required width/height ratio to downsize to before computing the render pass.
  57749. * @param camera The camera to apply the render pass to.
  57750. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57751. * @param engine The engine which the post process will be applied. (default: current engine)
  57752. * @param reusable If the post process can be reused on the same frame. (default: false)
  57753. */
  57754. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57755. }
  57756. }
  57757. declare module "babylonjs/Shaders/filter.fragment" {
  57758. /** @hidden */
  57759. export var filterPixelShader: {
  57760. name: string;
  57761. shader: string;
  57762. };
  57763. }
  57764. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57765. import { Nullable } from "babylonjs/types";
  57766. import { Matrix } from "babylonjs/Maths/math";
  57767. import { Camera } from "babylonjs/Cameras/camera";
  57768. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57769. import { Engine } from "babylonjs/Engines/engine";
  57770. import "babylonjs/Shaders/filter.fragment";
  57771. /**
  57772. * Applies a kernel filter to the image
  57773. */
  57774. export class FilterPostProcess extends PostProcess {
  57775. /** The matrix to be applied to the image */
  57776. kernelMatrix: Matrix;
  57777. /**
  57778. *
  57779. * @param name The name of the effect.
  57780. * @param kernelMatrix The matrix to be applied to the image
  57781. * @param options The required width/height ratio to downsize to before computing the render pass.
  57782. * @param camera The camera to apply the render pass to.
  57783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57784. * @param engine The engine which the post process will be applied. (default: current engine)
  57785. * @param reusable If the post process can be reused on the same frame. (default: false)
  57786. */
  57787. constructor(name: string,
  57788. /** The matrix to be applied to the image */
  57789. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57790. }
  57791. }
  57792. declare module "babylonjs/Shaders/fxaa.fragment" {
  57793. /** @hidden */
  57794. export var fxaaPixelShader: {
  57795. name: string;
  57796. shader: string;
  57797. };
  57798. }
  57799. declare module "babylonjs/Shaders/fxaa.vertex" {
  57800. /** @hidden */
  57801. export var fxaaVertexShader: {
  57802. name: string;
  57803. shader: string;
  57804. };
  57805. }
  57806. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57807. import { Nullable } from "babylonjs/types";
  57808. import { Camera } from "babylonjs/Cameras/camera";
  57809. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57810. import { Engine } from "babylonjs/Engines/engine";
  57811. import "babylonjs/Shaders/fxaa.fragment";
  57812. import "babylonjs/Shaders/fxaa.vertex";
  57813. /**
  57814. * Fxaa post process
  57815. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57816. */
  57817. export class FxaaPostProcess extends PostProcess {
  57818. /** @hidden */
  57819. texelWidth: number;
  57820. /** @hidden */
  57821. texelHeight: number;
  57822. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57823. private _getDefines;
  57824. }
  57825. }
  57826. declare module "babylonjs/Shaders/grain.fragment" {
  57827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57828. /** @hidden */
  57829. export var grainPixelShader: {
  57830. name: string;
  57831. shader: string;
  57832. };
  57833. }
  57834. declare module "babylonjs/PostProcesses/grainPostProcess" {
  57835. import { Nullable } from "babylonjs/types";
  57836. import { Camera } from "babylonjs/Cameras/camera";
  57837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57838. import { Engine } from "babylonjs/Engines/engine";
  57839. import "babylonjs/Shaders/grain.fragment";
  57840. /**
  57841. * The GrainPostProcess adds noise to the image at mid luminance levels
  57842. */
  57843. export class GrainPostProcess extends PostProcess {
  57844. /**
  57845. * The intensity of the grain added (default: 30)
  57846. */
  57847. intensity: number;
  57848. /**
  57849. * If the grain should be randomized on every frame
  57850. */
  57851. animated: boolean;
  57852. /**
  57853. * Creates a new instance of @see GrainPostProcess
  57854. * @param name The name of the effect.
  57855. * @param options The required width/height ratio to downsize to before computing the render pass.
  57856. * @param camera The camera to apply the render pass to.
  57857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57858. * @param engine The engine which the post process will be applied. (default: current engine)
  57859. * @param reusable If the post process can be reused on the same frame. (default: false)
  57860. * @param textureType Type of textures used when performing the post process. (default: 0)
  57861. * @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)
  57862. */
  57863. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57864. }
  57865. }
  57866. declare module "babylonjs/Shaders/highlights.fragment" {
  57867. /** @hidden */
  57868. export var highlightsPixelShader: {
  57869. name: string;
  57870. shader: string;
  57871. };
  57872. }
  57873. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  57874. import { Nullable } from "babylonjs/types";
  57875. import { Camera } from "babylonjs/Cameras/camera";
  57876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57877. import { Engine } from "babylonjs/Engines/engine";
  57878. import "babylonjs/Shaders/highlights.fragment";
  57879. /**
  57880. * Extracts highlights from the image
  57881. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57882. */
  57883. export class HighlightsPostProcess extends PostProcess {
  57884. /**
  57885. * Extracts highlights from the image
  57886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57887. * @param name The name of the effect.
  57888. * @param options The required width/height ratio to downsize to before computing the render pass.
  57889. * @param camera The camera to apply the render pass to.
  57890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57891. * @param engine The engine which the post process will be applied. (default: current engine)
  57892. * @param reusable If the post process can be reused on the same frame. (default: false)
  57893. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57894. */
  57895. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57896. }
  57897. }
  57898. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  57899. /** @hidden */
  57900. export var mrtFragmentDeclaration: {
  57901. name: string;
  57902. shader: string;
  57903. };
  57904. }
  57905. declare module "babylonjs/Shaders/geometry.fragment" {
  57906. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  57907. /** @hidden */
  57908. export var geometryPixelShader: {
  57909. name: string;
  57910. shader: string;
  57911. };
  57912. }
  57913. declare module "babylonjs/Shaders/geometry.vertex" {
  57914. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57915. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57916. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57917. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57918. /** @hidden */
  57919. export var geometryVertexShader: {
  57920. name: string;
  57921. shader: string;
  57922. };
  57923. }
  57924. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  57925. import { Matrix } from "babylonjs/Maths/math";
  57926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57927. import { Mesh } from "babylonjs/Meshes/mesh";
  57928. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  57929. import { Effect } from "babylonjs/Materials/effect";
  57930. import { Scene } from "babylonjs/scene";
  57931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57932. import "babylonjs/Shaders/geometry.fragment";
  57933. import "babylonjs/Shaders/geometry.vertex";
  57934. /** @hidden */
  57935. interface ISavedTransformationMatrix {
  57936. world: Matrix;
  57937. viewProjection: Matrix;
  57938. }
  57939. /**
  57940. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57941. */
  57942. export class GeometryBufferRenderer {
  57943. /**
  57944. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57945. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57946. */
  57947. static readonly POSITION_TEXTURE_TYPE: number;
  57948. /**
  57949. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57950. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57951. */
  57952. static readonly VELOCITY_TEXTURE_TYPE: number;
  57953. /**
  57954. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57955. * in order to compute objects velocities when enableVelocity is set to "true"
  57956. * @hidden
  57957. */
  57958. _previousTransformationMatrices: {
  57959. [index: number]: ISavedTransformationMatrix;
  57960. };
  57961. /**
  57962. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57963. * in order to compute objects velocities when enableVelocity is set to "true"
  57964. * @hidden
  57965. */
  57966. _previousBonesTransformationMatrices: {
  57967. [index: number]: Float32Array;
  57968. };
  57969. /**
  57970. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57971. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57972. */
  57973. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57974. private _scene;
  57975. private _multiRenderTarget;
  57976. private _ratio;
  57977. private _enablePosition;
  57978. private _enableVelocity;
  57979. private _positionIndex;
  57980. private _velocityIndex;
  57981. protected _effect: Effect;
  57982. protected _cachedDefines: string;
  57983. /**
  57984. * Set the render list (meshes to be rendered) used in the G buffer.
  57985. */
  57986. renderList: Mesh[];
  57987. /**
  57988. * Gets wether or not G buffer are supported by the running hardware.
  57989. * This requires draw buffer supports
  57990. */
  57991. readonly isSupported: boolean;
  57992. /**
  57993. * Returns the index of the given texture type in the G-Buffer textures array
  57994. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57995. * @returns the index of the given texture type in the G-Buffer textures array
  57996. */
  57997. getTextureIndex(textureType: number): number;
  57998. /**
  57999. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58000. */
  58001. /**
  58002. * Sets whether or not objects positions are enabled for the G buffer.
  58003. */
  58004. enablePosition: boolean;
  58005. /**
  58006. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58007. */
  58008. /**
  58009. * Sets wether or not objects velocities are enabled for the G buffer.
  58010. */
  58011. enableVelocity: boolean;
  58012. /**
  58013. * Gets the scene associated with the buffer.
  58014. */
  58015. readonly scene: Scene;
  58016. /**
  58017. * Gets the ratio used by the buffer during its creation.
  58018. * How big is the buffer related to the main canvas.
  58019. */
  58020. readonly ratio: number;
  58021. /** @hidden */
  58022. static _SceneComponentInitialization: (scene: Scene) => void;
  58023. /**
  58024. * Creates a new G Buffer for the scene
  58025. * @param scene The scene the buffer belongs to
  58026. * @param ratio How big is the buffer related to the main canvas.
  58027. */
  58028. constructor(scene: Scene, ratio?: number);
  58029. /**
  58030. * Checks wether everything is ready to render a submesh to the G buffer.
  58031. * @param subMesh the submesh to check readiness for
  58032. * @param useInstances is the mesh drawn using instance or not
  58033. * @returns true if ready otherwise false
  58034. */
  58035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58036. /**
  58037. * Gets the current underlying G Buffer.
  58038. * @returns the buffer
  58039. */
  58040. getGBuffer(): MultiRenderTarget;
  58041. /**
  58042. * Gets the number of samples used to render the buffer (anti aliasing).
  58043. */
  58044. /**
  58045. * Sets the number of samples used to render the buffer (anti aliasing).
  58046. */
  58047. samples: number;
  58048. /**
  58049. * Disposes the renderer and frees up associated resources.
  58050. */
  58051. dispose(): void;
  58052. protected _createRenderTargets(): void;
  58053. private _copyBonesTransformationMatrices;
  58054. }
  58055. }
  58056. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58057. import { Nullable } from "babylonjs/types";
  58058. import { Scene } from "babylonjs/scene";
  58059. import { ISceneComponent } from "babylonjs/sceneComponent";
  58060. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58061. module "babylonjs/scene" {
  58062. interface Scene {
  58063. /** @hidden (Backing field) */
  58064. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58065. /**
  58066. * Gets or Sets the current geometry buffer associated to the scene.
  58067. */
  58068. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58069. /**
  58070. * Enables a GeometryBufferRender and associates it with the scene
  58071. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58072. * @returns the GeometryBufferRenderer
  58073. */
  58074. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58075. /**
  58076. * Disables the GeometryBufferRender associated with the scene
  58077. */
  58078. disableGeometryBufferRenderer(): void;
  58079. }
  58080. }
  58081. /**
  58082. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58083. * in several rendering techniques.
  58084. */
  58085. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58086. /**
  58087. * The component name helpful to identify the component in the list of scene components.
  58088. */
  58089. readonly name: string;
  58090. /**
  58091. * The scene the component belongs to.
  58092. */
  58093. scene: Scene;
  58094. /**
  58095. * Creates a new instance of the component for the given scene
  58096. * @param scene Defines the scene to register the component in
  58097. */
  58098. constructor(scene: Scene);
  58099. /**
  58100. * Registers the component in a given scene
  58101. */
  58102. register(): void;
  58103. /**
  58104. * Rebuilds the elements related to this component in case of
  58105. * context lost for instance.
  58106. */
  58107. rebuild(): void;
  58108. /**
  58109. * Disposes the component and the associated ressources
  58110. */
  58111. dispose(): void;
  58112. private _gatherRenderTargets;
  58113. }
  58114. }
  58115. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58116. /** @hidden */
  58117. export var motionBlurPixelShader: {
  58118. name: string;
  58119. shader: string;
  58120. };
  58121. }
  58122. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58123. import { Nullable } from "babylonjs/types";
  58124. import { Camera } from "babylonjs/Cameras/camera";
  58125. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58126. import { Scene } from "babylonjs/scene";
  58127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58128. import "babylonjs/Animations/animatable";
  58129. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58130. import "babylonjs/Shaders/motionBlur.fragment";
  58131. import { Engine } from "babylonjs/Engines/engine";
  58132. /**
  58133. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58134. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58135. * As an example, all you have to do is to create the post-process:
  58136. * var mb = new BABYLON.MotionBlurPostProcess(
  58137. * 'mb', // The name of the effect.
  58138. * scene, // The scene containing the objects to blur according to their velocity.
  58139. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58140. * camera // The camera to apply the render pass to.
  58141. * );
  58142. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58143. */
  58144. export class MotionBlurPostProcess extends PostProcess {
  58145. /**
  58146. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58147. */
  58148. motionStrength: number;
  58149. /**
  58150. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58151. */
  58152. /**
  58153. * Sets the number of iterations to be used for motion blur quality
  58154. */
  58155. motionBlurSamples: number;
  58156. private _motionBlurSamples;
  58157. private _geometryBufferRenderer;
  58158. /**
  58159. * Creates a new instance MotionBlurPostProcess
  58160. * @param name The name of the effect.
  58161. * @param scene The scene containing the objects to blur according to their velocity.
  58162. * @param options The required width/height ratio to downsize to before computing the render pass.
  58163. * @param camera The camera to apply the render pass to.
  58164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58165. * @param engine The engine which the post process will be applied. (default: current engine)
  58166. * @param reusable If the post process can be reused on the same frame. (default: false)
  58167. * @param textureType Type of textures used when performing the post process. (default: 0)
  58168. * @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)
  58169. */
  58170. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58171. /**
  58172. * Excludes the given skinned mesh from computing bones velocities.
  58173. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  58174. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58175. */
  58176. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58177. /**
  58178. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58179. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58180. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58181. */
  58182. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58183. /**
  58184. * Disposes the post process.
  58185. * @param camera The camera to dispose the post process on.
  58186. */
  58187. dispose(camera?: Camera): void;
  58188. }
  58189. }
  58190. declare module "babylonjs/Shaders/refraction.fragment" {
  58191. /** @hidden */
  58192. export var refractionPixelShader: {
  58193. name: string;
  58194. shader: string;
  58195. };
  58196. }
  58197. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58198. import { Color3 } from "babylonjs/Maths/math";
  58199. import { Camera } from "babylonjs/Cameras/camera";
  58200. import { Texture } from "babylonjs/Materials/Textures/texture";
  58201. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58202. import { Engine } from "babylonjs/Engines/engine";
  58203. import "babylonjs/Shaders/refraction.fragment";
  58204. /**
  58205. * Post process which applies a refractin texture
  58206. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58207. */
  58208. export class RefractionPostProcess extends PostProcess {
  58209. /** the base color of the refraction (used to taint the rendering) */
  58210. color: Color3;
  58211. /** simulated refraction depth */
  58212. depth: number;
  58213. /** the coefficient of the base color (0 to remove base color tainting) */
  58214. colorLevel: number;
  58215. private _refTexture;
  58216. private _ownRefractionTexture;
  58217. /**
  58218. * Gets or sets the refraction texture
  58219. * Please note that you are responsible for disposing the texture if you set it manually
  58220. */
  58221. refractionTexture: Texture;
  58222. /**
  58223. * Initializes the RefractionPostProcess
  58224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58225. * @param name The name of the effect.
  58226. * @param refractionTextureUrl Url of the refraction texture to use
  58227. * @param color the base color of the refraction (used to taint the rendering)
  58228. * @param depth simulated refraction depth
  58229. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58230. * @param camera The camera to apply the render pass to.
  58231. * @param options The required width/height ratio to downsize to before computing the render pass.
  58232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58233. * @param engine The engine which the post process will be applied. (default: current engine)
  58234. * @param reusable If the post process can be reused on the same frame. (default: false)
  58235. */
  58236. constructor(name: string, refractionTextureUrl: string,
  58237. /** the base color of the refraction (used to taint the rendering) */
  58238. color: Color3,
  58239. /** simulated refraction depth */
  58240. depth: number,
  58241. /** the coefficient of the base color (0 to remove base color tainting) */
  58242. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58243. /**
  58244. * Disposes of the post process
  58245. * @param camera Camera to dispose post process on
  58246. */
  58247. dispose(camera: Camera): void;
  58248. }
  58249. }
  58250. declare module "babylonjs/Shaders/sharpen.fragment" {
  58251. /** @hidden */
  58252. export var sharpenPixelShader: {
  58253. name: string;
  58254. shader: string;
  58255. };
  58256. }
  58257. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58258. import { Nullable } from "babylonjs/types";
  58259. import { Camera } from "babylonjs/Cameras/camera";
  58260. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58261. import "babylonjs/Shaders/sharpen.fragment";
  58262. import { Engine } from "babylonjs/Engines/engine";
  58263. /**
  58264. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58265. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58266. */
  58267. export class SharpenPostProcess extends PostProcess {
  58268. /**
  58269. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58270. */
  58271. colorAmount: number;
  58272. /**
  58273. * How much sharpness should be applied (default: 0.3)
  58274. */
  58275. edgeAmount: number;
  58276. /**
  58277. * Creates a new instance ConvolutionPostProcess
  58278. * @param name The name of the effect.
  58279. * @param options The required width/height ratio to downsize to before computing the render pass.
  58280. * @param camera The camera to apply the render pass to.
  58281. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58282. * @param engine The engine which the post process will be applied. (default: current engine)
  58283. * @param reusable If the post process can be reused on the same frame. (default: false)
  58284. * @param textureType Type of textures used when performing the post process. (default: 0)
  58285. * @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)
  58286. */
  58287. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58288. }
  58289. }
  58290. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58291. import { Nullable } from "babylonjs/types";
  58292. import { Camera } from "babylonjs/Cameras/camera";
  58293. import { Engine } from "babylonjs/Engines/engine";
  58294. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58295. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58296. /**
  58297. * PostProcessRenderPipeline
  58298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58299. */
  58300. export class PostProcessRenderPipeline {
  58301. private engine;
  58302. private _renderEffects;
  58303. private _renderEffectsForIsolatedPass;
  58304. /**
  58305. * List of inspectable custom properties (used by the Inspector)
  58306. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58307. */
  58308. inspectableCustomProperties: IInspectable[];
  58309. /**
  58310. * @hidden
  58311. */
  58312. protected _cameras: Camera[];
  58313. /** @hidden */
  58314. _name: string;
  58315. /**
  58316. * Gets pipeline name
  58317. */
  58318. readonly name: string;
  58319. /**
  58320. * Initializes a PostProcessRenderPipeline
  58321. * @param engine engine to add the pipeline to
  58322. * @param name name of the pipeline
  58323. */
  58324. constructor(engine: Engine, name: string);
  58325. /**
  58326. * Gets the class name
  58327. * @returns "PostProcessRenderPipeline"
  58328. */
  58329. getClassName(): string;
  58330. /**
  58331. * If all the render effects in the pipeline are supported
  58332. */
  58333. readonly isSupported: boolean;
  58334. /**
  58335. * Adds an effect to the pipeline
  58336. * @param renderEffect the effect to add
  58337. */
  58338. addEffect(renderEffect: PostProcessRenderEffect): void;
  58339. /** @hidden */
  58340. _rebuild(): void;
  58341. /** @hidden */
  58342. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58343. /** @hidden */
  58344. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58345. /** @hidden */
  58346. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58347. /** @hidden */
  58348. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58349. /** @hidden */
  58350. _attachCameras(cameras: Camera, unique: boolean): void;
  58351. /** @hidden */
  58352. _attachCameras(cameras: Camera[], unique: boolean): void;
  58353. /** @hidden */
  58354. _detachCameras(cameras: Camera): void;
  58355. /** @hidden */
  58356. _detachCameras(cameras: Nullable<Camera[]>): void;
  58357. /** @hidden */
  58358. _update(): void;
  58359. /** @hidden */
  58360. _reset(): void;
  58361. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58362. /**
  58363. * Disposes of the pipeline
  58364. */
  58365. dispose(): void;
  58366. }
  58367. }
  58368. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58369. import { Camera } from "babylonjs/Cameras/camera";
  58370. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58371. /**
  58372. * PostProcessRenderPipelineManager class
  58373. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58374. */
  58375. export class PostProcessRenderPipelineManager {
  58376. private _renderPipelines;
  58377. /**
  58378. * Initializes a PostProcessRenderPipelineManager
  58379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58380. */
  58381. constructor();
  58382. /**
  58383. * Gets the list of supported render pipelines
  58384. */
  58385. readonly supportedPipelines: PostProcessRenderPipeline[];
  58386. /**
  58387. * Adds a pipeline to the manager
  58388. * @param renderPipeline The pipeline to add
  58389. */
  58390. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58391. /**
  58392. * Attaches a camera to the pipeline
  58393. * @param renderPipelineName The name of the pipeline to attach to
  58394. * @param cameras the camera to attach
  58395. * @param unique if the camera can be attached multiple times to the pipeline
  58396. */
  58397. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58398. /**
  58399. * Detaches a camera from the pipeline
  58400. * @param renderPipelineName The name of the pipeline to detach from
  58401. * @param cameras the camera to detach
  58402. */
  58403. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58404. /**
  58405. * Enables an effect by name on a pipeline
  58406. * @param renderPipelineName the name of the pipeline to enable the effect in
  58407. * @param renderEffectName the name of the effect to enable
  58408. * @param cameras the cameras that the effect should be enabled on
  58409. */
  58410. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58411. /**
  58412. * Disables an effect by name on a pipeline
  58413. * @param renderPipelineName the name of the pipeline to disable the effect in
  58414. * @param renderEffectName the name of the effect to disable
  58415. * @param cameras the cameras that the effect should be disabled on
  58416. */
  58417. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58418. /**
  58419. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58420. */
  58421. update(): void;
  58422. /** @hidden */
  58423. _rebuild(): void;
  58424. /**
  58425. * Disposes of the manager and pipelines
  58426. */
  58427. dispose(): void;
  58428. }
  58429. }
  58430. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58431. import { ISceneComponent } from "babylonjs/sceneComponent";
  58432. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58433. import { Scene } from "babylonjs/scene";
  58434. module "babylonjs/scene" {
  58435. interface Scene {
  58436. /** @hidden (Backing field) */
  58437. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58438. /**
  58439. * Gets the postprocess render pipeline manager
  58440. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58441. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58442. */
  58443. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58444. }
  58445. }
  58446. /**
  58447. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58448. */
  58449. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58450. /**
  58451. * The component name helpfull to identify the component in the list of scene components.
  58452. */
  58453. readonly name: string;
  58454. /**
  58455. * The scene the component belongs to.
  58456. */
  58457. scene: Scene;
  58458. /**
  58459. * Creates a new instance of the component for the given scene
  58460. * @param scene Defines the scene to register the component in
  58461. */
  58462. constructor(scene: Scene);
  58463. /**
  58464. * Registers the component in a given scene
  58465. */
  58466. register(): void;
  58467. /**
  58468. * Rebuilds the elements related to this component in case of
  58469. * context lost for instance.
  58470. */
  58471. rebuild(): void;
  58472. /**
  58473. * Disposes the component and the associated ressources
  58474. */
  58475. dispose(): void;
  58476. private _gatherRenderTargets;
  58477. }
  58478. }
  58479. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58480. import { Nullable } from "babylonjs/types";
  58481. import { IAnimatable } from "babylonjs/Misc/tools";
  58482. import { Camera } from "babylonjs/Cameras/camera";
  58483. import { IDisposable } from "babylonjs/scene";
  58484. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58485. import { Scene } from "babylonjs/scene";
  58486. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58487. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58488. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58489. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58490. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58491. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58492. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58493. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58494. import { Animation } from "babylonjs/Animations/animation";
  58495. /**
  58496. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58497. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58498. */
  58499. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58500. private _scene;
  58501. private _camerasToBeAttached;
  58502. /**
  58503. * ID of the sharpen post process,
  58504. */
  58505. private readonly SharpenPostProcessId;
  58506. /**
  58507. * @ignore
  58508. * ID of the image processing post process;
  58509. */
  58510. readonly ImageProcessingPostProcessId: string;
  58511. /**
  58512. * @ignore
  58513. * ID of the Fast Approximate Anti-Aliasing post process;
  58514. */
  58515. readonly FxaaPostProcessId: string;
  58516. /**
  58517. * ID of the chromatic aberration post process,
  58518. */
  58519. private readonly ChromaticAberrationPostProcessId;
  58520. /**
  58521. * ID of the grain post process
  58522. */
  58523. private readonly GrainPostProcessId;
  58524. /**
  58525. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58526. */
  58527. sharpen: SharpenPostProcess;
  58528. private _sharpenEffect;
  58529. private bloom;
  58530. /**
  58531. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58532. */
  58533. depthOfField: DepthOfFieldEffect;
  58534. /**
  58535. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58536. */
  58537. fxaa: FxaaPostProcess;
  58538. /**
  58539. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58540. */
  58541. imageProcessing: ImageProcessingPostProcess;
  58542. /**
  58543. * Chromatic aberration post process which will shift rgb colors in the image
  58544. */
  58545. chromaticAberration: ChromaticAberrationPostProcess;
  58546. private _chromaticAberrationEffect;
  58547. /**
  58548. * Grain post process which add noise to the image
  58549. */
  58550. grain: GrainPostProcess;
  58551. private _grainEffect;
  58552. /**
  58553. * Glow post process which adds a glow to emissive areas of the image
  58554. */
  58555. private _glowLayer;
  58556. /**
  58557. * Animations which can be used to tweak settings over a period of time
  58558. */
  58559. animations: Animation[];
  58560. private _imageProcessingConfigurationObserver;
  58561. private _sharpenEnabled;
  58562. private _bloomEnabled;
  58563. private _depthOfFieldEnabled;
  58564. private _depthOfFieldBlurLevel;
  58565. private _fxaaEnabled;
  58566. private _imageProcessingEnabled;
  58567. private _defaultPipelineTextureType;
  58568. private _bloomScale;
  58569. private _chromaticAberrationEnabled;
  58570. private _grainEnabled;
  58571. private _buildAllowed;
  58572. /**
  58573. * Gets active scene
  58574. */
  58575. readonly scene: Scene;
  58576. /**
  58577. * Enable or disable the sharpen process from the pipeline
  58578. */
  58579. sharpenEnabled: boolean;
  58580. private _resizeObserver;
  58581. private _hardwareScaleLevel;
  58582. private _bloomKernel;
  58583. /**
  58584. * Specifies the size of the bloom blur kernel, relative to the final output size
  58585. */
  58586. bloomKernel: number;
  58587. /**
  58588. * Specifies the weight of the bloom in the final rendering
  58589. */
  58590. private _bloomWeight;
  58591. /**
  58592. * Specifies the luma threshold for the area that will be blurred by the bloom
  58593. */
  58594. private _bloomThreshold;
  58595. private _hdr;
  58596. /**
  58597. * The strength of the bloom.
  58598. */
  58599. bloomWeight: number;
  58600. /**
  58601. * The strength of the bloom.
  58602. */
  58603. bloomThreshold: number;
  58604. /**
  58605. * The scale of the bloom, lower value will provide better performance.
  58606. */
  58607. bloomScale: number;
  58608. /**
  58609. * Enable or disable the bloom from the pipeline
  58610. */
  58611. bloomEnabled: boolean;
  58612. private _rebuildBloom;
  58613. /**
  58614. * If the depth of field is enabled.
  58615. */
  58616. depthOfFieldEnabled: boolean;
  58617. /**
  58618. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58619. */
  58620. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58621. /**
  58622. * If the anti aliasing is enabled.
  58623. */
  58624. fxaaEnabled: boolean;
  58625. private _samples;
  58626. /**
  58627. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58628. */
  58629. samples: number;
  58630. /**
  58631. * If image processing is enabled.
  58632. */
  58633. imageProcessingEnabled: boolean;
  58634. /**
  58635. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58636. */
  58637. glowLayerEnabled: boolean;
  58638. /**
  58639. * Gets the glow layer (or null if not defined)
  58640. */
  58641. readonly glowLayer: Nullable<GlowLayer>;
  58642. /**
  58643. * Enable or disable the chromaticAberration process from the pipeline
  58644. */
  58645. chromaticAberrationEnabled: boolean;
  58646. /**
  58647. * Enable or disable the grain process from the pipeline
  58648. */
  58649. grainEnabled: boolean;
  58650. /**
  58651. * @constructor
  58652. * @param name - The rendering pipeline name (default: "")
  58653. * @param hdr - If high dynamic range textures should be used (default: true)
  58654. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58655. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58656. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58657. */
  58658. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58659. /**
  58660. * Get the class name
  58661. * @returns "DefaultRenderingPipeline"
  58662. */
  58663. getClassName(): string;
  58664. /**
  58665. * Force the compilation of the entire pipeline.
  58666. */
  58667. prepare(): void;
  58668. private _hasCleared;
  58669. private _prevPostProcess;
  58670. private _prevPrevPostProcess;
  58671. private _setAutoClearAndTextureSharing;
  58672. private _depthOfFieldSceneObserver;
  58673. private _buildPipeline;
  58674. private _disposePostProcesses;
  58675. /**
  58676. * Adds a camera to the pipeline
  58677. * @param camera the camera to be added
  58678. */
  58679. addCamera(camera: Camera): void;
  58680. /**
  58681. * Removes a camera from the pipeline
  58682. * @param camera the camera to remove
  58683. */
  58684. removeCamera(camera: Camera): void;
  58685. /**
  58686. * Dispose of the pipeline and stop all post processes
  58687. */
  58688. dispose(): void;
  58689. /**
  58690. * Serialize the rendering pipeline (Used when exporting)
  58691. * @returns the serialized object
  58692. */
  58693. serialize(): any;
  58694. /**
  58695. * Parse the serialized pipeline
  58696. * @param source Source pipeline.
  58697. * @param scene The scene to load the pipeline to.
  58698. * @param rootUrl The URL of the serialized pipeline.
  58699. * @returns An instantiated pipeline from the serialized object.
  58700. */
  58701. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58702. }
  58703. }
  58704. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58705. /** @hidden */
  58706. export var lensHighlightsPixelShader: {
  58707. name: string;
  58708. shader: string;
  58709. };
  58710. }
  58711. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58712. /** @hidden */
  58713. export var depthOfFieldPixelShader: {
  58714. name: string;
  58715. shader: string;
  58716. };
  58717. }
  58718. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58719. import { Camera } from "babylonjs/Cameras/camera";
  58720. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58721. import { Scene } from "babylonjs/scene";
  58722. import "babylonjs/Shaders/chromaticAberration.fragment";
  58723. import "babylonjs/Shaders/lensHighlights.fragment";
  58724. import "babylonjs/Shaders/depthOfField.fragment";
  58725. /**
  58726. * BABYLON.JS Chromatic Aberration GLSL Shader
  58727. * Author: Olivier Guyot
  58728. * Separates very slightly R, G and B colors on the edges of the screen
  58729. * Inspired by Francois Tarlier & Martins Upitis
  58730. */
  58731. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58732. /**
  58733. * @ignore
  58734. * The chromatic aberration PostProcess id in the pipeline
  58735. */
  58736. LensChromaticAberrationEffect: string;
  58737. /**
  58738. * @ignore
  58739. * The highlights enhancing PostProcess id in the pipeline
  58740. */
  58741. HighlightsEnhancingEffect: string;
  58742. /**
  58743. * @ignore
  58744. * The depth-of-field PostProcess id in the pipeline
  58745. */
  58746. LensDepthOfFieldEffect: string;
  58747. private _scene;
  58748. private _depthTexture;
  58749. private _grainTexture;
  58750. private _chromaticAberrationPostProcess;
  58751. private _highlightsPostProcess;
  58752. private _depthOfFieldPostProcess;
  58753. private _edgeBlur;
  58754. private _grainAmount;
  58755. private _chromaticAberration;
  58756. private _distortion;
  58757. private _highlightsGain;
  58758. private _highlightsThreshold;
  58759. private _dofDistance;
  58760. private _dofAperture;
  58761. private _dofDarken;
  58762. private _dofPentagon;
  58763. private _blurNoise;
  58764. /**
  58765. * @constructor
  58766. *
  58767. * Effect parameters are as follow:
  58768. * {
  58769. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58770. * edge_blur: number; // from 0 to x (1 for realism)
  58771. * distortion: number; // from 0 to x (1 for realism)
  58772. * grain_amount: number; // from 0 to 1
  58773. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58774. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58775. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58776. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58777. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58778. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58779. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58780. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58781. * }
  58782. * Note: if an effect parameter is unset, effect is disabled
  58783. *
  58784. * @param name The rendering pipeline name
  58785. * @param parameters - An object containing all parameters (see above)
  58786. * @param scene The scene linked to this pipeline
  58787. * @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)
  58788. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58789. */
  58790. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58791. /**
  58792. * Get the class name
  58793. * @returns "LensRenderingPipeline"
  58794. */
  58795. getClassName(): string;
  58796. /**
  58797. * Gets associated scene
  58798. */
  58799. readonly scene: Scene;
  58800. /**
  58801. * Gets or sets the edge blur
  58802. */
  58803. edgeBlur: number;
  58804. /**
  58805. * Gets or sets the grain amount
  58806. */
  58807. grainAmount: number;
  58808. /**
  58809. * Gets or sets the chromatic aberration amount
  58810. */
  58811. chromaticAberration: number;
  58812. /**
  58813. * Gets or sets the depth of field aperture
  58814. */
  58815. dofAperture: number;
  58816. /**
  58817. * Gets or sets the edge distortion
  58818. */
  58819. edgeDistortion: number;
  58820. /**
  58821. * Gets or sets the depth of field distortion
  58822. */
  58823. dofDistortion: number;
  58824. /**
  58825. * Gets or sets the darken out of focus amount
  58826. */
  58827. darkenOutOfFocus: number;
  58828. /**
  58829. * Gets or sets a boolean indicating if blur noise is enabled
  58830. */
  58831. blurNoise: boolean;
  58832. /**
  58833. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58834. */
  58835. pentagonBokeh: boolean;
  58836. /**
  58837. * Gets or sets the highlight grain amount
  58838. */
  58839. highlightsGain: number;
  58840. /**
  58841. * Gets or sets the highlight threshold
  58842. */
  58843. highlightsThreshold: number;
  58844. /**
  58845. * Sets the amount of blur at the edges
  58846. * @param amount blur amount
  58847. */
  58848. setEdgeBlur(amount: number): void;
  58849. /**
  58850. * Sets edge blur to 0
  58851. */
  58852. disableEdgeBlur(): void;
  58853. /**
  58854. * Sets the amout of grain
  58855. * @param amount Amount of grain
  58856. */
  58857. setGrainAmount(amount: number): void;
  58858. /**
  58859. * Set grain amount to 0
  58860. */
  58861. disableGrain(): void;
  58862. /**
  58863. * Sets the chromatic aberration amount
  58864. * @param amount amount of chromatic aberration
  58865. */
  58866. setChromaticAberration(amount: number): void;
  58867. /**
  58868. * Sets chromatic aberration amount to 0
  58869. */
  58870. disableChromaticAberration(): void;
  58871. /**
  58872. * Sets the EdgeDistortion amount
  58873. * @param amount amount of EdgeDistortion
  58874. */
  58875. setEdgeDistortion(amount: number): void;
  58876. /**
  58877. * Sets edge distortion to 0
  58878. */
  58879. disableEdgeDistortion(): void;
  58880. /**
  58881. * Sets the FocusDistance amount
  58882. * @param amount amount of FocusDistance
  58883. */
  58884. setFocusDistance(amount: number): void;
  58885. /**
  58886. * Disables depth of field
  58887. */
  58888. disableDepthOfField(): void;
  58889. /**
  58890. * Sets the Aperture amount
  58891. * @param amount amount of Aperture
  58892. */
  58893. setAperture(amount: number): void;
  58894. /**
  58895. * Sets the DarkenOutOfFocus amount
  58896. * @param amount amount of DarkenOutOfFocus
  58897. */
  58898. setDarkenOutOfFocus(amount: number): void;
  58899. private _pentagonBokehIsEnabled;
  58900. /**
  58901. * Creates a pentagon bokeh effect
  58902. */
  58903. enablePentagonBokeh(): void;
  58904. /**
  58905. * Disables the pentagon bokeh effect
  58906. */
  58907. disablePentagonBokeh(): void;
  58908. /**
  58909. * Enables noise blur
  58910. */
  58911. enableNoiseBlur(): void;
  58912. /**
  58913. * Disables noise blur
  58914. */
  58915. disableNoiseBlur(): void;
  58916. /**
  58917. * Sets the HighlightsGain amount
  58918. * @param amount amount of HighlightsGain
  58919. */
  58920. setHighlightsGain(amount: number): void;
  58921. /**
  58922. * Sets the HighlightsThreshold amount
  58923. * @param amount amount of HighlightsThreshold
  58924. */
  58925. setHighlightsThreshold(amount: number): void;
  58926. /**
  58927. * Disables highlights
  58928. */
  58929. disableHighlights(): void;
  58930. /**
  58931. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58932. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58933. */
  58934. dispose(disableDepthRender?: boolean): void;
  58935. private _createChromaticAberrationPostProcess;
  58936. private _createHighlightsPostProcess;
  58937. private _createDepthOfFieldPostProcess;
  58938. private _createGrainTexture;
  58939. }
  58940. }
  58941. declare module "babylonjs/Shaders/ssao2.fragment" {
  58942. /** @hidden */
  58943. export var ssao2PixelShader: {
  58944. name: string;
  58945. shader: string;
  58946. };
  58947. }
  58948. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  58949. /** @hidden */
  58950. export var ssaoCombinePixelShader: {
  58951. name: string;
  58952. shader: string;
  58953. };
  58954. }
  58955. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  58956. import { Camera } from "babylonjs/Cameras/camera";
  58957. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58958. import { Scene } from "babylonjs/scene";
  58959. import "babylonjs/Shaders/ssao2.fragment";
  58960. import "babylonjs/Shaders/ssaoCombine.fragment";
  58961. /**
  58962. * Render pipeline to produce ssao effect
  58963. */
  58964. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58965. /**
  58966. * @ignore
  58967. * The PassPostProcess id in the pipeline that contains the original scene color
  58968. */
  58969. SSAOOriginalSceneColorEffect: string;
  58970. /**
  58971. * @ignore
  58972. * The SSAO PostProcess id in the pipeline
  58973. */
  58974. SSAORenderEffect: string;
  58975. /**
  58976. * @ignore
  58977. * The horizontal blur PostProcess id in the pipeline
  58978. */
  58979. SSAOBlurHRenderEffect: string;
  58980. /**
  58981. * @ignore
  58982. * The vertical blur PostProcess id in the pipeline
  58983. */
  58984. SSAOBlurVRenderEffect: string;
  58985. /**
  58986. * @ignore
  58987. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58988. */
  58989. SSAOCombineRenderEffect: string;
  58990. /**
  58991. * The output strength of the SSAO post-process. Default value is 1.0.
  58992. */
  58993. totalStrength: number;
  58994. /**
  58995. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58996. */
  58997. maxZ: number;
  58998. /**
  58999. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59000. */
  59001. minZAspect: number;
  59002. private _samples;
  59003. /**
  59004. * Number of samples used for the SSAO calculations. Default value is 8
  59005. */
  59006. samples: number;
  59007. private _textureSamples;
  59008. /**
  59009. * Number of samples to use for antialiasing
  59010. */
  59011. textureSamples: number;
  59012. /**
  59013. * Ratio object used for SSAO ratio and blur ratio
  59014. */
  59015. private _ratio;
  59016. /**
  59017. * Dynamically generated sphere sampler.
  59018. */
  59019. private _sampleSphere;
  59020. /**
  59021. * Blur filter offsets
  59022. */
  59023. private _samplerOffsets;
  59024. private _expensiveBlur;
  59025. /**
  59026. * If bilateral blur should be used
  59027. */
  59028. expensiveBlur: boolean;
  59029. /**
  59030. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59031. */
  59032. radius: number;
  59033. /**
  59034. * The base color of the SSAO post-process
  59035. * The final result is "base + ssao" between [0, 1]
  59036. */
  59037. base: number;
  59038. /**
  59039. * Support test.
  59040. */
  59041. static readonly IsSupported: boolean;
  59042. private _scene;
  59043. private _depthTexture;
  59044. private _normalTexture;
  59045. private _randomTexture;
  59046. private _originalColorPostProcess;
  59047. private _ssaoPostProcess;
  59048. private _blurHPostProcess;
  59049. private _blurVPostProcess;
  59050. private _ssaoCombinePostProcess;
  59051. private _firstUpdate;
  59052. /**
  59053. * Gets active scene
  59054. */
  59055. readonly scene: Scene;
  59056. /**
  59057. * @constructor
  59058. * @param name The rendering pipeline name
  59059. * @param scene The scene linked to this pipeline
  59060. * @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 }
  59061. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59062. */
  59063. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59064. /**
  59065. * Get the class name
  59066. * @returns "SSAO2RenderingPipeline"
  59067. */
  59068. getClassName(): string;
  59069. /**
  59070. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59071. */
  59072. dispose(disableGeometryBufferRenderer?: boolean): void;
  59073. private _createBlurPostProcess;
  59074. /** @hidden */
  59075. _rebuild(): void;
  59076. private _bits;
  59077. private _radicalInverse_VdC;
  59078. private _hammersley;
  59079. private _hemisphereSample_uniform;
  59080. private _generateHemisphere;
  59081. private _createSSAOPostProcess;
  59082. private _createSSAOCombinePostProcess;
  59083. private _createRandomTexture;
  59084. /**
  59085. * Serialize the rendering pipeline (Used when exporting)
  59086. * @returns the serialized object
  59087. */
  59088. serialize(): any;
  59089. /**
  59090. * Parse the serialized pipeline
  59091. * @param source Source pipeline.
  59092. * @param scene The scene to load the pipeline to.
  59093. * @param rootUrl The URL of the serialized pipeline.
  59094. * @returns An instantiated pipeline from the serialized object.
  59095. */
  59096. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59097. }
  59098. }
  59099. declare module "babylonjs/Shaders/ssao.fragment" {
  59100. /** @hidden */
  59101. export var ssaoPixelShader: {
  59102. name: string;
  59103. shader: string;
  59104. };
  59105. }
  59106. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59107. import { Camera } from "babylonjs/Cameras/camera";
  59108. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59109. import { Scene } from "babylonjs/scene";
  59110. import "babylonjs/Shaders/ssao.fragment";
  59111. import "babylonjs/Shaders/ssaoCombine.fragment";
  59112. /**
  59113. * Render pipeline to produce ssao effect
  59114. */
  59115. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59116. /**
  59117. * @ignore
  59118. * The PassPostProcess id in the pipeline that contains the original scene color
  59119. */
  59120. SSAOOriginalSceneColorEffect: string;
  59121. /**
  59122. * @ignore
  59123. * The SSAO PostProcess id in the pipeline
  59124. */
  59125. SSAORenderEffect: string;
  59126. /**
  59127. * @ignore
  59128. * The horizontal blur PostProcess id in the pipeline
  59129. */
  59130. SSAOBlurHRenderEffect: string;
  59131. /**
  59132. * @ignore
  59133. * The vertical blur PostProcess id in the pipeline
  59134. */
  59135. SSAOBlurVRenderEffect: string;
  59136. /**
  59137. * @ignore
  59138. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59139. */
  59140. SSAOCombineRenderEffect: string;
  59141. /**
  59142. * The output strength of the SSAO post-process. Default value is 1.0.
  59143. */
  59144. totalStrength: number;
  59145. /**
  59146. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59147. */
  59148. radius: number;
  59149. /**
  59150. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59151. * Must not be equal to fallOff and superior to fallOff.
  59152. * Default value is 0.0075
  59153. */
  59154. area: number;
  59155. /**
  59156. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59157. * Must not be equal to area and inferior to area.
  59158. * Default value is 0.000001
  59159. */
  59160. fallOff: number;
  59161. /**
  59162. * The base color of the SSAO post-process
  59163. * The final result is "base + ssao" between [0, 1]
  59164. */
  59165. base: number;
  59166. private _scene;
  59167. private _depthTexture;
  59168. private _randomTexture;
  59169. private _originalColorPostProcess;
  59170. private _ssaoPostProcess;
  59171. private _blurHPostProcess;
  59172. private _blurVPostProcess;
  59173. private _ssaoCombinePostProcess;
  59174. private _firstUpdate;
  59175. /**
  59176. * Gets active scene
  59177. */
  59178. readonly scene: Scene;
  59179. /**
  59180. * @constructor
  59181. * @param name - The rendering pipeline name
  59182. * @param scene - The scene linked to this pipeline
  59183. * @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 }
  59184. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59185. */
  59186. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59187. /**
  59188. * Get the class name
  59189. * @returns "SSAORenderingPipeline"
  59190. */
  59191. getClassName(): string;
  59192. /**
  59193. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59194. */
  59195. dispose(disableDepthRender?: boolean): void;
  59196. private _createBlurPostProcess;
  59197. /** @hidden */
  59198. _rebuild(): void;
  59199. private _createSSAOPostProcess;
  59200. private _createSSAOCombinePostProcess;
  59201. private _createRandomTexture;
  59202. }
  59203. }
  59204. declare module "babylonjs/Shaders/standard.fragment" {
  59205. /** @hidden */
  59206. export var standardPixelShader: {
  59207. name: string;
  59208. shader: string;
  59209. };
  59210. }
  59211. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59212. import { Nullable } from "babylonjs/types";
  59213. import { IAnimatable } from "babylonjs/Misc/tools";
  59214. import { Camera } from "babylonjs/Cameras/camera";
  59215. import { Texture } from "babylonjs/Materials/Textures/texture";
  59216. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59217. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59218. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59219. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59220. import { IDisposable } from "babylonjs/scene";
  59221. import { SpotLight } from "babylonjs/Lights/spotLight";
  59222. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59223. import { Scene } from "babylonjs/scene";
  59224. import { Animation } from "babylonjs/Animations/animation";
  59225. import "babylonjs/Shaders/standard.fragment";
  59226. /**
  59227. * Standard rendering pipeline
  59228. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59229. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59230. */
  59231. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59232. /**
  59233. * Public members
  59234. */
  59235. /**
  59236. * Post-process which contains the original scene color before the pipeline applies all the effects
  59237. */
  59238. originalPostProcess: Nullable<PostProcess>;
  59239. /**
  59240. * Post-process used to down scale an image x4
  59241. */
  59242. downSampleX4PostProcess: Nullable<PostProcess>;
  59243. /**
  59244. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59245. */
  59246. brightPassPostProcess: Nullable<PostProcess>;
  59247. /**
  59248. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59249. */
  59250. blurHPostProcesses: PostProcess[];
  59251. /**
  59252. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59253. */
  59254. blurVPostProcesses: PostProcess[];
  59255. /**
  59256. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59257. */
  59258. textureAdderPostProcess: Nullable<PostProcess>;
  59259. /**
  59260. * Post-process used to create volumetric lighting effect
  59261. */
  59262. volumetricLightPostProcess: Nullable<PostProcess>;
  59263. /**
  59264. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59265. */
  59266. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59267. /**
  59268. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59269. */
  59270. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59271. /**
  59272. * Post-process used to merge the volumetric light effect and the real scene color
  59273. */
  59274. volumetricLightMergePostProces: Nullable<PostProcess>;
  59275. /**
  59276. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59277. */
  59278. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59279. /**
  59280. * Base post-process used to calculate the average luminance of the final image for HDR
  59281. */
  59282. luminancePostProcess: Nullable<PostProcess>;
  59283. /**
  59284. * Post-processes used to create down sample post-processes in order to get
  59285. * the average luminance of the final image for HDR
  59286. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59287. */
  59288. luminanceDownSamplePostProcesses: PostProcess[];
  59289. /**
  59290. * Post-process used to create a HDR effect (light adaptation)
  59291. */
  59292. hdrPostProcess: Nullable<PostProcess>;
  59293. /**
  59294. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59295. */
  59296. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59297. /**
  59298. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59299. */
  59300. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59301. /**
  59302. * Post-process used to merge the final HDR post-process and the real scene color
  59303. */
  59304. hdrFinalPostProcess: Nullable<PostProcess>;
  59305. /**
  59306. * Post-process used to create a lens flare effect
  59307. */
  59308. lensFlarePostProcess: Nullable<PostProcess>;
  59309. /**
  59310. * Post-process that merges the result of the lens flare post-process and the real scene color
  59311. */
  59312. lensFlareComposePostProcess: Nullable<PostProcess>;
  59313. /**
  59314. * Post-process used to create a motion blur effect
  59315. */
  59316. motionBlurPostProcess: Nullable<PostProcess>;
  59317. /**
  59318. * Post-process used to create a depth of field effect
  59319. */
  59320. depthOfFieldPostProcess: Nullable<PostProcess>;
  59321. /**
  59322. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59323. */
  59324. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59325. /**
  59326. * Represents the brightness threshold in order to configure the illuminated surfaces
  59327. */
  59328. brightThreshold: number;
  59329. /**
  59330. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59331. */
  59332. blurWidth: number;
  59333. /**
  59334. * Sets if the blur for highlighted surfaces must be only horizontal
  59335. */
  59336. horizontalBlur: boolean;
  59337. /**
  59338. * Gets the overall exposure used by the pipeline
  59339. */
  59340. /**
  59341. * Sets the overall exposure used by the pipeline
  59342. */
  59343. exposure: number;
  59344. /**
  59345. * Texture used typically to simulate "dirty" on camera lens
  59346. */
  59347. lensTexture: Nullable<Texture>;
  59348. /**
  59349. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59350. */
  59351. volumetricLightCoefficient: number;
  59352. /**
  59353. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59354. */
  59355. volumetricLightPower: number;
  59356. /**
  59357. * Used the set the blur intensity to smooth the volumetric lights
  59358. */
  59359. volumetricLightBlurScale: number;
  59360. /**
  59361. * Light (spot or directional) used to generate the volumetric lights rays
  59362. * The source light must have a shadow generate so the pipeline can get its
  59363. * depth map
  59364. */
  59365. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59366. /**
  59367. * For eye adaptation, represents the minimum luminance the eye can see
  59368. */
  59369. hdrMinimumLuminance: number;
  59370. /**
  59371. * For eye adaptation, represents the decrease luminance speed
  59372. */
  59373. hdrDecreaseRate: number;
  59374. /**
  59375. * For eye adaptation, represents the increase luminance speed
  59376. */
  59377. hdrIncreaseRate: number;
  59378. /**
  59379. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59380. */
  59381. /**
  59382. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59383. */
  59384. hdrAutoExposure: boolean;
  59385. /**
  59386. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59387. */
  59388. lensColorTexture: Nullable<Texture>;
  59389. /**
  59390. * The overall strengh for the lens flare effect
  59391. */
  59392. lensFlareStrength: number;
  59393. /**
  59394. * Dispersion coefficient for lens flare ghosts
  59395. */
  59396. lensFlareGhostDispersal: number;
  59397. /**
  59398. * Main lens flare halo width
  59399. */
  59400. lensFlareHaloWidth: number;
  59401. /**
  59402. * Based on the lens distortion effect, defines how much the lens flare result
  59403. * is distorted
  59404. */
  59405. lensFlareDistortionStrength: number;
  59406. /**
  59407. * Lens star texture must be used to simulate rays on the flares and is available
  59408. * in the documentation
  59409. */
  59410. lensStarTexture: Nullable<Texture>;
  59411. /**
  59412. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59413. * flare effect by taking account of the dirt texture
  59414. */
  59415. lensFlareDirtTexture: Nullable<Texture>;
  59416. /**
  59417. * Represents the focal length for the depth of field effect
  59418. */
  59419. depthOfFieldDistance: number;
  59420. /**
  59421. * Represents the blur intensity for the blurred part of the depth of field effect
  59422. */
  59423. depthOfFieldBlurWidth: number;
  59424. /**
  59425. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59426. */
  59427. /**
  59428. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59429. */
  59430. motionStrength: number;
  59431. /**
  59432. * Gets wether or not the motion blur post-process is object based or screen based.
  59433. */
  59434. /**
  59435. * Sets wether or not the motion blur post-process should be object based or screen based
  59436. */
  59437. objectBasedMotionBlur: boolean;
  59438. /**
  59439. * List of animations for the pipeline (IAnimatable implementation)
  59440. */
  59441. animations: Animation[];
  59442. /**
  59443. * Private members
  59444. */
  59445. private _scene;
  59446. private _currentDepthOfFieldSource;
  59447. private _basePostProcess;
  59448. private _fixedExposure;
  59449. private _currentExposure;
  59450. private _hdrAutoExposure;
  59451. private _hdrCurrentLuminance;
  59452. private _motionStrength;
  59453. private _isObjectBasedMotionBlur;
  59454. private _floatTextureType;
  59455. private _ratio;
  59456. private _bloomEnabled;
  59457. private _depthOfFieldEnabled;
  59458. private _vlsEnabled;
  59459. private _lensFlareEnabled;
  59460. private _hdrEnabled;
  59461. private _motionBlurEnabled;
  59462. private _fxaaEnabled;
  59463. private _motionBlurSamples;
  59464. private _volumetricLightStepsCount;
  59465. private _samples;
  59466. /**
  59467. * @ignore
  59468. * Specifies if the bloom pipeline is enabled
  59469. */
  59470. BloomEnabled: boolean;
  59471. /**
  59472. * @ignore
  59473. * Specifies if the depth of field pipeline is enabed
  59474. */
  59475. DepthOfFieldEnabled: boolean;
  59476. /**
  59477. * @ignore
  59478. * Specifies if the lens flare pipeline is enabed
  59479. */
  59480. LensFlareEnabled: boolean;
  59481. /**
  59482. * @ignore
  59483. * Specifies if the HDR pipeline is enabled
  59484. */
  59485. HDREnabled: boolean;
  59486. /**
  59487. * @ignore
  59488. * Specifies if the volumetric lights scattering effect is enabled
  59489. */
  59490. VLSEnabled: boolean;
  59491. /**
  59492. * @ignore
  59493. * Specifies if the motion blur effect is enabled
  59494. */
  59495. MotionBlurEnabled: boolean;
  59496. /**
  59497. * Specifies if anti-aliasing is enabled
  59498. */
  59499. fxaaEnabled: boolean;
  59500. /**
  59501. * Specifies the number of steps used to calculate the volumetric lights
  59502. * Typically in interval [50, 200]
  59503. */
  59504. volumetricLightStepsCount: number;
  59505. /**
  59506. * Specifies the number of samples used for the motion blur effect
  59507. * Typically in interval [16, 64]
  59508. */
  59509. motionBlurSamples: number;
  59510. /**
  59511. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59512. */
  59513. samples: number;
  59514. /**
  59515. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59516. * @constructor
  59517. * @param name The rendering pipeline name
  59518. * @param scene The scene linked to this pipeline
  59519. * @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)
  59520. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59521. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59522. */
  59523. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59524. private _buildPipeline;
  59525. private _createDownSampleX4PostProcess;
  59526. private _createBrightPassPostProcess;
  59527. private _createBlurPostProcesses;
  59528. private _createTextureAdderPostProcess;
  59529. private _createVolumetricLightPostProcess;
  59530. private _createLuminancePostProcesses;
  59531. private _createHdrPostProcess;
  59532. private _createLensFlarePostProcess;
  59533. private _createDepthOfFieldPostProcess;
  59534. private _createMotionBlurPostProcess;
  59535. private _getDepthTexture;
  59536. private _disposePostProcesses;
  59537. /**
  59538. * Dispose of the pipeline and stop all post processes
  59539. */
  59540. dispose(): void;
  59541. /**
  59542. * Serialize the rendering pipeline (Used when exporting)
  59543. * @returns the serialized object
  59544. */
  59545. serialize(): any;
  59546. /**
  59547. * Parse the serialized pipeline
  59548. * @param source Source pipeline.
  59549. * @param scene The scene to load the pipeline to.
  59550. * @param rootUrl The URL of the serialized pipeline.
  59551. * @returns An instantiated pipeline from the serialized object.
  59552. */
  59553. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59554. /**
  59555. * Luminance steps
  59556. */
  59557. static LuminanceSteps: number;
  59558. }
  59559. }
  59560. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59561. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59562. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59563. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59564. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59565. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59566. }
  59567. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59569. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59570. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59571. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59572. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59573. }
  59574. declare module "babylonjs/Shaders/tonemap.fragment" {
  59575. /** @hidden */
  59576. export var tonemapPixelShader: {
  59577. name: string;
  59578. shader: string;
  59579. };
  59580. }
  59581. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59582. import { Camera } from "babylonjs/Cameras/camera";
  59583. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59584. import "babylonjs/Shaders/tonemap.fragment";
  59585. import { Engine } from "babylonjs/Engines/engine";
  59586. /** Defines operator used for tonemapping */
  59587. export enum TonemappingOperator {
  59588. /** Hable */
  59589. Hable = 0,
  59590. /** Reinhard */
  59591. Reinhard = 1,
  59592. /** HejiDawson */
  59593. HejiDawson = 2,
  59594. /** Photographic */
  59595. Photographic = 3
  59596. }
  59597. /**
  59598. * Defines a post process to apply tone mapping
  59599. */
  59600. export class TonemapPostProcess extends PostProcess {
  59601. private _operator;
  59602. /** Defines the required exposure adjustement */
  59603. exposureAdjustment: number;
  59604. /**
  59605. * Creates a new TonemapPostProcess
  59606. * @param name defines the name of the postprocess
  59607. * @param _operator defines the operator to use
  59608. * @param exposureAdjustment defines the required exposure adjustement
  59609. * @param camera defines the camera to use (can be null)
  59610. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59611. * @param engine defines the hosting engine (can be ignore if camera is set)
  59612. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59613. */
  59614. constructor(name: string, _operator: TonemappingOperator,
  59615. /** Defines the required exposure adjustement */
  59616. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59617. }
  59618. }
  59619. declare module "babylonjs/Shaders/depth.vertex" {
  59620. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59621. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59622. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59623. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59624. /** @hidden */
  59625. export var depthVertexShader: {
  59626. name: string;
  59627. shader: string;
  59628. };
  59629. }
  59630. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59631. /** @hidden */
  59632. export var volumetricLightScatteringPixelShader: {
  59633. name: string;
  59634. shader: string;
  59635. };
  59636. }
  59637. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59638. /** @hidden */
  59639. export var volumetricLightScatteringPassPixelShader: {
  59640. name: string;
  59641. shader: string;
  59642. };
  59643. }
  59644. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59645. import { Vector3 } from "babylonjs/Maths/math";
  59646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59647. import { Mesh } from "babylonjs/Meshes/mesh";
  59648. import { Camera } from "babylonjs/Cameras/camera";
  59649. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59651. import { Scene } from "babylonjs/scene";
  59652. import "babylonjs/Meshes/Builders/planeBuilder";
  59653. import "babylonjs/Shaders/depth.vertex";
  59654. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59655. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59656. import { Engine } from "babylonjs/Engines/engine";
  59657. /**
  59658. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59659. */
  59660. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59661. private _volumetricLightScatteringPass;
  59662. private _volumetricLightScatteringRTT;
  59663. private _viewPort;
  59664. private _screenCoordinates;
  59665. private _cachedDefines;
  59666. /**
  59667. * If not undefined, the mesh position is computed from the attached node position
  59668. */
  59669. attachedNode: {
  59670. position: Vector3;
  59671. };
  59672. /**
  59673. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59674. */
  59675. customMeshPosition: Vector3;
  59676. /**
  59677. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59678. */
  59679. useCustomMeshPosition: boolean;
  59680. /**
  59681. * If the post-process should inverse the light scattering direction
  59682. */
  59683. invert: boolean;
  59684. /**
  59685. * The internal mesh used by the post-process
  59686. */
  59687. mesh: Mesh;
  59688. /**
  59689. * @hidden
  59690. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59691. */
  59692. useDiffuseColor: boolean;
  59693. /**
  59694. * Array containing the excluded meshes not rendered in the internal pass
  59695. */
  59696. excludedMeshes: AbstractMesh[];
  59697. /**
  59698. * Controls the overall intensity of the post-process
  59699. */
  59700. exposure: number;
  59701. /**
  59702. * Dissipates each sample's contribution in range [0, 1]
  59703. */
  59704. decay: number;
  59705. /**
  59706. * Controls the overall intensity of each sample
  59707. */
  59708. weight: number;
  59709. /**
  59710. * Controls the density of each sample
  59711. */
  59712. density: number;
  59713. /**
  59714. * @constructor
  59715. * @param name The post-process name
  59716. * @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)
  59717. * @param camera The camera that the post-process will be attached to
  59718. * @param mesh The mesh used to create the light scattering
  59719. * @param samples The post-process quality, default 100
  59720. * @param samplingModeThe post-process filtering mode
  59721. * @param engine The babylon engine
  59722. * @param reusable If the post-process is reusable
  59723. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59724. */
  59725. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59726. /**
  59727. * Returns the string "VolumetricLightScatteringPostProcess"
  59728. * @returns "VolumetricLightScatteringPostProcess"
  59729. */
  59730. getClassName(): string;
  59731. private _isReady;
  59732. /**
  59733. * Sets the new light position for light scattering effect
  59734. * @param position The new custom light position
  59735. */
  59736. setCustomMeshPosition(position: Vector3): void;
  59737. /**
  59738. * Returns the light position for light scattering effect
  59739. * @return Vector3 The custom light position
  59740. */
  59741. getCustomMeshPosition(): Vector3;
  59742. /**
  59743. * Disposes the internal assets and detaches the post-process from the camera
  59744. */
  59745. dispose(camera: Camera): void;
  59746. /**
  59747. * Returns the render target texture used by the post-process
  59748. * @return the render target texture used by the post-process
  59749. */
  59750. getPass(): RenderTargetTexture;
  59751. private _meshExcluded;
  59752. private _createPass;
  59753. private _updateMeshScreenCoordinates;
  59754. /**
  59755. * Creates a default mesh for the Volumeric Light Scattering post-process
  59756. * @param name The mesh name
  59757. * @param scene The scene where to create the mesh
  59758. * @return the default mesh
  59759. */
  59760. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59761. }
  59762. }
  59763. declare module "babylonjs/PostProcesses/index" {
  59764. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59765. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59766. export * from "babylonjs/PostProcesses/bloomEffect";
  59767. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59768. export * from "babylonjs/PostProcesses/blurPostProcess";
  59769. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59770. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59771. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59772. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59773. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59774. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59775. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59776. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59777. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59778. export * from "babylonjs/PostProcesses/filterPostProcess";
  59779. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59780. export * from "babylonjs/PostProcesses/grainPostProcess";
  59781. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59782. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59783. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59784. export * from "babylonjs/PostProcesses/passPostProcess";
  59785. export * from "babylonjs/PostProcesses/postProcess";
  59786. export * from "babylonjs/PostProcesses/postProcessManager";
  59787. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59788. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59789. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59790. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59791. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59792. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59793. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59794. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59795. }
  59796. declare module "babylonjs/Probes/index" {
  59797. export * from "babylonjs/Probes/reflectionProbe";
  59798. }
  59799. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59800. import { Scene } from "babylonjs/scene";
  59801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59802. import { Color3 } from "babylonjs/Maths/math";
  59803. import { SmartArray } from "babylonjs/Misc/smartArray";
  59804. import { ISceneComponent } from "babylonjs/sceneComponent";
  59805. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59806. import "babylonjs/Meshes/Builders/boxBuilder";
  59807. import "babylonjs/Shaders/color.fragment";
  59808. import "babylonjs/Shaders/color.vertex";
  59809. module "babylonjs/scene" {
  59810. interface Scene {
  59811. /** @hidden (Backing field) */
  59812. _boundingBoxRenderer: BoundingBoxRenderer;
  59813. /** @hidden (Backing field) */
  59814. _forceShowBoundingBoxes: boolean;
  59815. /**
  59816. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59817. */
  59818. forceShowBoundingBoxes: boolean;
  59819. /**
  59820. * Gets the bounding box renderer associated with the scene
  59821. * @returns a BoundingBoxRenderer
  59822. */
  59823. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59824. }
  59825. }
  59826. module "babylonjs/Meshes/abstractMesh" {
  59827. interface AbstractMesh {
  59828. /** @hidden (Backing field) */
  59829. _showBoundingBox: boolean;
  59830. /**
  59831. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59832. */
  59833. showBoundingBox: boolean;
  59834. }
  59835. }
  59836. /**
  59837. * Component responsible of rendering the bounding box of the meshes in a scene.
  59838. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59839. */
  59840. export class BoundingBoxRenderer implements ISceneComponent {
  59841. /**
  59842. * The component name helpfull to identify the component in the list of scene components.
  59843. */
  59844. readonly name: string;
  59845. /**
  59846. * The scene the component belongs to.
  59847. */
  59848. scene: Scene;
  59849. /**
  59850. * Color of the bounding box lines placed in front of an object
  59851. */
  59852. frontColor: Color3;
  59853. /**
  59854. * Color of the bounding box lines placed behind an object
  59855. */
  59856. backColor: Color3;
  59857. /**
  59858. * Defines if the renderer should show the back lines or not
  59859. */
  59860. showBackLines: boolean;
  59861. /**
  59862. * @hidden
  59863. */
  59864. renderList: SmartArray<BoundingBox>;
  59865. private _colorShader;
  59866. private _vertexBuffers;
  59867. private _indexBuffer;
  59868. private _fillIndexBuffer;
  59869. private _fillIndexData;
  59870. /**
  59871. * Instantiates a new bounding box renderer in a scene.
  59872. * @param scene the scene the renderer renders in
  59873. */
  59874. constructor(scene: Scene);
  59875. /**
  59876. * Registers the component in a given scene
  59877. */
  59878. register(): void;
  59879. private _evaluateSubMesh;
  59880. private _activeMesh;
  59881. private _prepareRessources;
  59882. private _createIndexBuffer;
  59883. /**
  59884. * Rebuilds the elements related to this component in case of
  59885. * context lost for instance.
  59886. */
  59887. rebuild(): void;
  59888. /**
  59889. * @hidden
  59890. */
  59891. reset(): void;
  59892. /**
  59893. * Render the bounding boxes of a specific rendering group
  59894. * @param renderingGroupId defines the rendering group to render
  59895. */
  59896. render(renderingGroupId: number): void;
  59897. /**
  59898. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59899. * @param mesh Define the mesh to render the occlusion bounding box for
  59900. */
  59901. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59902. /**
  59903. * Dispose and release the resources attached to this renderer.
  59904. */
  59905. dispose(): void;
  59906. }
  59907. }
  59908. declare module "babylonjs/Shaders/depth.fragment" {
  59909. /** @hidden */
  59910. export var depthPixelShader: {
  59911. name: string;
  59912. shader: string;
  59913. };
  59914. }
  59915. declare module "babylonjs/Rendering/depthRenderer" {
  59916. import { Nullable } from "babylonjs/types";
  59917. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59918. import { Scene } from "babylonjs/scene";
  59919. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59920. import { Camera } from "babylonjs/Cameras/camera";
  59921. import "babylonjs/Shaders/depth.fragment";
  59922. import "babylonjs/Shaders/depth.vertex";
  59923. /**
  59924. * This represents a depth renderer in Babylon.
  59925. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59926. */
  59927. export class DepthRenderer {
  59928. private _scene;
  59929. private _depthMap;
  59930. private _effect;
  59931. private _cachedDefines;
  59932. private _camera;
  59933. /**
  59934. * Specifiess that the depth renderer will only be used within
  59935. * the camera it is created for.
  59936. * This can help forcing its rendering during the camera processing.
  59937. */
  59938. useOnlyInActiveCamera: boolean;
  59939. /** @hidden */
  59940. static _SceneComponentInitialization: (scene: Scene) => void;
  59941. /**
  59942. * Instantiates a depth renderer
  59943. * @param scene The scene the renderer belongs to
  59944. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59945. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59946. */
  59947. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  59948. /**
  59949. * Creates the depth rendering effect and checks if the effect is ready.
  59950. * @param subMesh The submesh to be used to render the depth map of
  59951. * @param useInstances If multiple world instances should be used
  59952. * @returns if the depth renderer is ready to render the depth map
  59953. */
  59954. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59955. /**
  59956. * Gets the texture which the depth map will be written to.
  59957. * @returns The depth map texture
  59958. */
  59959. getDepthMap(): RenderTargetTexture;
  59960. /**
  59961. * Disposes of the depth renderer.
  59962. */
  59963. dispose(): void;
  59964. }
  59965. }
  59966. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  59967. import { Nullable } from "babylonjs/types";
  59968. import { Scene } from "babylonjs/scene";
  59969. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  59970. import { Camera } from "babylonjs/Cameras/camera";
  59971. import { ISceneComponent } from "babylonjs/sceneComponent";
  59972. module "babylonjs/scene" {
  59973. interface Scene {
  59974. /** @hidden (Backing field) */
  59975. _depthRenderer: {
  59976. [id: string]: DepthRenderer;
  59977. };
  59978. /**
  59979. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59980. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59981. * @returns the created depth renderer
  59982. */
  59983. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  59984. /**
  59985. * Disables a depth renderer for a given camera
  59986. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59987. */
  59988. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59989. }
  59990. }
  59991. /**
  59992. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59993. * in several rendering techniques.
  59994. */
  59995. export class DepthRendererSceneComponent implements ISceneComponent {
  59996. /**
  59997. * The component name helpfull to identify the component in the list of scene components.
  59998. */
  59999. readonly name: string;
  60000. /**
  60001. * The scene the component belongs to.
  60002. */
  60003. scene: Scene;
  60004. /**
  60005. * Creates a new instance of the component for the given scene
  60006. * @param scene Defines the scene to register the component in
  60007. */
  60008. constructor(scene: Scene);
  60009. /**
  60010. * Registers the component in a given scene
  60011. */
  60012. register(): void;
  60013. /**
  60014. * Rebuilds the elements related to this component in case of
  60015. * context lost for instance.
  60016. */
  60017. rebuild(): void;
  60018. /**
  60019. * Disposes the component and the associated ressources
  60020. */
  60021. dispose(): void;
  60022. private _gatherRenderTargets;
  60023. private _gatherActiveCameraRenderTargets;
  60024. }
  60025. }
  60026. declare module "babylonjs/Shaders/outline.fragment" {
  60027. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60028. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60029. /** @hidden */
  60030. export var outlinePixelShader: {
  60031. name: string;
  60032. shader: string;
  60033. };
  60034. }
  60035. declare module "babylonjs/Shaders/outline.vertex" {
  60036. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60037. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60038. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60039. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60040. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60041. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60042. /** @hidden */
  60043. export var outlineVertexShader: {
  60044. name: string;
  60045. shader: string;
  60046. };
  60047. }
  60048. declare module "babylonjs/Rendering/outlineRenderer" {
  60049. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60050. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60051. import { Scene } from "babylonjs/scene";
  60052. import { ISceneComponent } from "babylonjs/sceneComponent";
  60053. import "babylonjs/Shaders/outline.fragment";
  60054. import "babylonjs/Shaders/outline.vertex";
  60055. module "babylonjs/scene" {
  60056. interface Scene {
  60057. /** @hidden */
  60058. _outlineRenderer: OutlineRenderer;
  60059. /**
  60060. * Gets the outline renderer associated with the scene
  60061. * @returns a OutlineRenderer
  60062. */
  60063. getOutlineRenderer(): OutlineRenderer;
  60064. }
  60065. }
  60066. module "babylonjs/Meshes/abstractMesh" {
  60067. interface AbstractMesh {
  60068. /** @hidden (Backing field) */
  60069. _renderOutline: boolean;
  60070. /**
  60071. * Gets or sets a boolean indicating if the outline must be rendered as well
  60072. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60073. */
  60074. renderOutline: boolean;
  60075. /** @hidden (Backing field) */
  60076. _renderOverlay: boolean;
  60077. /**
  60078. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60079. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60080. */
  60081. renderOverlay: boolean;
  60082. }
  60083. }
  60084. /**
  60085. * This class is responsible to draw bothe outline/overlay of meshes.
  60086. * It should not be used directly but through the available method on mesh.
  60087. */
  60088. export class OutlineRenderer implements ISceneComponent {
  60089. /**
  60090. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60091. */
  60092. private static _StencilReference;
  60093. /**
  60094. * The name of the component. Each component must have a unique name.
  60095. */
  60096. name: string;
  60097. /**
  60098. * The scene the component belongs to.
  60099. */
  60100. scene: Scene;
  60101. /**
  60102. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60103. */
  60104. zOffset: number;
  60105. private _engine;
  60106. private _effect;
  60107. private _cachedDefines;
  60108. private _savedDepthWrite;
  60109. /**
  60110. * Instantiates a new outline renderer. (There could be only one per scene).
  60111. * @param scene Defines the scene it belongs to
  60112. */
  60113. constructor(scene: Scene);
  60114. /**
  60115. * Register the component to one instance of a scene.
  60116. */
  60117. register(): void;
  60118. /**
  60119. * Rebuilds the elements related to this component in case of
  60120. * context lost for instance.
  60121. */
  60122. rebuild(): void;
  60123. /**
  60124. * Disposes the component and the associated ressources.
  60125. */
  60126. dispose(): void;
  60127. /**
  60128. * Renders the outline in the canvas.
  60129. * @param subMesh Defines the sumesh to render
  60130. * @param batch Defines the batch of meshes in case of instances
  60131. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60132. */
  60133. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60134. /**
  60135. * Returns whether or not the outline renderer is ready for a given submesh.
  60136. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60137. * @param subMesh Defines the submesh to check readyness for
  60138. * @param useInstances Defines wheter wee are trying to render instances or not
  60139. * @returns true if ready otherwise false
  60140. */
  60141. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60142. private _beforeRenderingMesh;
  60143. private _afterRenderingMesh;
  60144. }
  60145. }
  60146. declare module "babylonjs/Rendering/index" {
  60147. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60148. export * from "babylonjs/Rendering/depthRenderer";
  60149. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60150. export * from "babylonjs/Rendering/edgesRenderer";
  60151. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60152. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60153. export * from "babylonjs/Rendering/outlineRenderer";
  60154. export * from "babylonjs/Rendering/renderingGroup";
  60155. export * from "babylonjs/Rendering/renderingManager";
  60156. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60157. }
  60158. declare module "babylonjs/Sprites/index" {
  60159. export * from "babylonjs/Sprites/sprite";
  60160. export * from "babylonjs/Sprites/spriteManager";
  60161. export * from "babylonjs/Sprites/spriteSceneComponent";
  60162. }
  60163. declare module "babylonjs/Misc/assetsManager" {
  60164. import { Scene } from "babylonjs/scene";
  60165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60167. import { Skeleton } from "babylonjs/Bones/skeleton";
  60168. import { Observable } from "babylonjs/Misc/observable";
  60169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60170. import { Texture } from "babylonjs/Materials/Textures/texture";
  60171. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60172. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60173. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60174. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60175. /**
  60176. * Defines the list of states available for a task inside a AssetsManager
  60177. */
  60178. export enum AssetTaskState {
  60179. /**
  60180. * Initialization
  60181. */
  60182. INIT = 0,
  60183. /**
  60184. * Running
  60185. */
  60186. RUNNING = 1,
  60187. /**
  60188. * Done
  60189. */
  60190. DONE = 2,
  60191. /**
  60192. * Error
  60193. */
  60194. ERROR = 3
  60195. }
  60196. /**
  60197. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60198. */
  60199. export abstract class AbstractAssetTask {
  60200. /**
  60201. * Task name
  60202. */ name: string;
  60203. /**
  60204. * Callback called when the task is successful
  60205. */
  60206. onSuccess: (task: any) => void;
  60207. /**
  60208. * Callback called when the task is not successful
  60209. */
  60210. onError: (task: any, message?: string, exception?: any) => void;
  60211. /**
  60212. * Creates a new AssetsManager
  60213. * @param name defines the name of the task
  60214. */
  60215. constructor(
  60216. /**
  60217. * Task name
  60218. */ name: string);
  60219. private _isCompleted;
  60220. private _taskState;
  60221. private _errorObject;
  60222. /**
  60223. * Get if the task is completed
  60224. */
  60225. readonly isCompleted: boolean;
  60226. /**
  60227. * Gets the current state of the task
  60228. */
  60229. readonly taskState: AssetTaskState;
  60230. /**
  60231. * Gets the current error object (if task is in error)
  60232. */
  60233. readonly errorObject: {
  60234. message?: string;
  60235. exception?: any;
  60236. };
  60237. /**
  60238. * Internal only
  60239. * @hidden
  60240. */
  60241. _setErrorObject(message?: string, exception?: any): void;
  60242. /**
  60243. * Execute the current task
  60244. * @param scene defines the scene where you want your assets to be loaded
  60245. * @param onSuccess is a callback called when the task is successfully executed
  60246. * @param onError is a callback called if an error occurs
  60247. */
  60248. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60249. /**
  60250. * Execute the current task
  60251. * @param scene defines the scene where you want your assets to be loaded
  60252. * @param onSuccess is a callback called when the task is successfully executed
  60253. * @param onError is a callback called if an error occurs
  60254. */
  60255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60256. /**
  60257. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60258. * This can be used with failed tasks that have the reason for failure fixed.
  60259. */
  60260. reset(): void;
  60261. private onErrorCallback;
  60262. private onDoneCallback;
  60263. }
  60264. /**
  60265. * Define the interface used by progress events raised during assets loading
  60266. */
  60267. export interface IAssetsProgressEvent {
  60268. /**
  60269. * Defines the number of remaining tasks to process
  60270. */
  60271. remainingCount: number;
  60272. /**
  60273. * Defines the total number of tasks
  60274. */
  60275. totalCount: number;
  60276. /**
  60277. * Defines the task that was just processed
  60278. */
  60279. task: AbstractAssetTask;
  60280. }
  60281. /**
  60282. * Class used to share progress information about assets loading
  60283. */
  60284. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60285. /**
  60286. * Defines the number of remaining tasks to process
  60287. */
  60288. remainingCount: number;
  60289. /**
  60290. * Defines the total number of tasks
  60291. */
  60292. totalCount: number;
  60293. /**
  60294. * Defines the task that was just processed
  60295. */
  60296. task: AbstractAssetTask;
  60297. /**
  60298. * Creates a AssetsProgressEvent
  60299. * @param remainingCount defines the number of remaining tasks to process
  60300. * @param totalCount defines the total number of tasks
  60301. * @param task defines the task that was just processed
  60302. */
  60303. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60304. }
  60305. /**
  60306. * Define a task used by AssetsManager to load meshes
  60307. */
  60308. export class MeshAssetTask extends AbstractAssetTask {
  60309. /**
  60310. * Defines the name of the task
  60311. */
  60312. name: string;
  60313. /**
  60314. * Defines the list of mesh's names you want to load
  60315. */
  60316. meshesNames: any;
  60317. /**
  60318. * Defines the root url to use as a base to load your meshes and associated resources
  60319. */
  60320. rootUrl: string;
  60321. /**
  60322. * Defines the filename of the scene to load from
  60323. */
  60324. sceneFilename: string;
  60325. /**
  60326. * Gets the list of loaded meshes
  60327. */
  60328. loadedMeshes: Array<AbstractMesh>;
  60329. /**
  60330. * Gets the list of loaded particle systems
  60331. */
  60332. loadedParticleSystems: Array<IParticleSystem>;
  60333. /**
  60334. * Gets the list of loaded skeletons
  60335. */
  60336. loadedSkeletons: Array<Skeleton>;
  60337. /**
  60338. * Gets the list of loaded animation groups
  60339. */
  60340. loadedAnimationGroups: Array<AnimationGroup>;
  60341. /**
  60342. * Callback called when the task is successful
  60343. */
  60344. onSuccess: (task: MeshAssetTask) => void;
  60345. /**
  60346. * Callback called when the task is successful
  60347. */
  60348. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60349. /**
  60350. * Creates a new MeshAssetTask
  60351. * @param name defines the name of the task
  60352. * @param meshesNames defines the list of mesh's names you want to load
  60353. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60354. * @param sceneFilename defines the filename of the scene to load from
  60355. */
  60356. constructor(
  60357. /**
  60358. * Defines the name of the task
  60359. */
  60360. name: string,
  60361. /**
  60362. * Defines the list of mesh's names you want to load
  60363. */
  60364. meshesNames: any,
  60365. /**
  60366. * Defines the root url to use as a base to load your meshes and associated resources
  60367. */
  60368. rootUrl: string,
  60369. /**
  60370. * Defines the filename of the scene to load from
  60371. */
  60372. sceneFilename: string);
  60373. /**
  60374. * Execute the current task
  60375. * @param scene defines the scene where you want your assets to be loaded
  60376. * @param onSuccess is a callback called when the task is successfully executed
  60377. * @param onError is a callback called if an error occurs
  60378. */
  60379. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60380. }
  60381. /**
  60382. * Define a task used by AssetsManager to load text content
  60383. */
  60384. export class TextFileAssetTask extends AbstractAssetTask {
  60385. /**
  60386. * Defines the name of the task
  60387. */
  60388. name: string;
  60389. /**
  60390. * Defines the location of the file to load
  60391. */
  60392. url: string;
  60393. /**
  60394. * Gets the loaded text string
  60395. */
  60396. text: string;
  60397. /**
  60398. * Callback called when the task is successful
  60399. */
  60400. onSuccess: (task: TextFileAssetTask) => void;
  60401. /**
  60402. * Callback called when the task is successful
  60403. */
  60404. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60405. /**
  60406. * Creates a new TextFileAssetTask object
  60407. * @param name defines the name of the task
  60408. * @param url defines the location of the file to load
  60409. */
  60410. constructor(
  60411. /**
  60412. * Defines the name of the task
  60413. */
  60414. name: string,
  60415. /**
  60416. * Defines the location of the file to load
  60417. */
  60418. url: string);
  60419. /**
  60420. * Execute the current task
  60421. * @param scene defines the scene where you want your assets to be loaded
  60422. * @param onSuccess is a callback called when the task is successfully executed
  60423. * @param onError is a callback called if an error occurs
  60424. */
  60425. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60426. }
  60427. /**
  60428. * Define a task used by AssetsManager to load binary data
  60429. */
  60430. export class BinaryFileAssetTask extends AbstractAssetTask {
  60431. /**
  60432. * Defines the name of the task
  60433. */
  60434. name: string;
  60435. /**
  60436. * Defines the location of the file to load
  60437. */
  60438. url: string;
  60439. /**
  60440. * Gets the lodaded data (as an array buffer)
  60441. */
  60442. data: ArrayBuffer;
  60443. /**
  60444. * Callback called when the task is successful
  60445. */
  60446. onSuccess: (task: BinaryFileAssetTask) => void;
  60447. /**
  60448. * Callback called when the task is successful
  60449. */
  60450. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60451. /**
  60452. * Creates a new BinaryFileAssetTask object
  60453. * @param name defines the name of the new task
  60454. * @param url defines the location of the file to load
  60455. */
  60456. constructor(
  60457. /**
  60458. * Defines the name of the task
  60459. */
  60460. name: string,
  60461. /**
  60462. * Defines the location of the file to load
  60463. */
  60464. url: string);
  60465. /**
  60466. * Execute the current task
  60467. * @param scene defines the scene where you want your assets to be loaded
  60468. * @param onSuccess is a callback called when the task is successfully executed
  60469. * @param onError is a callback called if an error occurs
  60470. */
  60471. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60472. }
  60473. /**
  60474. * Define a task used by AssetsManager to load images
  60475. */
  60476. export class ImageAssetTask extends AbstractAssetTask {
  60477. /**
  60478. * Defines the name of the task
  60479. */
  60480. name: string;
  60481. /**
  60482. * Defines the location of the image to load
  60483. */
  60484. url: string;
  60485. /**
  60486. * Gets the loaded images
  60487. */
  60488. image: HTMLImageElement;
  60489. /**
  60490. * Callback called when the task is successful
  60491. */
  60492. onSuccess: (task: ImageAssetTask) => void;
  60493. /**
  60494. * Callback called when the task is successful
  60495. */
  60496. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60497. /**
  60498. * Creates a new ImageAssetTask
  60499. * @param name defines the name of the task
  60500. * @param url defines the location of the image to load
  60501. */
  60502. constructor(
  60503. /**
  60504. * Defines the name of the task
  60505. */
  60506. name: string,
  60507. /**
  60508. * Defines the location of the image to load
  60509. */
  60510. url: string);
  60511. /**
  60512. * Execute the current task
  60513. * @param scene defines the scene where you want your assets to be loaded
  60514. * @param onSuccess is a callback called when the task is successfully executed
  60515. * @param onError is a callback called if an error occurs
  60516. */
  60517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60518. }
  60519. /**
  60520. * Defines the interface used by texture loading tasks
  60521. */
  60522. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60523. /**
  60524. * Gets the loaded texture
  60525. */
  60526. texture: TEX;
  60527. }
  60528. /**
  60529. * Define a task used by AssetsManager to load 2D textures
  60530. */
  60531. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60532. /**
  60533. * Defines the name of the task
  60534. */
  60535. name: string;
  60536. /**
  60537. * Defines the location of the file to load
  60538. */
  60539. url: string;
  60540. /**
  60541. * Defines if mipmap should not be generated (default is false)
  60542. */
  60543. noMipmap?: boolean | undefined;
  60544. /**
  60545. * Defines if texture must be inverted on Y axis (default is false)
  60546. */
  60547. invertY?: boolean | undefined;
  60548. /**
  60549. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60550. */
  60551. samplingMode: number;
  60552. /**
  60553. * Gets the loaded texture
  60554. */
  60555. texture: Texture;
  60556. /**
  60557. * Callback called when the task is successful
  60558. */
  60559. onSuccess: (task: TextureAssetTask) => void;
  60560. /**
  60561. * Callback called when the task is successful
  60562. */
  60563. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60564. /**
  60565. * Creates a new TextureAssetTask object
  60566. * @param name defines the name of the task
  60567. * @param url defines the location of the file to load
  60568. * @param noMipmap defines if mipmap should not be generated (default is false)
  60569. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60570. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60571. */
  60572. constructor(
  60573. /**
  60574. * Defines the name of the task
  60575. */
  60576. name: string,
  60577. /**
  60578. * Defines the location of the file to load
  60579. */
  60580. url: string,
  60581. /**
  60582. * Defines if mipmap should not be generated (default is false)
  60583. */
  60584. noMipmap?: boolean | undefined,
  60585. /**
  60586. * Defines if texture must be inverted on Y axis (default is false)
  60587. */
  60588. invertY?: boolean | undefined,
  60589. /**
  60590. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60591. */
  60592. samplingMode?: number);
  60593. /**
  60594. * Execute the current task
  60595. * @param scene defines the scene where you want your assets to be loaded
  60596. * @param onSuccess is a callback called when the task is successfully executed
  60597. * @param onError is a callback called if an error occurs
  60598. */
  60599. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60600. }
  60601. /**
  60602. * Define a task used by AssetsManager to load cube textures
  60603. */
  60604. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60605. /**
  60606. * Defines the name of the task
  60607. */
  60608. name: string;
  60609. /**
  60610. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60611. */
  60612. url: string;
  60613. /**
  60614. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60615. */
  60616. extensions?: string[] | undefined;
  60617. /**
  60618. * Defines if mipmaps should not be generated (default is false)
  60619. */
  60620. noMipmap?: boolean | undefined;
  60621. /**
  60622. * Defines the explicit list of files (undefined by default)
  60623. */
  60624. files?: string[] | undefined;
  60625. /**
  60626. * Gets the loaded texture
  60627. */
  60628. texture: CubeTexture;
  60629. /**
  60630. * Callback called when the task is successful
  60631. */
  60632. onSuccess: (task: CubeTextureAssetTask) => void;
  60633. /**
  60634. * Callback called when the task is successful
  60635. */
  60636. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60637. /**
  60638. * Creates a new CubeTextureAssetTask
  60639. * @param name defines the name of the task
  60640. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60641. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60642. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60643. * @param files defines the explicit list of files (undefined by default)
  60644. */
  60645. constructor(
  60646. /**
  60647. * Defines the name of the task
  60648. */
  60649. name: string,
  60650. /**
  60651. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60652. */
  60653. url: string,
  60654. /**
  60655. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60656. */
  60657. extensions?: string[] | undefined,
  60658. /**
  60659. * Defines if mipmaps should not be generated (default is false)
  60660. */
  60661. noMipmap?: boolean | undefined,
  60662. /**
  60663. * Defines the explicit list of files (undefined by default)
  60664. */
  60665. files?: string[] | undefined);
  60666. /**
  60667. * Execute the current task
  60668. * @param scene defines the scene where you want your assets to be loaded
  60669. * @param onSuccess is a callback called when the task is successfully executed
  60670. * @param onError is a callback called if an error occurs
  60671. */
  60672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60673. }
  60674. /**
  60675. * Define a task used by AssetsManager to load HDR cube textures
  60676. */
  60677. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60678. /**
  60679. * Defines the name of the task
  60680. */
  60681. name: string;
  60682. /**
  60683. * Defines the location of the file to load
  60684. */
  60685. url: string;
  60686. /**
  60687. * Defines the desired size (the more it increases the longer the generation will be)
  60688. */
  60689. size: number;
  60690. /**
  60691. * Defines if mipmaps should not be generated (default is false)
  60692. */
  60693. noMipmap: boolean;
  60694. /**
  60695. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60696. */
  60697. generateHarmonics: boolean;
  60698. /**
  60699. * 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)
  60700. */
  60701. gammaSpace: boolean;
  60702. /**
  60703. * Internal Use Only
  60704. */
  60705. reserved: boolean;
  60706. /**
  60707. * Gets the loaded texture
  60708. */
  60709. texture: HDRCubeTexture;
  60710. /**
  60711. * Callback called when the task is successful
  60712. */
  60713. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60714. /**
  60715. * Callback called when the task is successful
  60716. */
  60717. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60718. /**
  60719. * Creates a new HDRCubeTextureAssetTask object
  60720. * @param name defines the name of the task
  60721. * @param url defines the location of the file to load
  60722. * @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.
  60723. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60724. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60725. * @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)
  60726. * @param reserved Internal use only
  60727. */
  60728. constructor(
  60729. /**
  60730. * Defines the name of the task
  60731. */
  60732. name: string,
  60733. /**
  60734. * Defines the location of the file to load
  60735. */
  60736. url: string,
  60737. /**
  60738. * Defines the desired size (the more it increases the longer the generation will be)
  60739. */
  60740. size: number,
  60741. /**
  60742. * Defines if mipmaps should not be generated (default is false)
  60743. */
  60744. noMipmap?: boolean,
  60745. /**
  60746. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60747. */
  60748. generateHarmonics?: boolean,
  60749. /**
  60750. * 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)
  60751. */
  60752. gammaSpace?: boolean,
  60753. /**
  60754. * Internal Use Only
  60755. */
  60756. reserved?: boolean);
  60757. /**
  60758. * Execute the current task
  60759. * @param scene defines the scene where you want your assets to be loaded
  60760. * @param onSuccess is a callback called when the task is successfully executed
  60761. * @param onError is a callback called if an error occurs
  60762. */
  60763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60764. }
  60765. /**
  60766. * Define a task used by AssetsManager to load Equirectangular cube textures
  60767. */
  60768. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60769. /**
  60770. * Defines the name of the task
  60771. */
  60772. name: string;
  60773. /**
  60774. * Defines the location of the file to load
  60775. */
  60776. url: string;
  60777. /**
  60778. * Defines the desired size (the more it increases the longer the generation will be)
  60779. */
  60780. size: number;
  60781. /**
  60782. * Defines if mipmaps should not be generated (default is false)
  60783. */
  60784. noMipmap: boolean;
  60785. /**
  60786. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60787. * but the standard material would require them in Gamma space) (default is true)
  60788. */
  60789. gammaSpace: boolean;
  60790. /**
  60791. * Gets the loaded texture
  60792. */
  60793. texture: EquiRectangularCubeTexture;
  60794. /**
  60795. * Callback called when the task is successful
  60796. */
  60797. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60798. /**
  60799. * Callback called when the task is successful
  60800. */
  60801. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60802. /**
  60803. * Creates a new EquiRectangularCubeTextureAssetTask object
  60804. * @param name defines the name of the task
  60805. * @param url defines the location of the file to load
  60806. * @param size defines the desired size (the more it increases the longer the generation will be)
  60807. * If the size is omitted this implies you are using a preprocessed cubemap.
  60808. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60809. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60810. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60811. * (default is true)
  60812. */
  60813. constructor(
  60814. /**
  60815. * Defines the name of the task
  60816. */
  60817. name: string,
  60818. /**
  60819. * Defines the location of the file to load
  60820. */
  60821. url: string,
  60822. /**
  60823. * Defines the desired size (the more it increases the longer the generation will be)
  60824. */
  60825. size: number,
  60826. /**
  60827. * Defines if mipmaps should not be generated (default is false)
  60828. */
  60829. noMipmap?: boolean,
  60830. /**
  60831. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60832. * but the standard material would require them in Gamma space) (default is true)
  60833. */
  60834. gammaSpace?: boolean);
  60835. /**
  60836. * Execute the current task
  60837. * @param scene defines the scene where you want your assets to be loaded
  60838. * @param onSuccess is a callback called when the task is successfully executed
  60839. * @param onError is a callback called if an error occurs
  60840. */
  60841. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60842. }
  60843. /**
  60844. * This class can be used to easily import assets into a scene
  60845. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60846. */
  60847. export class AssetsManager {
  60848. private _scene;
  60849. private _isLoading;
  60850. protected _tasks: AbstractAssetTask[];
  60851. protected _waitingTasksCount: number;
  60852. protected _totalTasksCount: number;
  60853. /**
  60854. * Callback called when all tasks are processed
  60855. */
  60856. onFinish: (tasks: AbstractAssetTask[]) => void;
  60857. /**
  60858. * Callback called when a task is successful
  60859. */
  60860. onTaskSuccess: (task: AbstractAssetTask) => void;
  60861. /**
  60862. * Callback called when a task had an error
  60863. */
  60864. onTaskError: (task: AbstractAssetTask) => void;
  60865. /**
  60866. * Callback called when a task is done (whatever the result is)
  60867. */
  60868. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60869. /**
  60870. * Observable called when all tasks are processed
  60871. */
  60872. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60873. /**
  60874. * Observable called when a task had an error
  60875. */
  60876. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60877. /**
  60878. * Observable called when all tasks were executed
  60879. */
  60880. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60881. /**
  60882. * Observable called when a task is done (whatever the result is)
  60883. */
  60884. onProgressObservable: Observable<IAssetsProgressEvent>;
  60885. /**
  60886. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60888. */
  60889. useDefaultLoadingScreen: boolean;
  60890. /**
  60891. * Creates a new AssetsManager
  60892. * @param scene defines the scene to work on
  60893. */
  60894. constructor(scene: Scene);
  60895. /**
  60896. * Add a MeshAssetTask to the list of active tasks
  60897. * @param taskName defines the name of the new task
  60898. * @param meshesNames defines the name of meshes to load
  60899. * @param rootUrl defines the root url to use to locate files
  60900. * @param sceneFilename defines the filename of the scene file
  60901. * @returns a new MeshAssetTask object
  60902. */
  60903. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60904. /**
  60905. * Add a TextFileAssetTask to the list of active tasks
  60906. * @param taskName defines the name of the new task
  60907. * @param url defines the url of the file to load
  60908. * @returns a new TextFileAssetTask object
  60909. */
  60910. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60911. /**
  60912. * Add a BinaryFileAssetTask to the list of active tasks
  60913. * @param taskName defines the name of the new task
  60914. * @param url defines the url of the file to load
  60915. * @returns a new BinaryFileAssetTask object
  60916. */
  60917. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60918. /**
  60919. * Add a ImageAssetTask to the list of active tasks
  60920. * @param taskName defines the name of the new task
  60921. * @param url defines the url of the file to load
  60922. * @returns a new ImageAssetTask object
  60923. */
  60924. addImageTask(taskName: string, url: string): ImageAssetTask;
  60925. /**
  60926. * Add a TextureAssetTask to the list of active tasks
  60927. * @param taskName defines the name of the new task
  60928. * @param url defines the url of the file to load
  60929. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60930. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60931. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60932. * @returns a new TextureAssetTask object
  60933. */
  60934. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60935. /**
  60936. * Add a CubeTextureAssetTask to the list of active tasks
  60937. * @param taskName defines the name of the new task
  60938. * @param url defines the url of the file to load
  60939. * @param extensions defines the extension to use to load the cube map (can be null)
  60940. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60941. * @param files defines the list of files to load (can be null)
  60942. * @returns a new CubeTextureAssetTask object
  60943. */
  60944. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60945. /**
  60946. *
  60947. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60948. * @param taskName defines the name of the new task
  60949. * @param url defines the url of the file to load
  60950. * @param size defines the size you want for the cubemap (can be null)
  60951. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60952. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60953. * @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)
  60954. * @param reserved Internal use only
  60955. * @returns a new HDRCubeTextureAssetTask object
  60956. */
  60957. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60958. /**
  60959. *
  60960. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60961. * @param taskName defines the name of the new task
  60962. * @param url defines the url of the file to load
  60963. * @param size defines the size you want for the cubemap (can be null)
  60964. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60965. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60966. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60967. * @returns a new EquiRectangularCubeTextureAssetTask object
  60968. */
  60969. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60970. /**
  60971. * Remove a task from the assets manager.
  60972. * @param task the task to remove
  60973. */
  60974. removeTask(task: AbstractAssetTask): void;
  60975. private _decreaseWaitingTasksCount;
  60976. private _runTask;
  60977. /**
  60978. * Reset the AssetsManager and remove all tasks
  60979. * @return the current instance of the AssetsManager
  60980. */
  60981. reset(): AssetsManager;
  60982. /**
  60983. * Start the loading process
  60984. * @return the current instance of the AssetsManager
  60985. */
  60986. load(): AssetsManager;
  60987. /**
  60988. * Start the loading process as an async operation
  60989. * @return a promise returning the list of failed tasks
  60990. */
  60991. loadAsync(): Promise<void>;
  60992. }
  60993. }
  60994. declare module "babylonjs/Misc/deferred" {
  60995. /**
  60996. * Wrapper class for promise with external resolve and reject.
  60997. */
  60998. export class Deferred<T> {
  60999. /**
  61000. * The promise associated with this deferred object.
  61001. */
  61002. readonly promise: Promise<T>;
  61003. private _resolve;
  61004. private _reject;
  61005. /**
  61006. * The resolve method of the promise associated with this deferred object.
  61007. */
  61008. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61009. /**
  61010. * The reject method of the promise associated with this deferred object.
  61011. */
  61012. readonly reject: (reason?: any) => void;
  61013. /**
  61014. * Constructor for this deferred object.
  61015. */
  61016. constructor();
  61017. }
  61018. }
  61019. declare module "babylonjs/Misc/meshExploder" {
  61020. import { Mesh } from "babylonjs/Meshes/mesh";
  61021. /**
  61022. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61023. */
  61024. export class MeshExploder {
  61025. private _centerMesh;
  61026. private _meshes;
  61027. private _meshesOrigins;
  61028. private _toCenterVectors;
  61029. private _scaledDirection;
  61030. private _newPosition;
  61031. private _centerPosition;
  61032. /**
  61033. * Explodes meshes from a center mesh.
  61034. * @param meshes The meshes to explode.
  61035. * @param centerMesh The mesh to be center of explosion.
  61036. */
  61037. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61038. private _setCenterMesh;
  61039. /**
  61040. * Get class name
  61041. * @returns "MeshExploder"
  61042. */
  61043. getClassName(): string;
  61044. /**
  61045. * "Exploded meshes"
  61046. * @returns Array of meshes with the centerMesh at index 0.
  61047. */
  61048. getMeshes(): Array<Mesh>;
  61049. /**
  61050. * Explodes meshes giving a specific direction
  61051. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61052. */
  61053. explode(direction?: number): void;
  61054. }
  61055. }
  61056. declare module "babylonjs/Misc/filesInput" {
  61057. import { Engine } from "babylonjs/Engines/engine";
  61058. import { Scene } from "babylonjs/scene";
  61059. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61060. /**
  61061. * Class used to help managing file picking and drag'n'drop
  61062. */
  61063. export class FilesInput {
  61064. /**
  61065. * List of files ready to be loaded
  61066. */
  61067. static readonly FilesToLoad: {
  61068. [key: string]: File;
  61069. };
  61070. /**
  61071. * Callback called when a file is processed
  61072. */
  61073. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61074. private _engine;
  61075. private _currentScene;
  61076. private _sceneLoadedCallback;
  61077. private _progressCallback;
  61078. private _additionalRenderLoopLogicCallback;
  61079. private _textureLoadingCallback;
  61080. private _startingProcessingFilesCallback;
  61081. private _onReloadCallback;
  61082. private _errorCallback;
  61083. private _elementToMonitor;
  61084. private _sceneFileToLoad;
  61085. private _filesToLoad;
  61086. /**
  61087. * Creates a new FilesInput
  61088. * @param engine defines the rendering engine
  61089. * @param scene defines the hosting scene
  61090. * @param sceneLoadedCallback callback called when scene is loaded
  61091. * @param progressCallback callback called to track progress
  61092. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61093. * @param textureLoadingCallback callback called when a texture is loading
  61094. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61095. * @param onReloadCallback callback called when a reload is requested
  61096. * @param errorCallback callback call if an error occurs
  61097. */
  61098. 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);
  61099. private _dragEnterHandler;
  61100. private _dragOverHandler;
  61101. private _dropHandler;
  61102. /**
  61103. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61104. * @param elementToMonitor defines the DOM element to track
  61105. */
  61106. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61107. /**
  61108. * Release all associated resources
  61109. */
  61110. dispose(): void;
  61111. private renderFunction;
  61112. private drag;
  61113. private drop;
  61114. private _traverseFolder;
  61115. private _processFiles;
  61116. /**
  61117. * Load files from a drop event
  61118. * @param event defines the drop event to use as source
  61119. */
  61120. loadFiles(event: any): void;
  61121. private _processReload;
  61122. /**
  61123. * Reload the current scene from the loaded files
  61124. */
  61125. reload(): void;
  61126. }
  61127. }
  61128. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61129. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61130. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61131. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61132. }
  61133. declare module "babylonjs/Misc/sceneOptimizer" {
  61134. import { Scene, IDisposable } from "babylonjs/scene";
  61135. import { Observable } from "babylonjs/Misc/observable";
  61136. /**
  61137. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61139. */
  61140. export class SceneOptimization {
  61141. /**
  61142. * Defines the priority of this optimization (0 by default which means first in the list)
  61143. */
  61144. priority: number;
  61145. /**
  61146. * Gets a string describing the action executed by the current optimization
  61147. * @returns description string
  61148. */
  61149. getDescription(): string;
  61150. /**
  61151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61152. * @param scene defines the current scene where to apply this optimization
  61153. * @param optimizer defines the current optimizer
  61154. * @returns true if everything that can be done was applied
  61155. */
  61156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61157. /**
  61158. * Creates the SceneOptimization object
  61159. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61160. * @param desc defines the description associated with the optimization
  61161. */
  61162. constructor(
  61163. /**
  61164. * Defines the priority of this optimization (0 by default which means first in the list)
  61165. */
  61166. priority?: number);
  61167. }
  61168. /**
  61169. * Defines an optimization used to reduce the size of render target textures
  61170. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61171. */
  61172. export class TextureOptimization extends SceneOptimization {
  61173. /**
  61174. * Defines the priority of this optimization (0 by default which means first in the list)
  61175. */
  61176. priority: number;
  61177. /**
  61178. * 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
  61179. */
  61180. maximumSize: number;
  61181. /**
  61182. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61183. */
  61184. step: number;
  61185. /**
  61186. * Gets a string describing the action executed by the current optimization
  61187. * @returns description string
  61188. */
  61189. getDescription(): string;
  61190. /**
  61191. * Creates the TextureOptimization object
  61192. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61193. * @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
  61194. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61195. */
  61196. constructor(
  61197. /**
  61198. * Defines the priority of this optimization (0 by default which means first in the list)
  61199. */
  61200. priority?: number,
  61201. /**
  61202. * 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
  61203. */
  61204. maximumSize?: number,
  61205. /**
  61206. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61207. */
  61208. step?: number);
  61209. /**
  61210. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61211. * @param scene defines the current scene where to apply this optimization
  61212. * @param optimizer defines the current optimizer
  61213. * @returns true if everything that can be done was applied
  61214. */
  61215. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61216. }
  61217. /**
  61218. * Defines an optimization used to increase or decrease the rendering resolution
  61219. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61220. */
  61221. export class HardwareScalingOptimization extends SceneOptimization {
  61222. /**
  61223. * Defines the priority of this optimization (0 by default which means first in the list)
  61224. */
  61225. priority: number;
  61226. /**
  61227. * Defines the maximum scale to use (2 by default)
  61228. */
  61229. maximumScale: number;
  61230. /**
  61231. * Defines the step to use between two passes (0.5 by default)
  61232. */
  61233. step: number;
  61234. private _currentScale;
  61235. private _directionOffset;
  61236. /**
  61237. * Gets a string describing the action executed by the current optimization
  61238. * @return description string
  61239. */
  61240. getDescription(): string;
  61241. /**
  61242. * Creates the HardwareScalingOptimization object
  61243. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61244. * @param maximumScale defines the maximum scale to use (2 by default)
  61245. * @param step defines the step to use between two passes (0.5 by default)
  61246. */
  61247. constructor(
  61248. /**
  61249. * Defines the priority of this optimization (0 by default which means first in the list)
  61250. */
  61251. priority?: number,
  61252. /**
  61253. * Defines the maximum scale to use (2 by default)
  61254. */
  61255. maximumScale?: number,
  61256. /**
  61257. * Defines the step to use between two passes (0.5 by default)
  61258. */
  61259. step?: number);
  61260. /**
  61261. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61262. * @param scene defines the current scene where to apply this optimization
  61263. * @param optimizer defines the current optimizer
  61264. * @returns true if everything that can be done was applied
  61265. */
  61266. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61267. }
  61268. /**
  61269. * Defines an optimization used to remove shadows
  61270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61271. */
  61272. export class ShadowsOptimization extends SceneOptimization {
  61273. /**
  61274. * Gets a string describing the action executed by the current optimization
  61275. * @return description string
  61276. */
  61277. getDescription(): string;
  61278. /**
  61279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61280. * @param scene defines the current scene where to apply this optimization
  61281. * @param optimizer defines the current optimizer
  61282. * @returns true if everything that can be done was applied
  61283. */
  61284. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61285. }
  61286. /**
  61287. * Defines an optimization used to turn post-processes off
  61288. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61289. */
  61290. export class PostProcessesOptimization extends SceneOptimization {
  61291. /**
  61292. * Gets a string describing the action executed by the current optimization
  61293. * @return description string
  61294. */
  61295. getDescription(): string;
  61296. /**
  61297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61298. * @param scene defines the current scene where to apply this optimization
  61299. * @param optimizer defines the current optimizer
  61300. * @returns true if everything that can be done was applied
  61301. */
  61302. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61303. }
  61304. /**
  61305. * Defines an optimization used to turn lens flares off
  61306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61307. */
  61308. export class LensFlaresOptimization extends SceneOptimization {
  61309. /**
  61310. * Gets a string describing the action executed by the current optimization
  61311. * @return description string
  61312. */
  61313. getDescription(): string;
  61314. /**
  61315. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61316. * @param scene defines the current scene where to apply this optimization
  61317. * @param optimizer defines the current optimizer
  61318. * @returns true if everything that can be done was applied
  61319. */
  61320. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61321. }
  61322. /**
  61323. * Defines an optimization based on user defined callback.
  61324. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61325. */
  61326. export class CustomOptimization extends SceneOptimization {
  61327. /**
  61328. * Callback called to apply the custom optimization.
  61329. */
  61330. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61331. /**
  61332. * Callback called to get custom description
  61333. */
  61334. onGetDescription: () => string;
  61335. /**
  61336. * Gets a string describing the action executed by the current optimization
  61337. * @returns description string
  61338. */
  61339. getDescription(): string;
  61340. /**
  61341. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61342. * @param scene defines the current scene where to apply this optimization
  61343. * @param optimizer defines the current optimizer
  61344. * @returns true if everything that can be done was applied
  61345. */
  61346. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61347. }
  61348. /**
  61349. * Defines an optimization used to turn particles off
  61350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61351. */
  61352. export class ParticlesOptimization extends SceneOptimization {
  61353. /**
  61354. * Gets a string describing the action executed by the current optimization
  61355. * @return description string
  61356. */
  61357. getDescription(): string;
  61358. /**
  61359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61360. * @param scene defines the current scene where to apply this optimization
  61361. * @param optimizer defines the current optimizer
  61362. * @returns true if everything that can be done was applied
  61363. */
  61364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61365. }
  61366. /**
  61367. * Defines an optimization used to turn render targets off
  61368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61369. */
  61370. export class RenderTargetsOptimization extends SceneOptimization {
  61371. /**
  61372. * Gets a string describing the action executed by the current optimization
  61373. * @return description string
  61374. */
  61375. getDescription(): string;
  61376. /**
  61377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61378. * @param scene defines the current scene where to apply this optimization
  61379. * @param optimizer defines the current optimizer
  61380. * @returns true if everything that can be done was applied
  61381. */
  61382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61383. }
  61384. /**
  61385. * Defines an optimization used to merge meshes with compatible materials
  61386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61387. */
  61388. export class MergeMeshesOptimization extends SceneOptimization {
  61389. private static _UpdateSelectionTree;
  61390. /**
  61391. * Gets or sets a boolean which defines if optimization octree has to be updated
  61392. */
  61393. /**
  61394. * Gets or sets a boolean which defines if optimization octree has to be updated
  61395. */
  61396. static UpdateSelectionTree: boolean;
  61397. /**
  61398. * Gets a string describing the action executed by the current optimization
  61399. * @return description string
  61400. */
  61401. getDescription(): string;
  61402. private _canBeMerged;
  61403. /**
  61404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61405. * @param scene defines the current scene where to apply this optimization
  61406. * @param optimizer defines the current optimizer
  61407. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61408. * @returns true if everything that can be done was applied
  61409. */
  61410. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61411. }
  61412. /**
  61413. * Defines a list of options used by SceneOptimizer
  61414. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61415. */
  61416. export class SceneOptimizerOptions {
  61417. /**
  61418. * Defines the target frame rate to reach (60 by default)
  61419. */
  61420. targetFrameRate: number;
  61421. /**
  61422. * Defines the interval between two checkes (2000ms by default)
  61423. */
  61424. trackerDuration: number;
  61425. /**
  61426. * Gets the list of optimizations to apply
  61427. */
  61428. optimizations: SceneOptimization[];
  61429. /**
  61430. * Creates a new list of options used by SceneOptimizer
  61431. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61432. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61433. */
  61434. constructor(
  61435. /**
  61436. * Defines the target frame rate to reach (60 by default)
  61437. */
  61438. targetFrameRate?: number,
  61439. /**
  61440. * Defines the interval between two checkes (2000ms by default)
  61441. */
  61442. trackerDuration?: number);
  61443. /**
  61444. * Add a new optimization
  61445. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61446. * @returns the current SceneOptimizerOptions
  61447. */
  61448. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61449. /**
  61450. * Add a new custom optimization
  61451. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61452. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61453. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61454. * @returns the current SceneOptimizerOptions
  61455. */
  61456. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61457. /**
  61458. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61459. * @param targetFrameRate defines the target frame rate (60 by default)
  61460. * @returns a SceneOptimizerOptions object
  61461. */
  61462. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61463. /**
  61464. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61465. * @param targetFrameRate defines the target frame rate (60 by default)
  61466. * @returns a SceneOptimizerOptions object
  61467. */
  61468. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61469. /**
  61470. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61471. * @param targetFrameRate defines the target frame rate (60 by default)
  61472. * @returns a SceneOptimizerOptions object
  61473. */
  61474. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61475. }
  61476. /**
  61477. * Class used to run optimizations in order to reach a target frame rate
  61478. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61479. */
  61480. export class SceneOptimizer implements IDisposable {
  61481. private _isRunning;
  61482. private _options;
  61483. private _scene;
  61484. private _currentPriorityLevel;
  61485. private _targetFrameRate;
  61486. private _trackerDuration;
  61487. private _currentFrameRate;
  61488. private _sceneDisposeObserver;
  61489. private _improvementMode;
  61490. /**
  61491. * Defines an observable called when the optimizer reaches the target frame rate
  61492. */
  61493. onSuccessObservable: Observable<SceneOptimizer>;
  61494. /**
  61495. * Defines an observable called when the optimizer enables an optimization
  61496. */
  61497. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61498. /**
  61499. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61500. */
  61501. onFailureObservable: Observable<SceneOptimizer>;
  61502. /**
  61503. * Gets a boolean indicating if the optimizer is in improvement mode
  61504. */
  61505. readonly isInImprovementMode: boolean;
  61506. /**
  61507. * Gets the current priority level (0 at start)
  61508. */
  61509. readonly currentPriorityLevel: number;
  61510. /**
  61511. * Gets the current frame rate checked by the SceneOptimizer
  61512. */
  61513. readonly currentFrameRate: number;
  61514. /**
  61515. * Gets or sets the current target frame rate (60 by default)
  61516. */
  61517. /**
  61518. * Gets or sets the current target frame rate (60 by default)
  61519. */
  61520. targetFrameRate: number;
  61521. /**
  61522. * Gets or sets the current interval between two checks (every 2000ms by default)
  61523. */
  61524. /**
  61525. * Gets or sets the current interval between two checks (every 2000ms by default)
  61526. */
  61527. trackerDuration: number;
  61528. /**
  61529. * Gets the list of active optimizations
  61530. */
  61531. readonly optimizations: SceneOptimization[];
  61532. /**
  61533. * Creates a new SceneOptimizer
  61534. * @param scene defines the scene to work on
  61535. * @param options defines the options to use with the SceneOptimizer
  61536. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61537. * @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)
  61538. */
  61539. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61540. /**
  61541. * Stops the current optimizer
  61542. */
  61543. stop(): void;
  61544. /**
  61545. * Reset the optimizer to initial step (current priority level = 0)
  61546. */
  61547. reset(): void;
  61548. /**
  61549. * Start the optimizer. By default it will try to reach a specific framerate
  61550. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61551. */
  61552. start(): void;
  61553. private _checkCurrentState;
  61554. /**
  61555. * Release all resources
  61556. */
  61557. dispose(): void;
  61558. /**
  61559. * Helper function to create a SceneOptimizer with one single line of code
  61560. * @param scene defines the scene to work on
  61561. * @param options defines the options to use with the SceneOptimizer
  61562. * @param onSuccess defines a callback to call on success
  61563. * @param onFailure defines a callback to call on failure
  61564. * @returns the new SceneOptimizer object
  61565. */
  61566. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61567. }
  61568. }
  61569. declare module "babylonjs/Misc/sceneSerializer" {
  61570. import { Scene } from "babylonjs/scene";
  61571. /**
  61572. * Class used to serialize a scene into a string
  61573. */
  61574. export class SceneSerializer {
  61575. /**
  61576. * Clear cache used by a previous serialization
  61577. */
  61578. static ClearCache(): void;
  61579. /**
  61580. * Serialize a scene into a JSON compatible object
  61581. * @param scene defines the scene to serialize
  61582. * @returns a JSON compatible object
  61583. */
  61584. static Serialize(scene: Scene): any;
  61585. /**
  61586. * Serialize a mesh into a JSON compatible object
  61587. * @param toSerialize defines the mesh to serialize
  61588. * @param withParents defines if parents must be serialized as well
  61589. * @param withChildren defines if children must be serialized as well
  61590. * @returns a JSON compatible object
  61591. */
  61592. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61593. }
  61594. }
  61595. declare module "babylonjs/Misc/textureTools" {
  61596. import { Texture } from "babylonjs/Materials/Textures/texture";
  61597. /**
  61598. * Class used to host texture specific utilities
  61599. */
  61600. export class TextureTools {
  61601. /**
  61602. * Uses the GPU to create a copy texture rescaled at a given size
  61603. * @param texture Texture to copy from
  61604. * @param width defines the desired width
  61605. * @param height defines the desired height
  61606. * @param useBilinearMode defines if bilinear mode has to be used
  61607. * @return the generated texture
  61608. */
  61609. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61610. }
  61611. }
  61612. declare module "babylonjs/Misc/videoRecorder" {
  61613. import { Nullable } from "babylonjs/types";
  61614. import { Engine } from "babylonjs/Engines/engine";
  61615. /**
  61616. * This represents the different options avilable for the video capture.
  61617. */
  61618. export interface VideoRecorderOptions {
  61619. /** Defines the mime type of the video */
  61620. mimeType: string;
  61621. /** Defines the video the video should be recorded at */
  61622. fps: number;
  61623. /** Defines the chunk size for the recording data */
  61624. recordChunckSize: number;
  61625. /** The audio tracks to attach to the record */
  61626. audioTracks?: MediaStreamTrack[];
  61627. }
  61628. /**
  61629. * This can helps recording videos from BabylonJS.
  61630. * This is based on the available WebRTC functionalities of the browser.
  61631. *
  61632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61633. */
  61634. export class VideoRecorder {
  61635. private static readonly _defaultOptions;
  61636. /**
  61637. * Returns wehther or not the VideoRecorder is available in your browser.
  61638. * @param engine Defines the Babylon Engine to check the support for
  61639. * @returns true if supported otherwise false
  61640. */
  61641. static IsSupported(engine: Engine): boolean;
  61642. private readonly _options;
  61643. private _canvas;
  61644. private _mediaRecorder;
  61645. private _recordedChunks;
  61646. private _fileName;
  61647. private _resolve;
  61648. private _reject;
  61649. /**
  61650. * True wether a recording is already in progress.
  61651. */
  61652. readonly isRecording: boolean;
  61653. /**
  61654. * Create a new VideoCapture object which can help converting what you see in Babylon to
  61655. * a video file.
  61656. * @param engine Defines the BabylonJS Engine you wish to record
  61657. * @param options Defines options that can be used to customized the capture
  61658. */
  61659. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61660. /**
  61661. * Stops the current recording before the default capture timeout passed in the startRecording
  61662. * functions.
  61663. */
  61664. stopRecording(): void;
  61665. /**
  61666. * Starts recording the canvas for a max duration specified in parameters.
  61667. * @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.
  61668. * @param maxDuration Defines the maximum recording time in seconds.
  61669. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61670. * @return a promise callback at the end of the recording with the video data in Blob.
  61671. */
  61672. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61673. /**
  61674. * Releases internal resources used during the recording.
  61675. */
  61676. dispose(): void;
  61677. private _handleDataAvailable;
  61678. private _handleError;
  61679. private _handleStop;
  61680. }
  61681. }
  61682. declare module "babylonjs/Misc/screenshotTools" {
  61683. import { Camera } from "babylonjs/Cameras/camera";
  61684. import { Engine } from "babylonjs/Engines/engine";
  61685. /**
  61686. * Class containing a set of static utilities functions for screenshots
  61687. */
  61688. export class ScreenshotTools {
  61689. /**
  61690. * Captures a screenshot of the current rendering
  61691. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61692. * @param engine defines the rendering engine
  61693. * @param camera defines the source camera
  61694. * @param size This parameter can be set to a single number or to an object with the
  61695. * following (optional) properties: precision, width, height. If a single number is passed,
  61696. * it will be used for both width and height. If an object is passed, the screenshot size
  61697. * will be derived from the parameters. The precision property is a multiplier allowing
  61698. * rendering at a higher or lower resolution
  61699. * @param successCallback defines the callback receives a single parameter which contains the
  61700. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61701. * src parameter of an <img> to display it
  61702. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61703. * Check your browser for supported MIME types
  61704. */
  61705. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61706. /**
  61707. * Generates an image screenshot from the specified camera.
  61708. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61709. * @param engine The engine to use for rendering
  61710. * @param camera The camera to use for rendering
  61711. * @param size This parameter can be set to a single number or to an object with the
  61712. * following (optional) properties: precision, width, height. If a single number is passed,
  61713. * it will be used for both width and height. If an object is passed, the screenshot size
  61714. * will be derived from the parameters. The precision property is a multiplier allowing
  61715. * rendering at a higher or lower resolution
  61716. * @param successCallback The callback receives a single parameter which contains the
  61717. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61718. * src parameter of an <img> to display it
  61719. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61720. * Check your browser for supported MIME types
  61721. * @param samples Texture samples (default: 1)
  61722. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61723. * @param fileName A name for for the downloaded file.
  61724. */
  61725. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61726. }
  61727. }
  61728. declare module "babylonjs/Misc/index" {
  61729. export * from "babylonjs/Misc/andOrNotEvaluator";
  61730. export * from "babylonjs/Misc/assetsManager";
  61731. export * from "babylonjs/Misc/dds";
  61732. export * from "babylonjs/Misc/decorators";
  61733. export * from "babylonjs/Misc/deferred";
  61734. export * from "babylonjs/Misc/environmentTextureTools";
  61735. export * from "babylonjs/Misc/meshExploder";
  61736. export * from "babylonjs/Misc/filesInput";
  61737. export * from "babylonjs/Misc/HighDynamicRange/index";
  61738. export * from "babylonjs/Misc/khronosTextureContainer";
  61739. export * from "babylonjs/Misc/observable";
  61740. export * from "babylonjs/Misc/performanceMonitor";
  61741. export * from "babylonjs/Misc/promise";
  61742. export * from "babylonjs/Misc/sceneOptimizer";
  61743. export * from "babylonjs/Misc/sceneSerializer";
  61744. export * from "babylonjs/Misc/smartArray";
  61745. export * from "babylonjs/Misc/stringDictionary";
  61746. export * from "babylonjs/Misc/tags";
  61747. export * from "babylonjs/Misc/textureTools";
  61748. export * from "babylonjs/Misc/tga";
  61749. export * from "babylonjs/Misc/tools";
  61750. export * from "babylonjs/Misc/videoRecorder";
  61751. export * from "babylonjs/Misc/virtualJoystick";
  61752. export * from "babylonjs/Misc/workerPool";
  61753. export * from "babylonjs/Misc/logger";
  61754. export * from "babylonjs/Misc/typeStore";
  61755. export * from "babylonjs/Misc/filesInputStore";
  61756. export * from "babylonjs/Misc/deepCopier";
  61757. export * from "babylonjs/Misc/pivotTools";
  61758. export * from "babylonjs/Misc/precisionDate";
  61759. export * from "babylonjs/Misc/screenshotTools";
  61760. export * from "babylonjs/Misc/typeStore";
  61761. export * from "babylonjs/Misc/webRequest";
  61762. export * from "babylonjs/Misc/iInspectable";
  61763. export * from "babylonjs/Misc/brdfTextureTools";
  61764. }
  61765. declare module "babylonjs/index" {
  61766. export * from "babylonjs/abstractScene";
  61767. export * from "babylonjs/Actions/index";
  61768. export * from "babylonjs/Animations/index";
  61769. export * from "babylonjs/assetContainer";
  61770. export * from "babylonjs/Audio/index";
  61771. export * from "babylonjs/Behaviors/index";
  61772. export * from "babylonjs/Bones/index";
  61773. export * from "babylonjs/Cameras/index";
  61774. export * from "babylonjs/Collisions/index";
  61775. export * from "babylonjs/Culling/index";
  61776. export * from "babylonjs/Debug/index";
  61777. export * from "babylonjs/Engines/index";
  61778. export * from "babylonjs/Events/index";
  61779. export * from "babylonjs/Gamepads/index";
  61780. export * from "babylonjs/Gizmos/index";
  61781. export * from "babylonjs/Helpers/index";
  61782. export * from "babylonjs/Instrumentation/index";
  61783. export * from "babylonjs/Layers/index";
  61784. export * from "babylonjs/LensFlares/index";
  61785. export * from "babylonjs/Lights/index";
  61786. export * from "babylonjs/Loading/index";
  61787. export * from "babylonjs/Materials/index";
  61788. export * from "babylonjs/Maths/index";
  61789. export * from "babylonjs/Meshes/index";
  61790. export * from "babylonjs/Morph/index";
  61791. export * from "babylonjs/node";
  61792. export * from "babylonjs/Offline/index";
  61793. export * from "babylonjs/Particles/index";
  61794. export * from "babylonjs/Physics/index";
  61795. export * from "babylonjs/PostProcesses/index";
  61796. export * from "babylonjs/Probes/index";
  61797. export * from "babylonjs/Rendering/index";
  61798. export * from "babylonjs/scene";
  61799. export * from "babylonjs/sceneComponent";
  61800. export * from "babylonjs/Sprites/index";
  61801. export * from "babylonjs/States/index";
  61802. export * from "babylonjs/Misc/index";
  61803. export * from "babylonjs/types";
  61804. }
  61805. declare module "babylonjs/Animations/pathCursor" {
  61806. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61807. /**
  61808. * A cursor which tracks a point on a path
  61809. */
  61810. export class PathCursor {
  61811. private path;
  61812. /**
  61813. * Stores path cursor callbacks for when an onchange event is triggered
  61814. */
  61815. private _onchange;
  61816. /**
  61817. * The value of the path cursor
  61818. */
  61819. value: number;
  61820. /**
  61821. * The animation array of the path cursor
  61822. */
  61823. animations: Animation[];
  61824. /**
  61825. * Initializes the path cursor
  61826. * @param path The path to track
  61827. */
  61828. constructor(path: Path2);
  61829. /**
  61830. * Gets the cursor point on the path
  61831. * @returns A point on the path cursor at the cursor location
  61832. */
  61833. getPoint(): Vector3;
  61834. /**
  61835. * Moves the cursor ahead by the step amount
  61836. * @param step The amount to move the cursor forward
  61837. * @returns This path cursor
  61838. */
  61839. moveAhead(step?: number): PathCursor;
  61840. /**
  61841. * Moves the cursor behind by the step amount
  61842. * @param step The amount to move the cursor back
  61843. * @returns This path cursor
  61844. */
  61845. moveBack(step?: number): PathCursor;
  61846. /**
  61847. * Moves the cursor by the step amount
  61848. * If the step amount is greater than one, an exception is thrown
  61849. * @param step The amount to move the cursor
  61850. * @returns This path cursor
  61851. */
  61852. move(step: number): PathCursor;
  61853. /**
  61854. * Ensures that the value is limited between zero and one
  61855. * @returns This path cursor
  61856. */
  61857. private ensureLimits;
  61858. /**
  61859. * Runs onchange callbacks on change (used by the animation engine)
  61860. * @returns This path cursor
  61861. */
  61862. private raiseOnChange;
  61863. /**
  61864. * Executes a function on change
  61865. * @param f A path cursor onchange callback
  61866. * @returns This path cursor
  61867. */
  61868. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61869. }
  61870. }
  61871. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  61872. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  61873. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  61874. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  61875. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  61876. }
  61877. declare module "babylonjs/Engines/Processors/Expressions/index" {
  61878. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  61879. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  61880. }
  61881. declare module "babylonjs/Engines/Processors/index" {
  61882. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  61883. export * from "babylonjs/Engines/Processors/Expressions/index";
  61884. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  61885. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  61886. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  61887. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  61888. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  61889. export * from "babylonjs/Engines/Processors/shaderProcessor";
  61890. }
  61891. declare module "babylonjs/Legacy/legacy" {
  61892. import * as Babylon from "babylonjs/index";
  61893. export * from "babylonjs/index";
  61894. }
  61895. declare module "babylonjs/Shaders/blur.fragment" {
  61896. /** @hidden */
  61897. export var blurPixelShader: {
  61898. name: string;
  61899. shader: string;
  61900. };
  61901. }
  61902. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  61903. /** @hidden */
  61904. export var bones300Declaration: {
  61905. name: string;
  61906. shader: string;
  61907. };
  61908. }
  61909. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  61910. /** @hidden */
  61911. export var instances300Declaration: {
  61912. name: string;
  61913. shader: string;
  61914. };
  61915. }
  61916. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  61917. /** @hidden */
  61918. export var pointCloudVertexDeclaration: {
  61919. name: string;
  61920. shader: string;
  61921. };
  61922. }
  61923. // Mixins
  61924. interface Window {
  61925. mozIndexedDB: IDBFactory;
  61926. webkitIndexedDB: IDBFactory;
  61927. msIndexedDB: IDBFactory;
  61928. webkitURL: typeof URL;
  61929. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61930. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61931. WebGLRenderingContext: WebGLRenderingContext;
  61932. MSGesture: MSGesture;
  61933. CANNON: any;
  61934. AudioContext: AudioContext;
  61935. webkitAudioContext: AudioContext;
  61936. PointerEvent: any;
  61937. Math: Math;
  61938. Uint8Array: Uint8ArrayConstructor;
  61939. Float32Array: Float32ArrayConstructor;
  61940. mozURL: typeof URL;
  61941. msURL: typeof URL;
  61942. VRFrameData: any; // WebVR, from specs 1.1
  61943. DracoDecoderModule: any;
  61944. setImmediate(handler: (...args: any[]) => void): number;
  61945. }
  61946. interface HTMLCanvasElement {
  61947. requestPointerLock(): void;
  61948. msRequestPointerLock?(): void;
  61949. mozRequestPointerLock?(): void;
  61950. webkitRequestPointerLock?(): void;
  61951. /** Track wether a record is in progress */
  61952. isRecording: boolean;
  61953. /** Capture Stream method defined by some browsers */
  61954. captureStream(fps?: number): MediaStream;
  61955. }
  61956. interface CanvasRenderingContext2D {
  61957. msImageSmoothingEnabled: boolean;
  61958. }
  61959. interface MouseEvent {
  61960. mozMovementX: number;
  61961. mozMovementY: number;
  61962. webkitMovementX: number;
  61963. webkitMovementY: number;
  61964. msMovementX: number;
  61965. msMovementY: number;
  61966. }
  61967. interface Navigator {
  61968. mozGetVRDevices: (any: any) => any;
  61969. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61970. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61971. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61972. webkitGetGamepads(): Gamepad[];
  61973. msGetGamepads(): Gamepad[];
  61974. webkitGamepads(): Gamepad[];
  61975. }
  61976. interface HTMLVideoElement {
  61977. mozSrcObject: any;
  61978. }
  61979. interface Math {
  61980. fround(x: number): number;
  61981. imul(a: number, b: number): number;
  61982. }
  61983. interface WebGLRenderingContext {
  61984. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61985. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61986. vertexAttribDivisor(index: number, divisor: number): void;
  61987. createVertexArray(): any;
  61988. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61989. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61990. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61991. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61992. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61993. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61994. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61995. // Queries
  61996. createQuery(): WebGLQuery;
  61997. deleteQuery(query: WebGLQuery): void;
  61998. beginQuery(target: number, query: WebGLQuery): void;
  61999. endQuery(target: number): void;
  62000. getQueryParameter(query: WebGLQuery, pname: number): any;
  62001. getQuery(target: number, pname: number): any;
  62002. MAX_SAMPLES: number;
  62003. RGBA8: number;
  62004. READ_FRAMEBUFFER: number;
  62005. DRAW_FRAMEBUFFER: number;
  62006. UNIFORM_BUFFER: number;
  62007. HALF_FLOAT_OES: number;
  62008. RGBA16F: number;
  62009. RGBA32F: number;
  62010. R32F: number;
  62011. RG32F: number;
  62012. RGB32F: number;
  62013. R16F: number;
  62014. RG16F: number;
  62015. RGB16F: number;
  62016. RED: number;
  62017. RG: number;
  62018. R8: number;
  62019. RG8: number;
  62020. UNSIGNED_INT_24_8: number;
  62021. DEPTH24_STENCIL8: number;
  62022. /* Multiple Render Targets */
  62023. drawBuffers(buffers: number[]): void;
  62024. readBuffer(src: number): void;
  62025. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62026. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62027. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62028. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62029. // Occlusion Query
  62030. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62031. ANY_SAMPLES_PASSED: number;
  62032. QUERY_RESULT_AVAILABLE: number;
  62033. QUERY_RESULT: number;
  62034. }
  62035. interface WebGLProgram {
  62036. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62037. }
  62038. interface EXT_disjoint_timer_query {
  62039. QUERY_COUNTER_BITS_EXT: number;
  62040. TIME_ELAPSED_EXT: number;
  62041. TIMESTAMP_EXT: number;
  62042. GPU_DISJOINT_EXT: number;
  62043. QUERY_RESULT_EXT: number;
  62044. QUERY_RESULT_AVAILABLE_EXT: number;
  62045. queryCounterEXT(query: WebGLQuery, target: number): void;
  62046. createQueryEXT(): WebGLQuery;
  62047. beginQueryEXT(target: number, query: WebGLQuery): void;
  62048. endQueryEXT(target: number): void;
  62049. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62050. deleteQueryEXT(query: WebGLQuery): void;
  62051. }
  62052. interface WebGLUniformLocation {
  62053. _currentState: any;
  62054. }
  62055. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62056. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62057. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62058. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62059. interface WebGLRenderingContext {
  62060. readonly RASTERIZER_DISCARD: number;
  62061. readonly DEPTH_COMPONENT24: number;
  62062. readonly TEXTURE_3D: number;
  62063. readonly TEXTURE_2D_ARRAY: number;
  62064. readonly TEXTURE_COMPARE_FUNC: number;
  62065. readonly TEXTURE_COMPARE_MODE: number;
  62066. readonly COMPARE_REF_TO_TEXTURE: number;
  62067. readonly TEXTURE_WRAP_R: number;
  62068. readonly HALF_FLOAT: number;
  62069. readonly RGB8: number;
  62070. readonly RED_INTEGER: number;
  62071. readonly RG_INTEGER: number;
  62072. readonly RGB_INTEGER: number;
  62073. readonly RGBA_INTEGER: number;
  62074. readonly R8_SNORM: number;
  62075. readonly RG8_SNORM: number;
  62076. readonly RGB8_SNORM: number;
  62077. readonly RGBA8_SNORM: number;
  62078. readonly R8I: number;
  62079. readonly RG8I: number;
  62080. readonly RGB8I: number;
  62081. readonly RGBA8I: number;
  62082. readonly R8UI: number;
  62083. readonly RG8UI: number;
  62084. readonly RGB8UI: number;
  62085. readonly RGBA8UI: number;
  62086. readonly R16I: number;
  62087. readonly RG16I: number;
  62088. readonly RGB16I: number;
  62089. readonly RGBA16I: number;
  62090. readonly R16UI: number;
  62091. readonly RG16UI: number;
  62092. readonly RGB16UI: number;
  62093. readonly RGBA16UI: number;
  62094. readonly R32I: number;
  62095. readonly RG32I: number;
  62096. readonly RGB32I: number;
  62097. readonly RGBA32I: number;
  62098. readonly R32UI: number;
  62099. readonly RG32UI: number;
  62100. readonly RGB32UI: number;
  62101. readonly RGBA32UI: number;
  62102. readonly RGB10_A2UI: number;
  62103. readonly R11F_G11F_B10F: number;
  62104. readonly RGB9_E5: number;
  62105. readonly RGB10_A2: number;
  62106. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62107. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62108. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62109. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62110. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62111. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62112. 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;
  62113. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62114. readonly TRANSFORM_FEEDBACK: number;
  62115. readonly INTERLEAVED_ATTRIBS: number;
  62116. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62117. createTransformFeedback(): WebGLTransformFeedback;
  62118. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62119. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62120. beginTransformFeedback(primitiveMode: number): void;
  62121. endTransformFeedback(): void;
  62122. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62123. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62124. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62125. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62126. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62127. }
  62128. interface ImageBitmap {
  62129. readonly width: number;
  62130. readonly height: number;
  62131. close(): void;
  62132. }
  62133. interface WebGLQuery extends WebGLObject {
  62134. }
  62135. declare var WebGLQuery: {
  62136. prototype: WebGLQuery;
  62137. new(): WebGLQuery;
  62138. };
  62139. interface WebGLSampler extends WebGLObject {
  62140. }
  62141. declare var WebGLSampler: {
  62142. prototype: WebGLSampler;
  62143. new(): WebGLSampler;
  62144. };
  62145. interface WebGLSync extends WebGLObject {
  62146. }
  62147. declare var WebGLSync: {
  62148. prototype: WebGLSync;
  62149. new(): WebGLSync;
  62150. };
  62151. interface WebGLTransformFeedback extends WebGLObject {
  62152. }
  62153. declare var WebGLTransformFeedback: {
  62154. prototype: WebGLTransformFeedback;
  62155. new(): WebGLTransformFeedback;
  62156. };
  62157. interface WebGLVertexArrayObject extends WebGLObject {
  62158. }
  62159. declare var WebGLVertexArrayObject: {
  62160. prototype: WebGLVertexArrayObject;
  62161. new(): WebGLVertexArrayObject;
  62162. };
  62163. // Type definitions for WebVR API
  62164. // Project: https://w3c.github.io/webvr/
  62165. // Definitions by: six a <https://github.com/lostfictions>
  62166. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62167. interface VRDisplay extends EventTarget {
  62168. /**
  62169. * Dictionary of capabilities describing the VRDisplay.
  62170. */
  62171. readonly capabilities: VRDisplayCapabilities;
  62172. /**
  62173. * z-depth defining the far plane of the eye view frustum
  62174. * enables mapping of values in the render target depth
  62175. * attachment to scene coordinates. Initially set to 10000.0.
  62176. */
  62177. depthFar: number;
  62178. /**
  62179. * z-depth defining the near plane of the eye view frustum
  62180. * enables mapping of values in the render target depth
  62181. * attachment to scene coordinates. Initially set to 0.01.
  62182. */
  62183. depthNear: number;
  62184. /**
  62185. * An identifier for this distinct VRDisplay. Used as an
  62186. * association point in the Gamepad API.
  62187. */
  62188. readonly displayId: number;
  62189. /**
  62190. * A display name, a user-readable name identifying it.
  62191. */
  62192. readonly displayName: string;
  62193. readonly isConnected: boolean;
  62194. readonly isPresenting: boolean;
  62195. /**
  62196. * If this VRDisplay supports room-scale experiences, the optional
  62197. * stage attribute contains details on the room-scale parameters.
  62198. */
  62199. readonly stageParameters: VRStageParameters | null;
  62200. /**
  62201. * Passing the value returned by `requestAnimationFrame` to
  62202. * `cancelAnimationFrame` will unregister the callback.
  62203. * @param handle Define the hanle of the request to cancel
  62204. */
  62205. cancelAnimationFrame(handle: number): void;
  62206. /**
  62207. * Stops presenting to the VRDisplay.
  62208. * @returns a promise to know when it stopped
  62209. */
  62210. exitPresent(): Promise<void>;
  62211. /**
  62212. * Return the current VREyeParameters for the given eye.
  62213. * @param whichEye Define the eye we want the parameter for
  62214. * @returns the eye parameters
  62215. */
  62216. getEyeParameters(whichEye: string): VREyeParameters;
  62217. /**
  62218. * Populates the passed VRFrameData with the information required to render
  62219. * the current frame.
  62220. * @param frameData Define the data structure to populate
  62221. * @returns true if ok otherwise false
  62222. */
  62223. getFrameData(frameData: VRFrameData): boolean;
  62224. /**
  62225. * Get the layers currently being presented.
  62226. * @returns the list of VR layers
  62227. */
  62228. getLayers(): VRLayer[];
  62229. /**
  62230. * Return a VRPose containing the future predicted pose of the VRDisplay
  62231. * when the current frame will be presented. The value returned will not
  62232. * change until JavaScript has returned control to the browser.
  62233. *
  62234. * The VRPose will contain the position, orientation, velocity,
  62235. * and acceleration of each of these properties.
  62236. * @returns the pose object
  62237. */
  62238. getPose(): VRPose;
  62239. /**
  62240. * Return the current instantaneous pose of the VRDisplay, with no
  62241. * prediction applied.
  62242. * @returns the current instantaneous pose
  62243. */
  62244. getImmediatePose(): VRPose;
  62245. /**
  62246. * The callback passed to `requestAnimationFrame` will be called
  62247. * any time a new frame should be rendered. When the VRDisplay is
  62248. * presenting the callback will be called at the native refresh
  62249. * rate of the HMD. When not presenting this function acts
  62250. * identically to how window.requestAnimationFrame acts. Content should
  62251. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62252. * asynchronously from other displays and at differing refresh rates.
  62253. * @param callback Define the eaction to run next frame
  62254. * @returns the request handle it
  62255. */
  62256. requestAnimationFrame(callback: FrameRequestCallback): number;
  62257. /**
  62258. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62259. * Repeat calls while already presenting will update the VRLayers being displayed.
  62260. * @param layers Define the list of layer to present
  62261. * @returns a promise to know when the request has been fulfilled
  62262. */
  62263. requestPresent(layers: VRLayer[]): Promise<void>;
  62264. /**
  62265. * Reset the pose for this display, treating its current position and
  62266. * orientation as the "origin/zero" values. VRPose.position,
  62267. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62268. * updated when calling resetPose(). This should be called in only
  62269. * sitting-space experiences.
  62270. */
  62271. resetPose(): void;
  62272. /**
  62273. * The VRLayer provided to the VRDisplay will be captured and presented
  62274. * in the HMD. Calling this function has the same effect on the source
  62275. * canvas as any other operation that uses its source image, and canvases
  62276. * created without preserveDrawingBuffer set to true will be cleared.
  62277. * @param pose Define the pose to submit
  62278. */
  62279. submitFrame(pose?: VRPose): void;
  62280. }
  62281. declare var VRDisplay: {
  62282. prototype: VRDisplay;
  62283. new(): VRDisplay;
  62284. };
  62285. interface VRLayer {
  62286. leftBounds?: number[] | Float32Array | null;
  62287. rightBounds?: number[] | Float32Array | null;
  62288. source?: HTMLCanvasElement | null;
  62289. }
  62290. interface VRDisplayCapabilities {
  62291. readonly canPresent: boolean;
  62292. readonly hasExternalDisplay: boolean;
  62293. readonly hasOrientation: boolean;
  62294. readonly hasPosition: boolean;
  62295. readonly maxLayers: number;
  62296. }
  62297. interface VREyeParameters {
  62298. /** @deprecated */
  62299. readonly fieldOfView: VRFieldOfView;
  62300. readonly offset: Float32Array;
  62301. readonly renderHeight: number;
  62302. readonly renderWidth: number;
  62303. }
  62304. interface VRFieldOfView {
  62305. readonly downDegrees: number;
  62306. readonly leftDegrees: number;
  62307. readonly rightDegrees: number;
  62308. readonly upDegrees: number;
  62309. }
  62310. interface VRFrameData {
  62311. readonly leftProjectionMatrix: Float32Array;
  62312. readonly leftViewMatrix: Float32Array;
  62313. readonly pose: VRPose;
  62314. readonly rightProjectionMatrix: Float32Array;
  62315. readonly rightViewMatrix: Float32Array;
  62316. readonly timestamp: number;
  62317. }
  62318. interface VRPose {
  62319. readonly angularAcceleration: Float32Array | null;
  62320. readonly angularVelocity: Float32Array | null;
  62321. readonly linearAcceleration: Float32Array | null;
  62322. readonly linearVelocity: Float32Array | null;
  62323. readonly orientation: Float32Array | null;
  62324. readonly position: Float32Array | null;
  62325. readonly timestamp: number;
  62326. }
  62327. interface VRStageParameters {
  62328. sittingToStandingTransform?: Float32Array;
  62329. sizeX?: number;
  62330. sizeY?: number;
  62331. }
  62332. interface Navigator {
  62333. getVRDisplays(): Promise<VRDisplay[]>;
  62334. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62335. }
  62336. interface Window {
  62337. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62338. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62339. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62340. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62341. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62342. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62343. }
  62344. interface Gamepad {
  62345. readonly displayId: number;
  62346. }
  62347. interface XRDevice {
  62348. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62349. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62350. }
  62351. interface XRSession {
  62352. getInputSources(): Array<any>;
  62353. baseLayer: XRWebGLLayer;
  62354. requestFrameOfReference(type: string): Promise<void>;
  62355. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62356. end(): Promise<void>;
  62357. requestAnimationFrame: Function;
  62358. addEventListener: Function;
  62359. }
  62360. interface XRSessionCreationOptions {
  62361. outputContext?: WebGLRenderingContext | null;
  62362. immersive?: boolean;
  62363. environmentIntegration?: boolean;
  62364. }
  62365. interface XRLayer {
  62366. getViewport: Function;
  62367. framebufferWidth: number;
  62368. framebufferHeight: number;
  62369. }
  62370. interface XRView {
  62371. projectionMatrix: Float32Array;
  62372. }
  62373. interface XRFrame {
  62374. getDevicePose: Function;
  62375. getInputPose: Function;
  62376. views: Array<XRView>;
  62377. baseLayer: XRLayer;
  62378. }
  62379. interface XRFrameOfReference {
  62380. }
  62381. interface XRWebGLLayer extends XRLayer {
  62382. framebuffer: WebGLFramebuffer;
  62383. }
  62384. declare var XRWebGLLayer: {
  62385. prototype: XRWebGLLayer;
  62386. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62387. };
  62388. declare module "babylonjs" {
  62389. export * from "babylonjs/Legacy/legacy";
  62390. }
  62391. declare module BABYLON {
  62392. /** Alias type for value that can be null */
  62393. export type Nullable<T> = T | null;
  62394. /**
  62395. * Alias type for number that are floats
  62396. * @ignorenaming
  62397. */
  62398. export type float = number;
  62399. /**
  62400. * Alias type for number that are doubles.
  62401. * @ignorenaming
  62402. */
  62403. export type double = number;
  62404. /**
  62405. * Alias type for number that are integer
  62406. * @ignorenaming
  62407. */
  62408. export type int = number;
  62409. /** Alias type for number array or Float32Array */
  62410. export type FloatArray = number[] | Float32Array;
  62411. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62412. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62413. /**
  62414. * Alias for types that can be used by a Buffer or VertexBuffer.
  62415. */
  62416. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62417. /**
  62418. * Alias type for primitive types
  62419. * @ignorenaming
  62420. */
  62421. type Primitive = undefined | null | boolean | string | number | Function;
  62422. /**
  62423. * Type modifier to make all the properties of an object Readonly
  62424. */
  62425. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62426. /**
  62427. * Type modifier to make all the properties of an object Readonly recursively
  62428. */
  62429. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62430. /** @hidden */
  62431. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62432. }
  62433. /** @hidden */
  62434. /** @hidden */
  62435. type DeepImmutableObject<T> = {
  62436. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62437. };
  62438. }
  62439. declare module BABYLON {
  62440. /**
  62441. * Class containing a set of static utilities functions for arrays.
  62442. */
  62443. export class ArrayTools {
  62444. /**
  62445. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62446. * @param size the number of element to construct and put in the array
  62447. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62448. * @returns a new array filled with new objects
  62449. */
  62450. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62451. }
  62452. }
  62453. declare module BABYLON {
  62454. /**
  62455. * Scalar computation library
  62456. */
  62457. export class Scalar {
  62458. /**
  62459. * Two pi constants convenient for computation.
  62460. */
  62461. static TwoPi: number;
  62462. /**
  62463. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62464. * @param a number
  62465. * @param b number
  62466. * @param epsilon (default = 1.401298E-45)
  62467. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62468. */
  62469. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62470. /**
  62471. * Returns a string : the upper case translation of the number i to hexadecimal.
  62472. * @param i number
  62473. * @returns the upper case translation of the number i to hexadecimal.
  62474. */
  62475. static ToHex(i: number): string;
  62476. /**
  62477. * Returns -1 if value is negative and +1 is value is positive.
  62478. * @param value the value
  62479. * @returns the value itself if it's equal to zero.
  62480. */
  62481. static Sign(value: number): number;
  62482. /**
  62483. * Returns the value itself if it's between min and max.
  62484. * Returns min if the value is lower than min.
  62485. * Returns max if the value is greater than max.
  62486. * @param value the value to clmap
  62487. * @param min the min value to clamp to (default: 0)
  62488. * @param max the max value to clamp to (default: 1)
  62489. * @returns the clamped value
  62490. */
  62491. static Clamp(value: number, min?: number, max?: number): number;
  62492. /**
  62493. * the log2 of value.
  62494. * @param value the value to compute log2 of
  62495. * @returns the log2 of value.
  62496. */
  62497. static Log2(value: number): number;
  62498. /**
  62499. * Loops the value, so that it is never larger than length and never smaller than 0.
  62500. *
  62501. * This is similar to the modulo operator but it works with floating point numbers.
  62502. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62503. * With t = 5 and length = 2.5, the result would be 0.0.
  62504. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62505. * @param value the value
  62506. * @param length the length
  62507. * @returns the looped value
  62508. */
  62509. static Repeat(value: number, length: number): number;
  62510. /**
  62511. * Normalize the value between 0.0 and 1.0 using min and max values
  62512. * @param value value to normalize
  62513. * @param min max to normalize between
  62514. * @param max min to normalize between
  62515. * @returns the normalized value
  62516. */
  62517. static Normalize(value: number, min: number, max: number): number;
  62518. /**
  62519. * Denormalize the value from 0.0 and 1.0 using min and max values
  62520. * @param normalized value to denormalize
  62521. * @param min max to denormalize between
  62522. * @param max min to denormalize between
  62523. * @returns the denormalized value
  62524. */
  62525. static Denormalize(normalized: number, min: number, max: number): number;
  62526. /**
  62527. * Calculates the shortest difference between two given angles given in degrees.
  62528. * @param current current angle in degrees
  62529. * @param target target angle in degrees
  62530. * @returns the delta
  62531. */
  62532. static DeltaAngle(current: number, target: number): number;
  62533. /**
  62534. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62535. * @param tx value
  62536. * @param length length
  62537. * @returns The returned value will move back and forth between 0 and length
  62538. */
  62539. static PingPong(tx: number, length: number): number;
  62540. /**
  62541. * Interpolates between min and max with smoothing at the limits.
  62542. *
  62543. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62544. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62545. * @param from from
  62546. * @param to to
  62547. * @param tx value
  62548. * @returns the smooth stepped value
  62549. */
  62550. static SmoothStep(from: number, to: number, tx: number): number;
  62551. /**
  62552. * Moves a value current towards target.
  62553. *
  62554. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62555. * Negative values of maxDelta pushes the value away from target.
  62556. * @param current current value
  62557. * @param target target value
  62558. * @param maxDelta max distance to move
  62559. * @returns resulting value
  62560. */
  62561. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62562. /**
  62563. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62564. *
  62565. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62566. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62567. * @param current current value
  62568. * @param target target value
  62569. * @param maxDelta max distance to move
  62570. * @returns resulting angle
  62571. */
  62572. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62573. /**
  62574. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62575. * @param start start value
  62576. * @param end target value
  62577. * @param amount amount to lerp between
  62578. * @returns the lerped value
  62579. */
  62580. static Lerp(start: number, end: number, amount: number): number;
  62581. /**
  62582. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62583. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62584. * @param start start value
  62585. * @param end target value
  62586. * @param amount amount to lerp between
  62587. * @returns the lerped value
  62588. */
  62589. static LerpAngle(start: number, end: number, amount: number): number;
  62590. /**
  62591. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62592. * @param a start value
  62593. * @param b target value
  62594. * @param value value between a and b
  62595. * @returns the inverseLerp value
  62596. */
  62597. static InverseLerp(a: number, b: number, value: number): number;
  62598. /**
  62599. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62600. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62601. * @param value1 spline value
  62602. * @param tangent1 spline value
  62603. * @param value2 spline value
  62604. * @param tangent2 spline value
  62605. * @param amount input value
  62606. * @returns hermite result
  62607. */
  62608. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62609. /**
  62610. * Returns a random float number between and min and max values
  62611. * @param min min value of random
  62612. * @param max max value of random
  62613. * @returns random value
  62614. */
  62615. static RandomRange(min: number, max: number): number;
  62616. /**
  62617. * This function returns percentage of a number in a given range.
  62618. *
  62619. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62620. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62621. * @param number to convert to percentage
  62622. * @param min min range
  62623. * @param max max range
  62624. * @returns the percentage
  62625. */
  62626. static RangeToPercent(number: number, min: number, max: number): number;
  62627. /**
  62628. * This function returns number that corresponds to the percentage in a given range.
  62629. *
  62630. * PercentToRange(0.34,0,100) will return 34.
  62631. * @param percent to convert to number
  62632. * @param min min range
  62633. * @param max max range
  62634. * @returns the number
  62635. */
  62636. static PercentToRange(percent: number, min: number, max: number): number;
  62637. /**
  62638. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62639. * @param angle The angle to normalize in radian.
  62640. * @return The converted angle.
  62641. */
  62642. static NormalizeRadians(angle: number): number;
  62643. }
  62644. }
  62645. declare module BABYLON {
  62646. /**
  62647. * Constant used to convert a value to gamma space
  62648. * @ignorenaming
  62649. */
  62650. export const ToGammaSpace: number;
  62651. /**
  62652. * Constant used to convert a value to linear space
  62653. * @ignorenaming
  62654. */
  62655. export const ToLinearSpace = 2.2;
  62656. /**
  62657. * Constant used to define the minimal number value in Babylon.js
  62658. * @ignorenaming
  62659. */
  62660. let Epsilon: number;
  62661. /**
  62662. * Class used to hold a RBG color
  62663. */
  62664. export class Color3 {
  62665. /**
  62666. * Defines the red component (between 0 and 1, default is 0)
  62667. */
  62668. r: number;
  62669. /**
  62670. * Defines the green component (between 0 and 1, default is 0)
  62671. */
  62672. g: number;
  62673. /**
  62674. * Defines the blue component (between 0 and 1, default is 0)
  62675. */
  62676. b: number;
  62677. /**
  62678. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62679. * @param r defines the red component (between 0 and 1, default is 0)
  62680. * @param g defines the green component (between 0 and 1, default is 0)
  62681. * @param b defines the blue component (between 0 and 1, default is 0)
  62682. */
  62683. constructor(
  62684. /**
  62685. * Defines the red component (between 0 and 1, default is 0)
  62686. */
  62687. r?: number,
  62688. /**
  62689. * Defines the green component (between 0 and 1, default is 0)
  62690. */
  62691. g?: number,
  62692. /**
  62693. * Defines the blue component (between 0 and 1, default is 0)
  62694. */
  62695. b?: number);
  62696. /**
  62697. * Creates a string with the Color3 current values
  62698. * @returns the string representation of the Color3 object
  62699. */
  62700. toString(): string;
  62701. /**
  62702. * Returns the string "Color3"
  62703. * @returns "Color3"
  62704. */
  62705. getClassName(): string;
  62706. /**
  62707. * Compute the Color3 hash code
  62708. * @returns an unique number that can be used to hash Color3 objects
  62709. */
  62710. getHashCode(): number;
  62711. /**
  62712. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62713. * @param array defines the array where to store the r,g,b components
  62714. * @param index defines an optional index in the target array to define where to start storing values
  62715. * @returns the current Color3 object
  62716. */
  62717. toArray(array: FloatArray, index?: number): Color3;
  62718. /**
  62719. * Returns a new Color4 object from the current Color3 and the given alpha
  62720. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62721. * @returns a new Color4 object
  62722. */
  62723. toColor4(alpha?: number): Color4;
  62724. /**
  62725. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62726. * @returns the new array
  62727. */
  62728. asArray(): number[];
  62729. /**
  62730. * Returns the luminance value
  62731. * @returns a float value
  62732. */
  62733. toLuminance(): number;
  62734. /**
  62735. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62736. * @param otherColor defines the second operand
  62737. * @returns the new Color3 object
  62738. */
  62739. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62740. /**
  62741. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62742. * @param otherColor defines the second operand
  62743. * @param result defines the Color3 object where to store the result
  62744. * @returns the current Color3
  62745. */
  62746. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62747. /**
  62748. * Determines equality between Color3 objects
  62749. * @param otherColor defines the second operand
  62750. * @returns true if the rgb values are equal to the given ones
  62751. */
  62752. equals(otherColor: DeepImmutable<Color3>): boolean;
  62753. /**
  62754. * Determines equality between the current Color3 object and a set of r,b,g values
  62755. * @param r defines the red component to check
  62756. * @param g defines the green component to check
  62757. * @param b defines the blue component to check
  62758. * @returns true if the rgb values are equal to the given ones
  62759. */
  62760. equalsFloats(r: number, g: number, b: number): boolean;
  62761. /**
  62762. * Multiplies in place each rgb value by scale
  62763. * @param scale defines the scaling factor
  62764. * @returns the updated Color3
  62765. */
  62766. scale(scale: number): Color3;
  62767. /**
  62768. * Multiplies the rgb values by scale and stores the result into "result"
  62769. * @param scale defines the scaling factor
  62770. * @param result defines the Color3 object where to store the result
  62771. * @returns the unmodified current Color3
  62772. */
  62773. scaleToRef(scale: number, result: Color3): Color3;
  62774. /**
  62775. * Scale the current Color3 values by a factor and add the result to a given Color3
  62776. * @param scale defines the scale factor
  62777. * @param result defines color to store the result into
  62778. * @returns the unmodified current Color3
  62779. */
  62780. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62781. /**
  62782. * Clamps the rgb values by the min and max values and stores the result into "result"
  62783. * @param min defines minimum clamping value (default is 0)
  62784. * @param max defines maximum clamping value (default is 1)
  62785. * @param result defines color to store the result into
  62786. * @returns the original Color3
  62787. */
  62788. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62789. /**
  62790. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62791. * @param otherColor defines the second operand
  62792. * @returns the new Color3
  62793. */
  62794. add(otherColor: DeepImmutable<Color3>): Color3;
  62795. /**
  62796. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62797. * @param otherColor defines the second operand
  62798. * @param result defines Color3 object to store the result into
  62799. * @returns the unmodified current Color3
  62800. */
  62801. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62802. /**
  62803. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62804. * @param otherColor defines the second operand
  62805. * @returns the new Color3
  62806. */
  62807. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62808. /**
  62809. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62810. * @param otherColor defines the second operand
  62811. * @param result defines Color3 object to store the result into
  62812. * @returns the unmodified current Color3
  62813. */
  62814. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62815. /**
  62816. * Copy the current object
  62817. * @returns a new Color3 copied the current one
  62818. */
  62819. clone(): Color3;
  62820. /**
  62821. * Copies the rgb values from the source in the current Color3
  62822. * @param source defines the source Color3 object
  62823. * @returns the updated Color3 object
  62824. */
  62825. copyFrom(source: DeepImmutable<Color3>): Color3;
  62826. /**
  62827. * Updates the Color3 rgb values from the given floats
  62828. * @param r defines the red component to read from
  62829. * @param g defines the green component to read from
  62830. * @param b defines the blue component to read from
  62831. * @returns the current Color3 object
  62832. */
  62833. copyFromFloats(r: number, g: number, b: number): Color3;
  62834. /**
  62835. * Updates the Color3 rgb values from the given floats
  62836. * @param r defines the red component to read from
  62837. * @param g defines the green component to read from
  62838. * @param b defines the blue component to read from
  62839. * @returns the current Color3 object
  62840. */
  62841. set(r: number, g: number, b: number): Color3;
  62842. /**
  62843. * Compute the Color3 hexadecimal code as a string
  62844. * @returns a string containing the hexadecimal representation of the Color3 object
  62845. */
  62846. toHexString(): string;
  62847. /**
  62848. * Computes a new Color3 converted from the current one to linear space
  62849. * @returns a new Color3 object
  62850. */
  62851. toLinearSpace(): Color3;
  62852. /**
  62853. * Converts current color in rgb space to HSV values
  62854. * @returns a new color3 representing the HSV values
  62855. */
  62856. toHSV(): Color3;
  62857. /**
  62858. * Converts current color in rgb space to HSV values
  62859. * @param result defines the Color3 where to store the HSV values
  62860. */
  62861. toHSVToRef(result: Color3): void;
  62862. /**
  62863. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  62864. * @param convertedColor defines the Color3 object where to store the linear space version
  62865. * @returns the unmodified Color3
  62866. */
  62867. toLinearSpaceToRef(convertedColor: Color3): Color3;
  62868. /**
  62869. * Computes a new Color3 converted from the current one to gamma space
  62870. * @returns a new Color3 object
  62871. */
  62872. toGammaSpace(): Color3;
  62873. /**
  62874. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  62875. * @param convertedColor defines the Color3 object where to store the gamma space version
  62876. * @returns the unmodified Color3
  62877. */
  62878. toGammaSpaceToRef(convertedColor: Color3): Color3;
  62879. private static _BlackReadOnly;
  62880. /**
  62881. * Convert Hue, saturation and value to a Color3 (RGB)
  62882. * @param hue defines the hue
  62883. * @param saturation defines the saturation
  62884. * @param value defines the value
  62885. * @param result defines the Color3 where to store the RGB values
  62886. */
  62887. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  62888. /**
  62889. * Creates a new Color3 from the string containing valid hexadecimal values
  62890. * @param hex defines a string containing valid hexadecimal values
  62891. * @returns a new Color3 object
  62892. */
  62893. static FromHexString(hex: string): Color3;
  62894. /**
  62895. * Creates a new Color3 from the starting index of the given array
  62896. * @param array defines the source array
  62897. * @param offset defines an offset in the source array
  62898. * @returns a new Color3 object
  62899. */
  62900. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  62901. /**
  62902. * Creates a new Color3 from integer values (< 256)
  62903. * @param r defines the red component to read from (value between 0 and 255)
  62904. * @param g defines the green component to read from (value between 0 and 255)
  62905. * @param b defines the blue component to read from (value between 0 and 255)
  62906. * @returns a new Color3 object
  62907. */
  62908. static FromInts(r: number, g: number, b: number): Color3;
  62909. /**
  62910. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62911. * @param start defines the start Color3 value
  62912. * @param end defines the end Color3 value
  62913. * @param amount defines the gradient value between start and end
  62914. * @returns a new Color3 object
  62915. */
  62916. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  62917. /**
  62918. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62919. * @param left defines the start value
  62920. * @param right defines the end value
  62921. * @param amount defines the gradient factor
  62922. * @param result defines the Color3 object where to store the result
  62923. */
  62924. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  62925. /**
  62926. * Returns a Color3 value containing a red color
  62927. * @returns a new Color3 object
  62928. */
  62929. static Red(): Color3;
  62930. /**
  62931. * Returns a Color3 value containing a green color
  62932. * @returns a new Color3 object
  62933. */
  62934. static Green(): Color3;
  62935. /**
  62936. * Returns a Color3 value containing a blue color
  62937. * @returns a new Color3 object
  62938. */
  62939. static Blue(): Color3;
  62940. /**
  62941. * Returns a Color3 value containing a black color
  62942. * @returns a new Color3 object
  62943. */
  62944. static Black(): Color3;
  62945. /**
  62946. * Gets a Color3 value containing a black color that must not be updated
  62947. */
  62948. static readonly BlackReadOnly: DeepImmutable<Color3>;
  62949. /**
  62950. * Returns a Color3 value containing a white color
  62951. * @returns a new Color3 object
  62952. */
  62953. static White(): Color3;
  62954. /**
  62955. * Returns a Color3 value containing a purple color
  62956. * @returns a new Color3 object
  62957. */
  62958. static Purple(): Color3;
  62959. /**
  62960. * Returns a Color3 value containing a magenta color
  62961. * @returns a new Color3 object
  62962. */
  62963. static Magenta(): Color3;
  62964. /**
  62965. * Returns a Color3 value containing a yellow color
  62966. * @returns a new Color3 object
  62967. */
  62968. static Yellow(): Color3;
  62969. /**
  62970. * Returns a Color3 value containing a gray color
  62971. * @returns a new Color3 object
  62972. */
  62973. static Gray(): Color3;
  62974. /**
  62975. * Returns a Color3 value containing a teal color
  62976. * @returns a new Color3 object
  62977. */
  62978. static Teal(): Color3;
  62979. /**
  62980. * Returns a Color3 value containing a random color
  62981. * @returns a new Color3 object
  62982. */
  62983. static Random(): Color3;
  62984. }
  62985. /**
  62986. * Class used to hold a RBGA color
  62987. */
  62988. export class Color4 {
  62989. /**
  62990. * Defines the red component (between 0 and 1, default is 0)
  62991. */
  62992. r: number;
  62993. /**
  62994. * Defines the green component (between 0 and 1, default is 0)
  62995. */
  62996. g: number;
  62997. /**
  62998. * Defines the blue component (between 0 and 1, default is 0)
  62999. */
  63000. b: number;
  63001. /**
  63002. * Defines the alpha component (between 0 and 1, default is 1)
  63003. */
  63004. a: number;
  63005. /**
  63006. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63007. * @param r defines the red component (between 0 and 1, default is 0)
  63008. * @param g defines the green component (between 0 and 1, default is 0)
  63009. * @param b defines the blue component (between 0 and 1, default is 0)
  63010. * @param a defines the alpha component (between 0 and 1, default is 1)
  63011. */
  63012. constructor(
  63013. /**
  63014. * Defines the red component (between 0 and 1, default is 0)
  63015. */
  63016. r?: number,
  63017. /**
  63018. * Defines the green component (between 0 and 1, default is 0)
  63019. */
  63020. g?: number,
  63021. /**
  63022. * Defines the blue component (between 0 and 1, default is 0)
  63023. */
  63024. b?: number,
  63025. /**
  63026. * Defines the alpha component (between 0 and 1, default is 1)
  63027. */
  63028. a?: number);
  63029. /**
  63030. * Adds in place the given Color4 values to the current Color4 object
  63031. * @param right defines the second operand
  63032. * @returns the current updated Color4 object
  63033. */
  63034. addInPlace(right: DeepImmutable<Color4>): Color4;
  63035. /**
  63036. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63037. * @returns the new array
  63038. */
  63039. asArray(): number[];
  63040. /**
  63041. * Stores from the starting index in the given array the Color4 successive values
  63042. * @param array defines the array where to store the r,g,b components
  63043. * @param index defines an optional index in the target array to define where to start storing values
  63044. * @returns the current Color4 object
  63045. */
  63046. toArray(array: number[], index?: number): Color4;
  63047. /**
  63048. * Determines equality between Color4 objects
  63049. * @param otherColor defines the second operand
  63050. * @returns true if the rgba values are equal to the given ones
  63051. */
  63052. equals(otherColor: DeepImmutable<Color4>): boolean;
  63053. /**
  63054. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63055. * @param right defines the second operand
  63056. * @returns a new Color4 object
  63057. */
  63058. add(right: DeepImmutable<Color4>): Color4;
  63059. /**
  63060. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63061. * @param right defines the second operand
  63062. * @returns a new Color4 object
  63063. */
  63064. subtract(right: DeepImmutable<Color4>): Color4;
  63065. /**
  63066. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63067. * @param right defines the second operand
  63068. * @param result defines the Color4 object where to store the result
  63069. * @returns the current Color4 object
  63070. */
  63071. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63072. /**
  63073. * Creates a new Color4 with the current Color4 values multiplied by scale
  63074. * @param scale defines the scaling factor to apply
  63075. * @returns a new Color4 object
  63076. */
  63077. scale(scale: number): Color4;
  63078. /**
  63079. * Multiplies the current Color4 values by scale and stores the result in "result"
  63080. * @param scale defines the scaling factor to apply
  63081. * @param result defines the Color4 object where to store the result
  63082. * @returns the current unmodified Color4
  63083. */
  63084. scaleToRef(scale: number, result: Color4): Color4;
  63085. /**
  63086. * Scale the current Color4 values by a factor and add the result to a given Color4
  63087. * @param scale defines the scale factor
  63088. * @param result defines the Color4 object where to store the result
  63089. * @returns the unmodified current Color4
  63090. */
  63091. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63092. /**
  63093. * Clamps the rgb values by the min and max values and stores the result into "result"
  63094. * @param min defines minimum clamping value (default is 0)
  63095. * @param max defines maximum clamping value (default is 1)
  63096. * @param result defines color to store the result into.
  63097. * @returns the cuurent Color4
  63098. */
  63099. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63100. /**
  63101. * Multipy an Color4 value by another and return a new Color4 object
  63102. * @param color defines the Color4 value to multiply by
  63103. * @returns a new Color4 object
  63104. */
  63105. multiply(color: Color4): Color4;
  63106. /**
  63107. * Multipy a Color4 value by another and push the result in a reference value
  63108. * @param color defines the Color4 value to multiply by
  63109. * @param result defines the Color4 to fill the result in
  63110. * @returns the result Color4
  63111. */
  63112. multiplyToRef(color: Color4, result: Color4): Color4;
  63113. /**
  63114. * Creates a string with the Color4 current values
  63115. * @returns the string representation of the Color4 object
  63116. */
  63117. toString(): string;
  63118. /**
  63119. * Returns the string "Color4"
  63120. * @returns "Color4"
  63121. */
  63122. getClassName(): string;
  63123. /**
  63124. * Compute the Color4 hash code
  63125. * @returns an unique number that can be used to hash Color4 objects
  63126. */
  63127. getHashCode(): number;
  63128. /**
  63129. * Creates a new Color4 copied from the current one
  63130. * @returns a new Color4 object
  63131. */
  63132. clone(): Color4;
  63133. /**
  63134. * Copies the given Color4 values into the current one
  63135. * @param source defines the source Color4 object
  63136. * @returns the current updated Color4 object
  63137. */
  63138. copyFrom(source: Color4): Color4;
  63139. /**
  63140. * Copies the given float values into the current one
  63141. * @param r defines the red component to read from
  63142. * @param g defines the green component to read from
  63143. * @param b defines the blue component to read from
  63144. * @param a defines the alpha component to read from
  63145. * @returns the current updated Color4 object
  63146. */
  63147. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63148. /**
  63149. * Copies the given float values into the current one
  63150. * @param r defines the red component to read from
  63151. * @param g defines the green component to read from
  63152. * @param b defines the blue component to read from
  63153. * @param a defines the alpha component to read from
  63154. * @returns the current updated Color4 object
  63155. */
  63156. set(r: number, g: number, b: number, a: number): Color4;
  63157. /**
  63158. * Compute the Color4 hexadecimal code as a string
  63159. * @returns a string containing the hexadecimal representation of the Color4 object
  63160. */
  63161. toHexString(): string;
  63162. /**
  63163. * Computes a new Color4 converted from the current one to linear space
  63164. * @returns a new Color4 object
  63165. */
  63166. toLinearSpace(): Color4;
  63167. /**
  63168. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63169. * @param convertedColor defines the Color4 object where to store the linear space version
  63170. * @returns the unmodified Color4
  63171. */
  63172. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63173. /**
  63174. * Computes a new Color4 converted from the current one to gamma space
  63175. * @returns a new Color4 object
  63176. */
  63177. toGammaSpace(): Color4;
  63178. /**
  63179. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63180. * @param convertedColor defines the Color4 object where to store the gamma space version
  63181. * @returns the unmodified Color4
  63182. */
  63183. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63184. /**
  63185. * Creates a new Color4 from the string containing valid hexadecimal values
  63186. * @param hex defines a string containing valid hexadecimal values
  63187. * @returns a new Color4 object
  63188. */
  63189. static FromHexString(hex: string): Color4;
  63190. /**
  63191. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63192. * @param left defines the start value
  63193. * @param right defines the end value
  63194. * @param amount defines the gradient factor
  63195. * @returns a new Color4 object
  63196. */
  63197. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63198. /**
  63199. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63200. * @param left defines the start value
  63201. * @param right defines the end value
  63202. * @param amount defines the gradient factor
  63203. * @param result defines the Color4 object where to store data
  63204. */
  63205. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63206. /**
  63207. * Creates a new Color4 from a Color3 and an alpha value
  63208. * @param color3 defines the source Color3 to read from
  63209. * @param alpha defines the alpha component (1.0 by default)
  63210. * @returns a new Color4 object
  63211. */
  63212. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63213. /**
  63214. * Creates a new Color4 from the starting index element of the given array
  63215. * @param array defines the source array to read from
  63216. * @param offset defines the offset in the source array
  63217. * @returns a new Color4 object
  63218. */
  63219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63220. /**
  63221. * Creates a new Color3 from integer values (< 256)
  63222. * @param r defines the red component to read from (value between 0 and 255)
  63223. * @param g defines the green component to read from (value between 0 and 255)
  63224. * @param b defines the blue component to read from (value between 0 and 255)
  63225. * @param a defines the alpha component to read from (value between 0 and 255)
  63226. * @returns a new Color3 object
  63227. */
  63228. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63229. /**
  63230. * Check the content of a given array and convert it to an array containing RGBA data
  63231. * If the original array was already containing count * 4 values then it is returned directly
  63232. * @param colors defines the array to check
  63233. * @param count defines the number of RGBA data to expect
  63234. * @returns an array containing count * 4 values (RGBA)
  63235. */
  63236. static CheckColors4(colors: number[], count: number): number[];
  63237. }
  63238. /**
  63239. * Class representing a vector containing 2 coordinates
  63240. */
  63241. export class Vector2 {
  63242. /** defines the first coordinate */
  63243. x: number;
  63244. /** defines the second coordinate */
  63245. y: number;
  63246. /**
  63247. * Creates a new Vector2 from the given x and y coordinates
  63248. * @param x defines the first coordinate
  63249. * @param y defines the second coordinate
  63250. */
  63251. constructor(
  63252. /** defines the first coordinate */
  63253. x?: number,
  63254. /** defines the second coordinate */
  63255. y?: number);
  63256. /**
  63257. * Gets a string with the Vector2 coordinates
  63258. * @returns a string with the Vector2 coordinates
  63259. */
  63260. toString(): string;
  63261. /**
  63262. * Gets class name
  63263. * @returns the string "Vector2"
  63264. */
  63265. getClassName(): string;
  63266. /**
  63267. * Gets current vector hash code
  63268. * @returns the Vector2 hash code as a number
  63269. */
  63270. getHashCode(): number;
  63271. /**
  63272. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63273. * @param array defines the source array
  63274. * @param index defines the offset in source array
  63275. * @returns the current Vector2
  63276. */
  63277. toArray(array: FloatArray, index?: number): Vector2;
  63278. /**
  63279. * Copy the current vector to an array
  63280. * @returns a new array with 2 elements: the Vector2 coordinates.
  63281. */
  63282. asArray(): number[];
  63283. /**
  63284. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63285. * @param source defines the source Vector2
  63286. * @returns the current updated Vector2
  63287. */
  63288. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63289. /**
  63290. * Sets the Vector2 coordinates with the given floats
  63291. * @param x defines the first coordinate
  63292. * @param y defines the second coordinate
  63293. * @returns the current updated Vector2
  63294. */
  63295. copyFromFloats(x: number, y: number): Vector2;
  63296. /**
  63297. * Sets the Vector2 coordinates with the given floats
  63298. * @param x defines the first coordinate
  63299. * @param y defines the second coordinate
  63300. * @returns the current updated Vector2
  63301. */
  63302. set(x: number, y: number): Vector2;
  63303. /**
  63304. * Add another vector with the current one
  63305. * @param otherVector defines the other vector
  63306. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63307. */
  63308. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63309. /**
  63310. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63311. * @param otherVector defines the other vector
  63312. * @param result defines the target vector
  63313. * @returns the unmodified current Vector2
  63314. */
  63315. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63316. /**
  63317. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63318. * @param otherVector defines the other vector
  63319. * @returns the current updated Vector2
  63320. */
  63321. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63322. /**
  63323. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63324. * @param otherVector defines the other vector
  63325. * @returns a new Vector2
  63326. */
  63327. addVector3(otherVector: Vector3): Vector2;
  63328. /**
  63329. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63330. * @param otherVector defines the other vector
  63331. * @returns a new Vector2
  63332. */
  63333. subtract(otherVector: Vector2): Vector2;
  63334. /**
  63335. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63336. * @param otherVector defines the other vector
  63337. * @param result defines the target vector
  63338. * @returns the unmodified current Vector2
  63339. */
  63340. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63341. /**
  63342. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63343. * @param otherVector defines the other vector
  63344. * @returns the current updated Vector2
  63345. */
  63346. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63347. /**
  63348. * Multiplies in place the current Vector2 coordinates by the given ones
  63349. * @param otherVector defines the other vector
  63350. * @returns the current updated Vector2
  63351. */
  63352. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63353. /**
  63354. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63355. * @param otherVector defines the other vector
  63356. * @returns a new Vector2
  63357. */
  63358. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63359. /**
  63360. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63361. * @param otherVector defines the other vector
  63362. * @param result defines the target vector
  63363. * @returns the unmodified current Vector2
  63364. */
  63365. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63366. /**
  63367. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63368. * @param x defines the first coordinate
  63369. * @param y defines the second coordinate
  63370. * @returns a new Vector2
  63371. */
  63372. multiplyByFloats(x: number, y: number): Vector2;
  63373. /**
  63374. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63375. * @param otherVector defines the other vector
  63376. * @returns a new Vector2
  63377. */
  63378. divide(otherVector: Vector2): Vector2;
  63379. /**
  63380. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63381. * @param otherVector defines the other vector
  63382. * @param result defines the target vector
  63383. * @returns the unmodified current Vector2
  63384. */
  63385. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63386. /**
  63387. * Divides the current Vector2 coordinates by the given ones
  63388. * @param otherVector defines the other vector
  63389. * @returns the current updated Vector2
  63390. */
  63391. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63392. /**
  63393. * Gets a new Vector2 with current Vector2 negated coordinates
  63394. * @returns a new Vector2
  63395. */
  63396. negate(): Vector2;
  63397. /**
  63398. * Multiply the Vector2 coordinates by scale
  63399. * @param scale defines the scaling factor
  63400. * @returns the current updated Vector2
  63401. */
  63402. scaleInPlace(scale: number): Vector2;
  63403. /**
  63404. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63405. * @param scale defines the scaling factor
  63406. * @returns a new Vector2
  63407. */
  63408. scale(scale: number): Vector2;
  63409. /**
  63410. * Scale the current Vector2 values by a factor to a given Vector2
  63411. * @param scale defines the scale factor
  63412. * @param result defines the Vector2 object where to store the result
  63413. * @returns the unmodified current Vector2
  63414. */
  63415. scaleToRef(scale: number, result: Vector2): Vector2;
  63416. /**
  63417. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63418. * @param scale defines the scale factor
  63419. * @param result defines the Vector2 object where to store the result
  63420. * @returns the unmodified current Vector2
  63421. */
  63422. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63423. /**
  63424. * Gets a boolean if two vectors are equals
  63425. * @param otherVector defines the other vector
  63426. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63427. */
  63428. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63429. /**
  63430. * Gets a boolean if two vectors are equals (using an epsilon value)
  63431. * @param otherVector defines the other vector
  63432. * @param epsilon defines the minimal distance to consider equality
  63433. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63434. */
  63435. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63436. /**
  63437. * Gets a new Vector2 from current Vector2 floored values
  63438. * @returns a new Vector2
  63439. */
  63440. floor(): Vector2;
  63441. /**
  63442. * Gets a new Vector2 from current Vector2 floored values
  63443. * @returns a new Vector2
  63444. */
  63445. fract(): Vector2;
  63446. /**
  63447. * Gets the length of the vector
  63448. * @returns the vector length (float)
  63449. */
  63450. length(): number;
  63451. /**
  63452. * Gets the vector squared length
  63453. * @returns the vector squared length (float)
  63454. */
  63455. lengthSquared(): number;
  63456. /**
  63457. * Normalize the vector
  63458. * @returns the current updated Vector2
  63459. */
  63460. normalize(): Vector2;
  63461. /**
  63462. * Gets a new Vector2 copied from the Vector2
  63463. * @returns a new Vector2
  63464. */
  63465. clone(): Vector2;
  63466. /**
  63467. * Gets a new Vector2(0, 0)
  63468. * @returns a new Vector2
  63469. */
  63470. static Zero(): Vector2;
  63471. /**
  63472. * Gets a new Vector2(1, 1)
  63473. * @returns a new Vector2
  63474. */
  63475. static One(): Vector2;
  63476. /**
  63477. * Gets a new Vector2 set from the given index element of the given array
  63478. * @param array defines the data source
  63479. * @param offset defines the offset in the data source
  63480. * @returns a new Vector2
  63481. */
  63482. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63483. /**
  63484. * Sets "result" from the given index element of the given array
  63485. * @param array defines the data source
  63486. * @param offset defines the offset in the data source
  63487. * @param result defines the target vector
  63488. */
  63489. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63490. /**
  63491. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63492. * @param value1 defines 1st point of control
  63493. * @param value2 defines 2nd point of control
  63494. * @param value3 defines 3rd point of control
  63495. * @param value4 defines 4th point of control
  63496. * @param amount defines the interpolation factor
  63497. * @returns a new Vector2
  63498. */
  63499. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63500. /**
  63501. * 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".
  63502. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63503. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63504. * @param value defines the value to clamp
  63505. * @param min defines the lower limit
  63506. * @param max defines the upper limit
  63507. * @returns a new Vector2
  63508. */
  63509. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63510. /**
  63511. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63512. * @param value1 defines the 1st control point
  63513. * @param tangent1 defines the outgoing tangent
  63514. * @param value2 defines the 2nd control point
  63515. * @param tangent2 defines the incoming tangent
  63516. * @param amount defines the interpolation factor
  63517. * @returns a new Vector2
  63518. */
  63519. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63520. /**
  63521. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63522. * @param start defines the start vector
  63523. * @param end defines the end vector
  63524. * @param amount defines the interpolation factor
  63525. * @returns a new Vector2
  63526. */
  63527. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63528. /**
  63529. * Gets the dot product of the vector "left" and the vector "right"
  63530. * @param left defines first vector
  63531. * @param right defines second vector
  63532. * @returns the dot product (float)
  63533. */
  63534. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63535. /**
  63536. * Returns a new Vector2 equal to the normalized given vector
  63537. * @param vector defines the vector to normalize
  63538. * @returns a new Vector2
  63539. */
  63540. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63541. /**
  63542. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63543. * @param left defines 1st vector
  63544. * @param right defines 2nd vector
  63545. * @returns a new Vector2
  63546. */
  63547. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63548. /**
  63549. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63550. * @param left defines 1st vector
  63551. * @param right defines 2nd vector
  63552. * @returns a new Vector2
  63553. */
  63554. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63555. /**
  63556. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63557. * @param vector defines the vector to transform
  63558. * @param transformation defines the matrix to apply
  63559. * @returns a new Vector2
  63560. */
  63561. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63562. /**
  63563. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63564. * @param vector defines the vector to transform
  63565. * @param transformation defines the matrix to apply
  63566. * @param result defines the target vector
  63567. */
  63568. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63569. /**
  63570. * Determines if a given vector is included in a triangle
  63571. * @param p defines the vector to test
  63572. * @param p0 defines 1st triangle point
  63573. * @param p1 defines 2nd triangle point
  63574. * @param p2 defines 3rd triangle point
  63575. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63576. */
  63577. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63578. /**
  63579. * Gets the distance between the vectors "value1" and "value2"
  63580. * @param value1 defines first vector
  63581. * @param value2 defines second vector
  63582. * @returns the distance between vectors
  63583. */
  63584. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63585. /**
  63586. * Returns the squared distance between the vectors "value1" and "value2"
  63587. * @param value1 defines first vector
  63588. * @param value2 defines second vector
  63589. * @returns the squared distance between vectors
  63590. */
  63591. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63592. /**
  63593. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63594. * @param value1 defines first vector
  63595. * @param value2 defines second vector
  63596. * @returns a new Vector2
  63597. */
  63598. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63599. /**
  63600. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63601. * @param p defines the middle point
  63602. * @param segA defines one point of the segment
  63603. * @param segB defines the other point of the segment
  63604. * @returns the shortest distance
  63605. */
  63606. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63607. }
  63608. /**
  63609. * Classed used to store (x,y,z) vector representation
  63610. * A Vector3 is the main object used in 3D geometry
  63611. * It can represent etiher the coordinates of a point the space, either a direction
  63612. * Reminder: js uses a left handed forward facing system
  63613. */
  63614. export class Vector3 {
  63615. /**
  63616. * Defines the first coordinates (on X axis)
  63617. */
  63618. x: number;
  63619. /**
  63620. * Defines the second coordinates (on Y axis)
  63621. */
  63622. y: number;
  63623. /**
  63624. * Defines the third coordinates (on Z axis)
  63625. */
  63626. z: number;
  63627. private static _UpReadOnly;
  63628. private static _ZeroReadOnly;
  63629. /**
  63630. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63631. * @param x defines the first coordinates (on X axis)
  63632. * @param y defines the second coordinates (on Y axis)
  63633. * @param z defines the third coordinates (on Z axis)
  63634. */
  63635. constructor(
  63636. /**
  63637. * Defines the first coordinates (on X axis)
  63638. */
  63639. x?: number,
  63640. /**
  63641. * Defines the second coordinates (on Y axis)
  63642. */
  63643. y?: number,
  63644. /**
  63645. * Defines the third coordinates (on Z axis)
  63646. */
  63647. z?: number);
  63648. /**
  63649. * Creates a string representation of the Vector3
  63650. * @returns a string with the Vector3 coordinates.
  63651. */
  63652. toString(): string;
  63653. /**
  63654. * Gets the class name
  63655. * @returns the string "Vector3"
  63656. */
  63657. getClassName(): string;
  63658. /**
  63659. * Creates the Vector3 hash code
  63660. * @returns a number which tends to be unique between Vector3 instances
  63661. */
  63662. getHashCode(): number;
  63663. /**
  63664. * Creates an array containing three elements : the coordinates of the Vector3
  63665. * @returns a new array of numbers
  63666. */
  63667. asArray(): number[];
  63668. /**
  63669. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63670. * @param array defines the destination array
  63671. * @param index defines the offset in the destination array
  63672. * @returns the current Vector3
  63673. */
  63674. toArray(array: FloatArray, index?: number): Vector3;
  63675. /**
  63676. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63677. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63678. */
  63679. toQuaternion(): Quaternion;
  63680. /**
  63681. * Adds the given vector to the current Vector3
  63682. * @param otherVector defines the second operand
  63683. * @returns the current updated Vector3
  63684. */
  63685. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63686. /**
  63687. * Adds the given coordinates to the current Vector3
  63688. * @param x defines the x coordinate of the operand
  63689. * @param y defines the y coordinate of the operand
  63690. * @param z defines the z coordinate of the operand
  63691. * @returns the current updated Vector3
  63692. */
  63693. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63694. /**
  63695. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63696. * @param otherVector defines the second operand
  63697. * @returns the resulting Vector3
  63698. */
  63699. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63700. /**
  63701. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63702. * @param otherVector defines the second operand
  63703. * @param result defines the Vector3 object where to store the result
  63704. * @returns the current Vector3
  63705. */
  63706. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63707. /**
  63708. * Subtract the given vector from the current Vector3
  63709. * @param otherVector defines the second operand
  63710. * @returns the current updated Vector3
  63711. */
  63712. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63713. /**
  63714. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63715. * @param otherVector defines the second operand
  63716. * @returns the resulting Vector3
  63717. */
  63718. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63719. /**
  63720. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63721. * @param otherVector defines the second operand
  63722. * @param result defines the Vector3 object where to store the result
  63723. * @returns the current Vector3
  63724. */
  63725. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63726. /**
  63727. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63728. * @param x defines the x coordinate of the operand
  63729. * @param y defines the y coordinate of the operand
  63730. * @param z defines the z coordinate of the operand
  63731. * @returns the resulting Vector3
  63732. */
  63733. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63734. /**
  63735. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63736. * @param x defines the x coordinate of the operand
  63737. * @param y defines the y coordinate of the operand
  63738. * @param z defines the z coordinate of the operand
  63739. * @param result defines the Vector3 object where to store the result
  63740. * @returns the current Vector3
  63741. */
  63742. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63743. /**
  63744. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63745. * @returns a new Vector3
  63746. */
  63747. negate(): Vector3;
  63748. /**
  63749. * Multiplies the Vector3 coordinates by the float "scale"
  63750. * @param scale defines the multiplier factor
  63751. * @returns the current updated Vector3
  63752. */
  63753. scaleInPlace(scale: number): Vector3;
  63754. /**
  63755. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63756. * @param scale defines the multiplier factor
  63757. * @returns a new Vector3
  63758. */
  63759. scale(scale: number): Vector3;
  63760. /**
  63761. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63762. * @param scale defines the multiplier factor
  63763. * @param result defines the Vector3 object where to store the result
  63764. * @returns the current Vector3
  63765. */
  63766. scaleToRef(scale: number, result: Vector3): Vector3;
  63767. /**
  63768. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63769. * @param scale defines the scale factor
  63770. * @param result defines the Vector3 object where to store the result
  63771. * @returns the unmodified current Vector3
  63772. */
  63773. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63774. /**
  63775. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63776. * @param otherVector defines the second operand
  63777. * @returns true if both vectors are equals
  63778. */
  63779. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63780. /**
  63781. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63782. * @param otherVector defines the second operand
  63783. * @param epsilon defines the minimal distance to define values as equals
  63784. * @returns true if both vectors are distant less than epsilon
  63785. */
  63786. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63787. /**
  63788. * Returns true if the current Vector3 coordinates equals the given floats
  63789. * @param x defines the x coordinate of the operand
  63790. * @param y defines the y coordinate of the operand
  63791. * @param z defines the z coordinate of the operand
  63792. * @returns true if both vectors are equals
  63793. */
  63794. equalsToFloats(x: number, y: number, z: number): boolean;
  63795. /**
  63796. * Multiplies the current Vector3 coordinates by the given ones
  63797. * @param otherVector defines the second operand
  63798. * @returns the current updated Vector3
  63799. */
  63800. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63801. /**
  63802. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63803. * @param otherVector defines the second operand
  63804. * @returns the new Vector3
  63805. */
  63806. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63807. /**
  63808. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63809. * @param otherVector defines the second operand
  63810. * @param result defines the Vector3 object where to store the result
  63811. * @returns the current Vector3
  63812. */
  63813. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63814. /**
  63815. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63816. * @param x defines the x coordinate of the operand
  63817. * @param y defines the y coordinate of the operand
  63818. * @param z defines the z coordinate of the operand
  63819. * @returns the new Vector3
  63820. */
  63821. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63822. /**
  63823. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63824. * @param otherVector defines the second operand
  63825. * @returns the new Vector3
  63826. */
  63827. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63828. /**
  63829. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63830. * @param otherVector defines the second operand
  63831. * @param result defines the Vector3 object where to store the result
  63832. * @returns the current Vector3
  63833. */
  63834. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63835. /**
  63836. * Divides the current Vector3 coordinates by the given ones.
  63837. * @param otherVector defines the second operand
  63838. * @returns the current updated Vector3
  63839. */
  63840. divideInPlace(otherVector: Vector3): Vector3;
  63841. /**
  63842. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  63843. * @param other defines the second operand
  63844. * @returns the current updated Vector3
  63845. */
  63846. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63847. /**
  63848. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  63849. * @param other defines the second operand
  63850. * @returns the current updated Vector3
  63851. */
  63852. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63853. /**
  63854. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  63855. * @param x defines the x coordinate of the operand
  63856. * @param y defines the y coordinate of the operand
  63857. * @param z defines the z coordinate of the operand
  63858. * @returns the current updated Vector3
  63859. */
  63860. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63861. /**
  63862. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  63863. * @param x defines the x coordinate of the operand
  63864. * @param y defines the y coordinate of the operand
  63865. * @param z defines the z coordinate of the operand
  63866. * @returns the current updated Vector3
  63867. */
  63868. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63869. /**
  63870. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  63871. * Check if is non uniform within a certain amount of decimal places to account for this
  63872. * @param epsilon the amount the values can differ
  63873. * @returns if the the vector is non uniform to a certain number of decimal places
  63874. */
  63875. isNonUniformWithinEpsilon(epsilon: number): boolean;
  63876. /**
  63877. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  63878. */
  63879. readonly isNonUniform: boolean;
  63880. /**
  63881. * Gets a new Vector3 from current Vector3 floored values
  63882. * @returns a new Vector3
  63883. */
  63884. floor(): Vector3;
  63885. /**
  63886. * Gets a new Vector3 from current Vector3 floored values
  63887. * @returns a new Vector3
  63888. */
  63889. fract(): Vector3;
  63890. /**
  63891. * Gets the length of the Vector3
  63892. * @returns the length of the Vecto3
  63893. */
  63894. length(): number;
  63895. /**
  63896. * Gets the squared length of the Vector3
  63897. * @returns squared length of the Vector3
  63898. */
  63899. lengthSquared(): number;
  63900. /**
  63901. * Normalize the current Vector3.
  63902. * Please note that this is an in place operation.
  63903. * @returns the current updated Vector3
  63904. */
  63905. normalize(): Vector3;
  63906. /**
  63907. * Reorders the x y z properties of the vector in place
  63908. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  63909. * @returns the current updated vector
  63910. */
  63911. reorderInPlace(order: string): this;
  63912. /**
  63913. * Rotates the vector around 0,0,0 by a quaternion
  63914. * @param quaternion the rotation quaternion
  63915. * @param result vector to store the result
  63916. * @returns the resulting vector
  63917. */
  63918. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  63919. /**
  63920. * Rotates a vector around a given point
  63921. * @param quaternion the rotation quaternion
  63922. * @param point the point to rotate around
  63923. * @param result vector to store the result
  63924. * @returns the resulting vector
  63925. */
  63926. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  63927. /**
  63928. * Normalize the current Vector3 with the given input length.
  63929. * Please note that this is an in place operation.
  63930. * @param len the length of the vector
  63931. * @returns the current updated Vector3
  63932. */
  63933. normalizeFromLength(len: number): Vector3;
  63934. /**
  63935. * Normalize the current Vector3 to a new vector
  63936. * @returns the new Vector3
  63937. */
  63938. normalizeToNew(): Vector3;
  63939. /**
  63940. * Normalize the current Vector3 to the reference
  63941. * @param reference define the Vector3 to update
  63942. * @returns the updated Vector3
  63943. */
  63944. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  63945. /**
  63946. * Creates a new Vector3 copied from the current Vector3
  63947. * @returns the new Vector3
  63948. */
  63949. clone(): Vector3;
  63950. /**
  63951. * Copies the given vector coordinates to the current Vector3 ones
  63952. * @param source defines the source Vector3
  63953. * @returns the current updated Vector3
  63954. */
  63955. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  63956. /**
  63957. * Copies the given floats to the current Vector3 coordinates
  63958. * @param x defines the x coordinate of the operand
  63959. * @param y defines the y coordinate of the operand
  63960. * @param z defines the z coordinate of the operand
  63961. * @returns the current updated Vector3
  63962. */
  63963. copyFromFloats(x: number, y: number, z: number): Vector3;
  63964. /**
  63965. * Copies the given floats to the current Vector3 coordinates
  63966. * @param x defines the x coordinate of the operand
  63967. * @param y defines the y coordinate of the operand
  63968. * @param z defines the z coordinate of the operand
  63969. * @returns the current updated Vector3
  63970. */
  63971. set(x: number, y: number, z: number): Vector3;
  63972. /**
  63973. * Copies the given float to the current Vector3 coordinates
  63974. * @param v defines the x, y and z coordinates of the operand
  63975. * @returns the current updated Vector3
  63976. */
  63977. setAll(v: number): Vector3;
  63978. /**
  63979. * Get the clip factor between two vectors
  63980. * @param vector0 defines the first operand
  63981. * @param vector1 defines the second operand
  63982. * @param axis defines the axis to use
  63983. * @param size defines the size along the axis
  63984. * @returns the clip factor
  63985. */
  63986. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  63987. /**
  63988. * Get angle between two vectors
  63989. * @param vector0 angle between vector0 and vector1
  63990. * @param vector1 angle between vector0 and vector1
  63991. * @param normal direction of the normal
  63992. * @return the angle between vector0 and vector1
  63993. */
  63994. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  63995. /**
  63996. * Returns a new Vector3 set from the index "offset" of the given array
  63997. * @param array defines the source array
  63998. * @param offset defines the offset in the source array
  63999. * @returns the new Vector3
  64000. */
  64001. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64002. /**
  64003. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64004. * This function is deprecated. Use FromArray instead
  64005. * @param array defines the source array
  64006. * @param offset defines the offset in the source array
  64007. * @returns the new Vector3
  64008. */
  64009. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64010. /**
  64011. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64012. * @param array defines the source array
  64013. * @param offset defines the offset in the source array
  64014. * @param result defines the Vector3 where to store the result
  64015. */
  64016. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64017. /**
  64018. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64019. * This function is deprecated. Use FromArrayToRef instead.
  64020. * @param array defines the source array
  64021. * @param offset defines the offset in the source array
  64022. * @param result defines the Vector3 where to store the result
  64023. */
  64024. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64025. /**
  64026. * Sets the given vector "result" with the given floats.
  64027. * @param x defines the x coordinate of the source
  64028. * @param y defines the y coordinate of the source
  64029. * @param z defines the z coordinate of the source
  64030. * @param result defines the Vector3 where to store the result
  64031. */
  64032. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64033. /**
  64034. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64035. * @returns a new empty Vector3
  64036. */
  64037. static Zero(): Vector3;
  64038. /**
  64039. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64040. * @returns a new unit Vector3
  64041. */
  64042. static One(): Vector3;
  64043. /**
  64044. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64045. * @returns a new up Vector3
  64046. */
  64047. static Up(): Vector3;
  64048. /**
  64049. * Gets a up Vector3 that must not be updated
  64050. */
  64051. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64052. /**
  64053. * Gets a zero Vector3 that must not be updated
  64054. */
  64055. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64056. /**
  64057. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64058. * @returns a new down Vector3
  64059. */
  64060. static Down(): Vector3;
  64061. /**
  64062. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64063. * @returns a new forward Vector3
  64064. */
  64065. static Forward(): Vector3;
  64066. /**
  64067. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64068. * @returns a new forward Vector3
  64069. */
  64070. static Backward(): Vector3;
  64071. /**
  64072. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64073. * @returns a new right Vector3
  64074. */
  64075. static Right(): Vector3;
  64076. /**
  64077. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64078. * @returns a new left Vector3
  64079. */
  64080. static Left(): Vector3;
  64081. /**
  64082. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64083. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64084. * @param vector defines the Vector3 to transform
  64085. * @param transformation defines the transformation matrix
  64086. * @returns the transformed Vector3
  64087. */
  64088. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64089. /**
  64090. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64091. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64092. * @param vector defines the Vector3 to transform
  64093. * @param transformation defines the transformation matrix
  64094. * @param result defines the Vector3 where to store the result
  64095. */
  64096. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64097. /**
  64098. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64099. * This method computes tranformed coordinates only, not transformed direction vectors
  64100. * @param x define the x coordinate of the source vector
  64101. * @param y define the y coordinate of the source vector
  64102. * @param z define the z coordinate of the source vector
  64103. * @param transformation defines the transformation matrix
  64104. * @param result defines the Vector3 where to store the result
  64105. */
  64106. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64107. /**
  64108. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64109. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64110. * @param vector defines the Vector3 to transform
  64111. * @param transformation defines the transformation matrix
  64112. * @returns the new Vector3
  64113. */
  64114. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64115. /**
  64116. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64117. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64118. * @param vector defines the Vector3 to transform
  64119. * @param transformation defines the transformation matrix
  64120. * @param result defines the Vector3 where to store the result
  64121. */
  64122. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64123. /**
  64124. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64125. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64126. * @param x define the x coordinate of the source vector
  64127. * @param y define the y coordinate of the source vector
  64128. * @param z define the z coordinate of the source vector
  64129. * @param transformation defines the transformation matrix
  64130. * @param result defines the Vector3 where to store the result
  64131. */
  64132. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64133. /**
  64134. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64135. * @param value1 defines the first control point
  64136. * @param value2 defines the second control point
  64137. * @param value3 defines the third control point
  64138. * @param value4 defines the fourth control point
  64139. * @param amount defines the amount on the spline to use
  64140. * @returns the new Vector3
  64141. */
  64142. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64143. /**
  64144. * 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"
  64145. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64146. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64147. * @param value defines the current value
  64148. * @param min defines the lower range value
  64149. * @param max defines the upper range value
  64150. * @returns the new Vector3
  64151. */
  64152. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64153. /**
  64154. * 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"
  64155. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64156. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64157. * @param value defines the current value
  64158. * @param min defines the lower range value
  64159. * @param max defines the upper range value
  64160. * @param result defines the Vector3 where to store the result
  64161. */
  64162. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64163. /**
  64164. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64165. * @param value1 defines the first control point
  64166. * @param tangent1 defines the first tangent vector
  64167. * @param value2 defines the second control point
  64168. * @param tangent2 defines the second tangent vector
  64169. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64170. * @returns the new Vector3
  64171. */
  64172. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64173. /**
  64174. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64175. * @param start defines the start value
  64176. * @param end defines the end value
  64177. * @param amount max defines amount between both (between 0 and 1)
  64178. * @returns the new Vector3
  64179. */
  64180. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64181. /**
  64182. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64183. * @param start defines the start value
  64184. * @param end defines the end value
  64185. * @param amount max defines amount between both (between 0 and 1)
  64186. * @param result defines the Vector3 where to store the result
  64187. */
  64188. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64189. /**
  64190. * Returns the dot product (float) between the vectors "left" and "right"
  64191. * @param left defines the left operand
  64192. * @param right defines the right operand
  64193. * @returns the dot product
  64194. */
  64195. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64196. /**
  64197. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64198. * The cross product is then orthogonal to both "left" and "right"
  64199. * @param left defines the left operand
  64200. * @param right defines the right operand
  64201. * @returns the cross product
  64202. */
  64203. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64204. /**
  64205. * Sets the given vector "result" with the cross product of "left" and "right"
  64206. * The cross product is then orthogonal to both "left" and "right"
  64207. * @param left defines the left operand
  64208. * @param right defines the right operand
  64209. * @param result defines the Vector3 where to store the result
  64210. */
  64211. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64212. /**
  64213. * Returns a new Vector3 as the normalization of the given vector
  64214. * @param vector defines the Vector3 to normalize
  64215. * @returns the new Vector3
  64216. */
  64217. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64218. /**
  64219. * Sets the given vector "result" with the normalization of the given first vector
  64220. * @param vector defines the Vector3 to normalize
  64221. * @param result defines the Vector3 where to store the result
  64222. */
  64223. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64224. /**
  64225. * Project a Vector3 onto screen space
  64226. * @param vector defines the Vector3 to project
  64227. * @param world defines the world matrix to use
  64228. * @param transform defines the transform (view x projection) matrix to use
  64229. * @param viewport defines the screen viewport to use
  64230. * @returns the new Vector3
  64231. */
  64232. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64233. /** @hidden */
  64234. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64235. /**
  64236. * Unproject from screen space to object space
  64237. * @param source defines the screen space Vector3 to use
  64238. * @param viewportWidth defines the current width of the viewport
  64239. * @param viewportHeight defines the current height of the viewport
  64240. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64241. * @param transform defines the transform (view x projection) matrix to use
  64242. * @returns the new Vector3
  64243. */
  64244. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64245. /**
  64246. * Unproject from screen space to object space
  64247. * @param source defines the screen space Vector3 to use
  64248. * @param viewportWidth defines the current width of the viewport
  64249. * @param viewportHeight defines the current height of the viewport
  64250. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64251. * @param view defines the view matrix to use
  64252. * @param projection defines the projection matrix to use
  64253. * @returns the new Vector3
  64254. */
  64255. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64256. /**
  64257. * Unproject from screen space to object space
  64258. * @param source defines the screen space Vector3 to use
  64259. * @param viewportWidth defines the current width of the viewport
  64260. * @param viewportHeight defines the current height of the viewport
  64261. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64262. * @param view defines the view matrix to use
  64263. * @param projection defines the projection matrix to use
  64264. * @param result defines the Vector3 where to store the result
  64265. */
  64266. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64267. /**
  64268. * Unproject from screen space to object space
  64269. * @param sourceX defines the screen space x coordinate to use
  64270. * @param sourceY defines the screen space y coordinate to use
  64271. * @param sourceZ defines the screen space z coordinate to use
  64272. * @param viewportWidth defines the current width of the viewport
  64273. * @param viewportHeight defines the current height of the viewport
  64274. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64275. * @param view defines the view matrix to use
  64276. * @param projection defines the projection matrix to use
  64277. * @param result defines the Vector3 where to store the result
  64278. */
  64279. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64280. /**
  64281. * Gets the minimal coordinate values between two Vector3
  64282. * @param left defines the first operand
  64283. * @param right defines the second operand
  64284. * @returns the new Vector3
  64285. */
  64286. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64287. /**
  64288. * Gets the maximal coordinate values between two Vector3
  64289. * @param left defines the first operand
  64290. * @param right defines the second operand
  64291. * @returns the new Vector3
  64292. */
  64293. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64294. /**
  64295. * Returns the distance between the vectors "value1" and "value2"
  64296. * @param value1 defines the first operand
  64297. * @param value2 defines the second operand
  64298. * @returns the distance
  64299. */
  64300. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64301. /**
  64302. * Returns the squared distance between the vectors "value1" and "value2"
  64303. * @param value1 defines the first operand
  64304. * @param value2 defines the second operand
  64305. * @returns the squared distance
  64306. */
  64307. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64308. /**
  64309. * Returns a new Vector3 located at the center between "value1" and "value2"
  64310. * @param value1 defines the first operand
  64311. * @param value2 defines the second operand
  64312. * @returns the new Vector3
  64313. */
  64314. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64315. /**
  64316. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64317. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64318. * to something in order to rotate it from its local system to the given target system
  64319. * Note: axis1, axis2 and axis3 are normalized during this operation
  64320. * @param axis1 defines the first axis
  64321. * @param axis2 defines the second axis
  64322. * @param axis3 defines the third axis
  64323. * @returns a new Vector3
  64324. */
  64325. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64326. /**
  64327. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64328. * @param axis1 defines the first axis
  64329. * @param axis2 defines the second axis
  64330. * @param axis3 defines the third axis
  64331. * @param ref defines the Vector3 where to store the result
  64332. */
  64333. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64334. }
  64335. /**
  64336. * Vector4 class created for EulerAngle class conversion to Quaternion
  64337. */
  64338. export class Vector4 {
  64339. /** x value of the vector */
  64340. x: number;
  64341. /** y value of the vector */
  64342. y: number;
  64343. /** z value of the vector */
  64344. z: number;
  64345. /** w value of the vector */
  64346. w: number;
  64347. /**
  64348. * Creates a Vector4 object from the given floats.
  64349. * @param x x value of the vector
  64350. * @param y y value of the vector
  64351. * @param z z value of the vector
  64352. * @param w w value of the vector
  64353. */
  64354. constructor(
  64355. /** x value of the vector */
  64356. x: number,
  64357. /** y value of the vector */
  64358. y: number,
  64359. /** z value of the vector */
  64360. z: number,
  64361. /** w value of the vector */
  64362. w: number);
  64363. /**
  64364. * Returns the string with the Vector4 coordinates.
  64365. * @returns a string containing all the vector values
  64366. */
  64367. toString(): string;
  64368. /**
  64369. * Returns the string "Vector4".
  64370. * @returns "Vector4"
  64371. */
  64372. getClassName(): string;
  64373. /**
  64374. * Returns the Vector4 hash code.
  64375. * @returns a unique hash code
  64376. */
  64377. getHashCode(): number;
  64378. /**
  64379. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64380. * @returns the resulting array
  64381. */
  64382. asArray(): number[];
  64383. /**
  64384. * Populates the given array from the given index with the Vector4 coordinates.
  64385. * @param array array to populate
  64386. * @param index index of the array to start at (default: 0)
  64387. * @returns the Vector4.
  64388. */
  64389. toArray(array: FloatArray, index?: number): Vector4;
  64390. /**
  64391. * Adds the given vector to the current Vector4.
  64392. * @param otherVector the vector to add
  64393. * @returns the updated Vector4.
  64394. */
  64395. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64396. /**
  64397. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64398. * @param otherVector the vector to add
  64399. * @returns the resulting vector
  64400. */
  64401. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64402. /**
  64403. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64404. * @param otherVector the vector to add
  64405. * @param result the vector to store the result
  64406. * @returns the current Vector4.
  64407. */
  64408. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64409. /**
  64410. * Subtract in place the given vector from the current Vector4.
  64411. * @param otherVector the vector to subtract
  64412. * @returns the updated Vector4.
  64413. */
  64414. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64415. /**
  64416. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64417. * @param otherVector the vector to add
  64418. * @returns the new vector with the result
  64419. */
  64420. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64421. /**
  64422. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64423. * @param otherVector the vector to subtract
  64424. * @param result the vector to store the result
  64425. * @returns the current Vector4.
  64426. */
  64427. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64428. /**
  64429. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64430. */
  64431. /**
  64432. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64433. * @param x value to subtract
  64434. * @param y value to subtract
  64435. * @param z value to subtract
  64436. * @param w value to subtract
  64437. * @returns new vector containing the result
  64438. */
  64439. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64440. /**
  64441. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64442. * @param x value to subtract
  64443. * @param y value to subtract
  64444. * @param z value to subtract
  64445. * @param w value to subtract
  64446. * @param result the vector to store the result in
  64447. * @returns the current Vector4.
  64448. */
  64449. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64450. /**
  64451. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64452. * @returns a new vector with the negated values
  64453. */
  64454. negate(): Vector4;
  64455. /**
  64456. * Multiplies the current Vector4 coordinates by scale (float).
  64457. * @param scale the number to scale with
  64458. * @returns the updated Vector4.
  64459. */
  64460. scaleInPlace(scale: number): Vector4;
  64461. /**
  64462. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64463. * @param scale the number to scale with
  64464. * @returns a new vector with the result
  64465. */
  64466. scale(scale: number): Vector4;
  64467. /**
  64468. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64469. * @param scale the number to scale with
  64470. * @param result a vector to store the result in
  64471. * @returns the current Vector4.
  64472. */
  64473. scaleToRef(scale: number, result: Vector4): Vector4;
  64474. /**
  64475. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64476. * @param scale defines the scale factor
  64477. * @param result defines the Vector4 object where to store the result
  64478. * @returns the unmodified current Vector4
  64479. */
  64480. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64481. /**
  64482. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64483. * @param otherVector the vector to compare against
  64484. * @returns true if they are equal
  64485. */
  64486. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64487. /**
  64488. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64489. * @param otherVector vector to compare against
  64490. * @param epsilon (Default: very small number)
  64491. * @returns true if they are equal
  64492. */
  64493. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64494. /**
  64495. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64496. * @param x x value to compare against
  64497. * @param y y value to compare against
  64498. * @param z z value to compare against
  64499. * @param w w value to compare against
  64500. * @returns true if equal
  64501. */
  64502. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64503. /**
  64504. * Multiplies in place the current Vector4 by the given one.
  64505. * @param otherVector vector to multiple with
  64506. * @returns the updated Vector4.
  64507. */
  64508. multiplyInPlace(otherVector: Vector4): Vector4;
  64509. /**
  64510. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64511. * @param otherVector vector to multiple with
  64512. * @returns resulting new vector
  64513. */
  64514. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64515. /**
  64516. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64517. * @param otherVector vector to multiple with
  64518. * @param result vector to store the result
  64519. * @returns the current Vector4.
  64520. */
  64521. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64522. /**
  64523. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64524. * @param x x value multiply with
  64525. * @param y y value multiply with
  64526. * @param z z value multiply with
  64527. * @param w w value multiply with
  64528. * @returns resulting new vector
  64529. */
  64530. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64531. /**
  64532. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64533. * @param otherVector vector to devide with
  64534. * @returns resulting new vector
  64535. */
  64536. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64537. /**
  64538. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64539. * @param otherVector vector to devide with
  64540. * @param result vector to store the result
  64541. * @returns the current Vector4.
  64542. */
  64543. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64544. /**
  64545. * Divides the current Vector3 coordinates by the given ones.
  64546. * @param otherVector vector to devide with
  64547. * @returns the updated Vector3.
  64548. */
  64549. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64550. /**
  64551. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64552. * @param other defines the second operand
  64553. * @returns the current updated Vector4
  64554. */
  64555. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64556. /**
  64557. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64558. * @param other defines the second operand
  64559. * @returns the current updated Vector4
  64560. */
  64561. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64562. /**
  64563. * Gets a new Vector4 from current Vector4 floored values
  64564. * @returns a new Vector4
  64565. */
  64566. floor(): Vector4;
  64567. /**
  64568. * Gets a new Vector4 from current Vector3 floored values
  64569. * @returns a new Vector4
  64570. */
  64571. fract(): Vector4;
  64572. /**
  64573. * Returns the Vector4 length (float).
  64574. * @returns the length
  64575. */
  64576. length(): number;
  64577. /**
  64578. * Returns the Vector4 squared length (float).
  64579. * @returns the length squared
  64580. */
  64581. lengthSquared(): number;
  64582. /**
  64583. * Normalizes in place the Vector4.
  64584. * @returns the updated Vector4.
  64585. */
  64586. normalize(): Vector4;
  64587. /**
  64588. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64589. * @returns this converted to a new vector3
  64590. */
  64591. toVector3(): Vector3;
  64592. /**
  64593. * Returns a new Vector4 copied from the current one.
  64594. * @returns the new cloned vector
  64595. */
  64596. clone(): Vector4;
  64597. /**
  64598. * Updates the current Vector4 with the given one coordinates.
  64599. * @param source the source vector to copy from
  64600. * @returns the updated Vector4.
  64601. */
  64602. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64603. /**
  64604. * Updates the current Vector4 coordinates with the given floats.
  64605. * @param x float to copy from
  64606. * @param y float to copy from
  64607. * @param z float to copy from
  64608. * @param w float to copy from
  64609. * @returns the updated Vector4.
  64610. */
  64611. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64612. /**
  64613. * Updates the current Vector4 coordinates with the given floats.
  64614. * @param x float to set from
  64615. * @param y float to set from
  64616. * @param z float to set from
  64617. * @param w float to set from
  64618. * @returns the updated Vector4.
  64619. */
  64620. set(x: number, y: number, z: number, w: number): Vector4;
  64621. /**
  64622. * Copies the given float to the current Vector3 coordinates
  64623. * @param v defines the x, y, z and w coordinates of the operand
  64624. * @returns the current updated Vector3
  64625. */
  64626. setAll(v: number): Vector4;
  64627. /**
  64628. * Returns a new Vector4 set from the starting index of the given array.
  64629. * @param array the array to pull values from
  64630. * @param offset the offset into the array to start at
  64631. * @returns the new vector
  64632. */
  64633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64634. /**
  64635. * Updates the given vector "result" from the starting index of the given array.
  64636. * @param array the array to pull values from
  64637. * @param offset the offset into the array to start at
  64638. * @param result the vector to store the result in
  64639. */
  64640. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64641. /**
  64642. * Updates the given vector "result" from the starting index of the given Float32Array.
  64643. * @param array the array to pull values from
  64644. * @param offset the offset into the array to start at
  64645. * @param result the vector to store the result in
  64646. */
  64647. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64648. /**
  64649. * Updates the given vector "result" coordinates from the given floats.
  64650. * @param x float to set from
  64651. * @param y float to set from
  64652. * @param z float to set from
  64653. * @param w float to set from
  64654. * @param result the vector to the floats in
  64655. */
  64656. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64657. /**
  64658. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64659. * @returns the new vector
  64660. */
  64661. static Zero(): Vector4;
  64662. /**
  64663. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64664. * @returns the new vector
  64665. */
  64666. static One(): Vector4;
  64667. /**
  64668. * Returns a new normalized Vector4 from the given one.
  64669. * @param vector the vector to normalize
  64670. * @returns the vector
  64671. */
  64672. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64673. /**
  64674. * Updates the given vector "result" from the normalization of the given one.
  64675. * @param vector the vector to normalize
  64676. * @param result the vector to store the result in
  64677. */
  64678. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64679. /**
  64680. * Returns a vector with the minimum values from the left and right vectors
  64681. * @param left left vector to minimize
  64682. * @param right right vector to minimize
  64683. * @returns a new vector with the minimum of the left and right vector values
  64684. */
  64685. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64686. /**
  64687. * Returns a vector with the maximum values from the left and right vectors
  64688. * @param left left vector to maximize
  64689. * @param right right vector to maximize
  64690. * @returns a new vector with the maximum of the left and right vector values
  64691. */
  64692. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64693. /**
  64694. * Returns the distance (float) between the vectors "value1" and "value2".
  64695. * @param value1 value to calulate the distance between
  64696. * @param value2 value to calulate the distance between
  64697. * @return the distance between the two vectors
  64698. */
  64699. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64700. /**
  64701. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64702. * @param value1 value to calulate the distance between
  64703. * @param value2 value to calulate the distance between
  64704. * @return the distance between the two vectors squared
  64705. */
  64706. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64707. /**
  64708. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64709. * @param value1 value to calulate the center between
  64710. * @param value2 value to calulate the center between
  64711. * @return the center between the two vectors
  64712. */
  64713. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64714. /**
  64715. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64716. * This methods computes transformed normalized direction vectors only.
  64717. * @param vector the vector to transform
  64718. * @param transformation the transformation matrix to apply
  64719. * @returns the new vector
  64720. */
  64721. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64722. /**
  64723. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64724. * This methods computes transformed normalized direction vectors only.
  64725. * @param vector the vector to transform
  64726. * @param transformation the transformation matrix to apply
  64727. * @param result the vector to store the result in
  64728. */
  64729. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64730. /**
  64731. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64732. * This methods computes transformed normalized direction vectors only.
  64733. * @param x value to transform
  64734. * @param y value to transform
  64735. * @param z value to transform
  64736. * @param w value to transform
  64737. * @param transformation the transformation matrix to apply
  64738. * @param result the vector to store the results in
  64739. */
  64740. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64741. /**
  64742. * Creates a new Vector4 from a Vector3
  64743. * @param source defines the source data
  64744. * @param w defines the 4th component (default is 0)
  64745. * @returns a new Vector4
  64746. */
  64747. static FromVector3(source: Vector3, w?: number): Vector4;
  64748. }
  64749. /**
  64750. * Interface for the size containing width and height
  64751. */
  64752. export interface ISize {
  64753. /**
  64754. * Width
  64755. */
  64756. width: number;
  64757. /**
  64758. * Heighht
  64759. */
  64760. height: number;
  64761. }
  64762. /**
  64763. * Size containing widht and height
  64764. */
  64765. export class Size implements ISize {
  64766. /**
  64767. * Width
  64768. */
  64769. width: number;
  64770. /**
  64771. * Height
  64772. */
  64773. height: number;
  64774. /**
  64775. * Creates a Size object from the given width and height (floats).
  64776. * @param width width of the new size
  64777. * @param height height of the new size
  64778. */
  64779. constructor(width: number, height: number);
  64780. /**
  64781. * Returns a string with the Size width and height
  64782. * @returns a string with the Size width and height
  64783. */
  64784. toString(): string;
  64785. /**
  64786. * "Size"
  64787. * @returns the string "Size"
  64788. */
  64789. getClassName(): string;
  64790. /**
  64791. * Returns the Size hash code.
  64792. * @returns a hash code for a unique width and height
  64793. */
  64794. getHashCode(): number;
  64795. /**
  64796. * Updates the current size from the given one.
  64797. * @param src the given size
  64798. */
  64799. copyFrom(src: Size): void;
  64800. /**
  64801. * Updates in place the current Size from the given floats.
  64802. * @param width width of the new size
  64803. * @param height height of the new size
  64804. * @returns the updated Size.
  64805. */
  64806. copyFromFloats(width: number, height: number): Size;
  64807. /**
  64808. * Updates in place the current Size from the given floats.
  64809. * @param width width to set
  64810. * @param height height to set
  64811. * @returns the updated Size.
  64812. */
  64813. set(width: number, height: number): Size;
  64814. /**
  64815. * Multiplies the width and height by numbers
  64816. * @param w factor to multiple the width by
  64817. * @param h factor to multiple the height by
  64818. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64819. */
  64820. multiplyByFloats(w: number, h: number): Size;
  64821. /**
  64822. * Clones the size
  64823. * @returns a new Size copied from the given one.
  64824. */
  64825. clone(): Size;
  64826. /**
  64827. * True if the current Size and the given one width and height are strictly equal.
  64828. * @param other the other size to compare against
  64829. * @returns True if the current Size and the given one width and height are strictly equal.
  64830. */
  64831. equals(other: Size): boolean;
  64832. /**
  64833. * The surface of the Size : width * height (float).
  64834. */
  64835. readonly surface: number;
  64836. /**
  64837. * Create a new size of zero
  64838. * @returns a new Size set to (0.0, 0.0)
  64839. */
  64840. static Zero(): Size;
  64841. /**
  64842. * Sums the width and height of two sizes
  64843. * @param otherSize size to add to this size
  64844. * @returns a new Size set as the addition result of the current Size and the given one.
  64845. */
  64846. add(otherSize: Size): Size;
  64847. /**
  64848. * Subtracts the width and height of two
  64849. * @param otherSize size to subtract to this size
  64850. * @returns a new Size set as the subtraction result of the given one from the current Size.
  64851. */
  64852. subtract(otherSize: Size): Size;
  64853. /**
  64854. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  64855. * @param start starting size to lerp between
  64856. * @param end end size to lerp between
  64857. * @param amount amount to lerp between the start and end values
  64858. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  64859. */
  64860. static Lerp(start: Size, end: Size, amount: number): Size;
  64861. }
  64862. /**
  64863. * Class used to store quaternion data
  64864. * @see https://en.wikipedia.org/wiki/Quaternion
  64865. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  64866. */
  64867. export class Quaternion {
  64868. /** defines the first component (0 by default) */
  64869. x: number;
  64870. /** defines the second component (0 by default) */
  64871. y: number;
  64872. /** defines the third component (0 by default) */
  64873. z: number;
  64874. /** defines the fourth component (1.0 by default) */
  64875. w: number;
  64876. /**
  64877. * Creates a new Quaternion from the given floats
  64878. * @param x defines the first component (0 by default)
  64879. * @param y defines the second component (0 by default)
  64880. * @param z defines the third component (0 by default)
  64881. * @param w defines the fourth component (1.0 by default)
  64882. */
  64883. constructor(
  64884. /** defines the first component (0 by default) */
  64885. x?: number,
  64886. /** defines the second component (0 by default) */
  64887. y?: number,
  64888. /** defines the third component (0 by default) */
  64889. z?: number,
  64890. /** defines the fourth component (1.0 by default) */
  64891. w?: number);
  64892. /**
  64893. * Gets a string representation for the current quaternion
  64894. * @returns a string with the Quaternion coordinates
  64895. */
  64896. toString(): string;
  64897. /**
  64898. * Gets the class name of the quaternion
  64899. * @returns the string "Quaternion"
  64900. */
  64901. getClassName(): string;
  64902. /**
  64903. * Gets a hash code for this quaternion
  64904. * @returns the quaternion hash code
  64905. */
  64906. getHashCode(): number;
  64907. /**
  64908. * Copy the quaternion to an array
  64909. * @returns a new array populated with 4 elements from the quaternion coordinates
  64910. */
  64911. asArray(): number[];
  64912. /**
  64913. * Check if two quaternions are equals
  64914. * @param otherQuaternion defines the second operand
  64915. * @return true if the current quaternion and the given one coordinates are strictly equals
  64916. */
  64917. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  64918. /**
  64919. * Clone the current quaternion
  64920. * @returns a new quaternion copied from the current one
  64921. */
  64922. clone(): Quaternion;
  64923. /**
  64924. * Copy a quaternion to the current one
  64925. * @param other defines the other quaternion
  64926. * @returns the updated current quaternion
  64927. */
  64928. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  64929. /**
  64930. * Updates the current quaternion with the given float coordinates
  64931. * @param x defines the x coordinate
  64932. * @param y defines the y coordinate
  64933. * @param z defines the z coordinate
  64934. * @param w defines the w coordinate
  64935. * @returns the updated current quaternion
  64936. */
  64937. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  64938. /**
  64939. * Updates the current quaternion from the given float coordinates
  64940. * @param x defines the x coordinate
  64941. * @param y defines the y coordinate
  64942. * @param z defines the z coordinate
  64943. * @param w defines the w coordinate
  64944. * @returns the updated current quaternion
  64945. */
  64946. set(x: number, y: number, z: number, w: number): Quaternion;
  64947. /**
  64948. * Adds two quaternions
  64949. * @param other defines the second operand
  64950. * @returns a new quaternion as the addition result of the given one and the current quaternion
  64951. */
  64952. add(other: DeepImmutable<Quaternion>): Quaternion;
  64953. /**
  64954. * Add a quaternion to the current one
  64955. * @param other defines the quaternion to add
  64956. * @returns the current quaternion
  64957. */
  64958. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  64959. /**
  64960. * Subtract two quaternions
  64961. * @param other defines the second operand
  64962. * @returns a new quaternion as the subtraction result of the given one from the current one
  64963. */
  64964. subtract(other: Quaternion): Quaternion;
  64965. /**
  64966. * Multiplies the current quaternion by a scale factor
  64967. * @param value defines the scale factor
  64968. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  64969. */
  64970. scale(value: number): Quaternion;
  64971. /**
  64972. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  64973. * @param scale defines the scale factor
  64974. * @param result defines the Quaternion object where to store the result
  64975. * @returns the unmodified current quaternion
  64976. */
  64977. scaleToRef(scale: number, result: Quaternion): Quaternion;
  64978. /**
  64979. * Multiplies in place the current quaternion by a scale factor
  64980. * @param value defines the scale factor
  64981. * @returns the current modified quaternion
  64982. */
  64983. scaleInPlace(value: number): Quaternion;
  64984. /**
  64985. * Scale the current quaternion values by a factor and add the result to a given quaternion
  64986. * @param scale defines the scale factor
  64987. * @param result defines the Quaternion object where to store the result
  64988. * @returns the unmodified current quaternion
  64989. */
  64990. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  64991. /**
  64992. * Multiplies two quaternions
  64993. * @param q1 defines the second operand
  64994. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  64995. */
  64996. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  64997. /**
  64998. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  64999. * @param q1 defines the second operand
  65000. * @param result defines the target quaternion
  65001. * @returns the current quaternion
  65002. */
  65003. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65004. /**
  65005. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65006. * @param q1 defines the second operand
  65007. * @returns the currentupdated quaternion
  65008. */
  65009. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65010. /**
  65011. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65012. * @param ref defines the target quaternion
  65013. * @returns the current quaternion
  65014. */
  65015. conjugateToRef(ref: Quaternion): Quaternion;
  65016. /**
  65017. * Conjugates in place (1-q) the current quaternion
  65018. * @returns the current updated quaternion
  65019. */
  65020. conjugateInPlace(): Quaternion;
  65021. /**
  65022. * Conjugates in place (1-q) the current quaternion
  65023. * @returns a new quaternion
  65024. */
  65025. conjugate(): Quaternion;
  65026. /**
  65027. * Gets length of current quaternion
  65028. * @returns the quaternion length (float)
  65029. */
  65030. length(): number;
  65031. /**
  65032. * Normalize in place the current quaternion
  65033. * @returns the current updated quaternion
  65034. */
  65035. normalize(): Quaternion;
  65036. /**
  65037. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65038. * @param order is a reserved parameter and is ignore for now
  65039. * @returns a new Vector3 containing the Euler angles
  65040. */
  65041. toEulerAngles(order?: string): Vector3;
  65042. /**
  65043. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65044. * @param result defines the vector which will be filled with the Euler angles
  65045. * @param order is a reserved parameter and is ignore for now
  65046. * @returns the current unchanged quaternion
  65047. */
  65048. toEulerAnglesToRef(result: Vector3): Quaternion;
  65049. /**
  65050. * Updates the given rotation matrix with the current quaternion values
  65051. * @param result defines the target matrix
  65052. * @returns the current unchanged quaternion
  65053. */
  65054. toRotationMatrix(result: Matrix): Quaternion;
  65055. /**
  65056. * Updates the current quaternion from the given rotation matrix values
  65057. * @param matrix defines the source matrix
  65058. * @returns the current updated quaternion
  65059. */
  65060. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65061. /**
  65062. * Creates a new quaternion from a rotation matrix
  65063. * @param matrix defines the source matrix
  65064. * @returns a new quaternion created from the given rotation matrix values
  65065. */
  65066. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65067. /**
  65068. * Updates the given quaternion with the given rotation matrix values
  65069. * @param matrix defines the source matrix
  65070. * @param result defines the target quaternion
  65071. */
  65072. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65073. /**
  65074. * Returns the dot product (float) between the quaternions "left" and "right"
  65075. * @param left defines the left operand
  65076. * @param right defines the right operand
  65077. * @returns the dot product
  65078. */
  65079. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65080. /**
  65081. * Checks if the two quaternions are close to each other
  65082. * @param quat0 defines the first quaternion to check
  65083. * @param quat1 defines the second quaternion to check
  65084. * @returns true if the two quaternions are close to each other
  65085. */
  65086. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65087. /**
  65088. * Creates an empty quaternion
  65089. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65090. */
  65091. static Zero(): Quaternion;
  65092. /**
  65093. * Inverse a given quaternion
  65094. * @param q defines the source quaternion
  65095. * @returns a new quaternion as the inverted current quaternion
  65096. */
  65097. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65098. /**
  65099. * Inverse a given quaternion
  65100. * @param q defines the source quaternion
  65101. * @param result the quaternion the result will be stored in
  65102. * @returns the result quaternion
  65103. */
  65104. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65105. /**
  65106. * Creates an identity quaternion
  65107. * @returns the identity quaternion
  65108. */
  65109. static Identity(): Quaternion;
  65110. /**
  65111. * Gets a boolean indicating if the given quaternion is identity
  65112. * @param quaternion defines the quaternion to check
  65113. * @returns true if the quaternion is identity
  65114. */
  65115. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65116. /**
  65117. * Creates a quaternion from a rotation around an axis
  65118. * @param axis defines the axis to use
  65119. * @param angle defines the angle to use
  65120. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65121. */
  65122. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65123. /**
  65124. * Creates a rotation around an axis and stores it into the given quaternion
  65125. * @param axis defines the axis to use
  65126. * @param angle defines the angle to use
  65127. * @param result defines the target quaternion
  65128. * @returns the target quaternion
  65129. */
  65130. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65131. /**
  65132. * Creates a new quaternion from data stored into an array
  65133. * @param array defines the data source
  65134. * @param offset defines the offset in the source array where the data starts
  65135. * @returns a new quaternion
  65136. */
  65137. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65138. /**
  65139. * Create a quaternion from Euler rotation angles
  65140. * @param x Pitch
  65141. * @param y Yaw
  65142. * @param z Roll
  65143. * @returns the new Quaternion
  65144. */
  65145. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65146. /**
  65147. * Updates a quaternion from Euler rotation angles
  65148. * @param x Pitch
  65149. * @param y Yaw
  65150. * @param z Roll
  65151. * @param result the quaternion to store the result
  65152. * @returns the updated quaternion
  65153. */
  65154. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65155. /**
  65156. * Create a quaternion from Euler rotation vector
  65157. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65158. * @returns the new Quaternion
  65159. */
  65160. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65161. /**
  65162. * Updates a quaternion from Euler rotation vector
  65163. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65164. * @param result the quaternion to store the result
  65165. * @returns the updated quaternion
  65166. */
  65167. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65168. /**
  65169. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65170. * @param yaw defines the rotation around Y axis
  65171. * @param pitch defines the rotation around X axis
  65172. * @param roll defines the rotation around Z axis
  65173. * @returns the new quaternion
  65174. */
  65175. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65176. /**
  65177. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65178. * @param yaw defines the rotation around Y axis
  65179. * @param pitch defines the rotation around X axis
  65180. * @param roll defines the rotation around Z axis
  65181. * @param result defines the target quaternion
  65182. */
  65183. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65184. /**
  65185. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65186. * @param alpha defines the rotation around first axis
  65187. * @param beta defines the rotation around second axis
  65188. * @param gamma defines the rotation around third axis
  65189. * @returns the new quaternion
  65190. */
  65191. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65192. /**
  65193. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65194. * @param alpha defines the rotation around first axis
  65195. * @param beta defines the rotation around second axis
  65196. * @param gamma defines the rotation around third axis
  65197. * @param result defines the target quaternion
  65198. */
  65199. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65200. /**
  65201. * 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)
  65202. * @param axis1 defines the first axis
  65203. * @param axis2 defines the second axis
  65204. * @param axis3 defines the third axis
  65205. * @returns the new quaternion
  65206. */
  65207. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65208. /**
  65209. * 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
  65210. * @param axis1 defines the first axis
  65211. * @param axis2 defines the second axis
  65212. * @param axis3 defines the third axis
  65213. * @param ref defines the target quaternion
  65214. */
  65215. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65216. /**
  65217. * Interpolates between two quaternions
  65218. * @param left defines first quaternion
  65219. * @param right defines second quaternion
  65220. * @param amount defines the gradient to use
  65221. * @returns the new interpolated quaternion
  65222. */
  65223. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65224. /**
  65225. * Interpolates between two quaternions and stores it into a target quaternion
  65226. * @param left defines first quaternion
  65227. * @param right defines second quaternion
  65228. * @param amount defines the gradient to use
  65229. * @param result defines the target quaternion
  65230. */
  65231. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65232. /**
  65233. * Interpolate between two quaternions using Hermite interpolation
  65234. * @param value1 defines first quaternion
  65235. * @param tangent1 defines the incoming tangent
  65236. * @param value2 defines second quaternion
  65237. * @param tangent2 defines the outgoing tangent
  65238. * @param amount defines the target quaternion
  65239. * @returns the new interpolated quaternion
  65240. */
  65241. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65242. }
  65243. /**
  65244. * Class used to store matrix data (4x4)
  65245. */
  65246. export class Matrix {
  65247. private static _updateFlagSeed;
  65248. private static _identityReadOnly;
  65249. private _isIdentity;
  65250. private _isIdentityDirty;
  65251. private _isIdentity3x2;
  65252. private _isIdentity3x2Dirty;
  65253. /**
  65254. * Gets the update flag of the matrix which is an unique number for the matrix.
  65255. * It will be incremented every time the matrix data change.
  65256. * You can use it to speed the comparison between two versions of the same matrix.
  65257. */
  65258. updateFlag: number;
  65259. private readonly _m;
  65260. /**
  65261. * Gets the internal data of the matrix
  65262. */
  65263. readonly m: DeepImmutable<Float32Array>;
  65264. /** @hidden */
  65265. _markAsUpdated(): void;
  65266. /** @hidden */
  65267. private _updateIdentityStatus;
  65268. /**
  65269. * Creates an empty matrix (filled with zeros)
  65270. */
  65271. constructor();
  65272. /**
  65273. * Check if the current matrix is identity
  65274. * @returns true is the matrix is the identity matrix
  65275. */
  65276. isIdentity(): boolean;
  65277. /**
  65278. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65279. * @returns true is the matrix is the identity matrix
  65280. */
  65281. isIdentityAs3x2(): boolean;
  65282. /**
  65283. * Gets the determinant of the matrix
  65284. * @returns the matrix determinant
  65285. */
  65286. determinant(): number;
  65287. /**
  65288. * Returns the matrix as a Float32Array
  65289. * @returns the matrix underlying array
  65290. */
  65291. toArray(): DeepImmutable<Float32Array>;
  65292. /**
  65293. * Returns the matrix as a Float32Array
  65294. * @returns the matrix underlying array.
  65295. */
  65296. asArray(): DeepImmutable<Float32Array>;
  65297. /**
  65298. * Inverts the current matrix in place
  65299. * @returns the current inverted matrix
  65300. */
  65301. invert(): Matrix;
  65302. /**
  65303. * Sets all the matrix elements to zero
  65304. * @returns the current matrix
  65305. */
  65306. reset(): Matrix;
  65307. /**
  65308. * Adds the current matrix with a second one
  65309. * @param other defines the matrix to add
  65310. * @returns a new matrix as the addition of the current matrix and the given one
  65311. */
  65312. add(other: DeepImmutable<Matrix>): Matrix;
  65313. /**
  65314. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65315. * @param other defines the matrix to add
  65316. * @param result defines the target matrix
  65317. * @returns the current matrix
  65318. */
  65319. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65320. /**
  65321. * Adds in place the given matrix to the current matrix
  65322. * @param other defines the second operand
  65323. * @returns the current updated matrix
  65324. */
  65325. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65326. /**
  65327. * Sets the given matrix to the current inverted Matrix
  65328. * @param other defines the target matrix
  65329. * @returns the unmodified current matrix
  65330. */
  65331. invertToRef(other: Matrix): Matrix;
  65332. /**
  65333. * add a value at the specified position in the current Matrix
  65334. * @param index the index of the value within the matrix. between 0 and 15.
  65335. * @param value the value to be added
  65336. * @returns the current updated matrix
  65337. */
  65338. addAtIndex(index: number, value: number): Matrix;
  65339. /**
  65340. * mutiply the specified position in the current Matrix by a value
  65341. * @param index the index of the value within the matrix. between 0 and 15.
  65342. * @param value the value to be added
  65343. * @returns the current updated matrix
  65344. */
  65345. multiplyAtIndex(index: number, value: number): Matrix;
  65346. /**
  65347. * Inserts the translation vector (using 3 floats) in the current matrix
  65348. * @param x defines the 1st component of the translation
  65349. * @param y defines the 2nd component of the translation
  65350. * @param z defines the 3rd component of the translation
  65351. * @returns the current updated matrix
  65352. */
  65353. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65354. /**
  65355. * Adds the translation vector (using 3 floats) in the current matrix
  65356. * @param x defines the 1st component of the translation
  65357. * @param y defines the 2nd component of the translation
  65358. * @param z defines the 3rd component of the translation
  65359. * @returns the current updated matrix
  65360. */
  65361. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65362. /**
  65363. * Inserts the translation vector in the current matrix
  65364. * @param vector3 defines the translation to insert
  65365. * @returns the current updated matrix
  65366. */
  65367. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65368. /**
  65369. * Gets the translation value of the current matrix
  65370. * @returns a new Vector3 as the extracted translation from the matrix
  65371. */
  65372. getTranslation(): Vector3;
  65373. /**
  65374. * Fill a Vector3 with the extracted translation from the matrix
  65375. * @param result defines the Vector3 where to store the translation
  65376. * @returns the current matrix
  65377. */
  65378. getTranslationToRef(result: Vector3): Matrix;
  65379. /**
  65380. * Remove rotation and scaling part from the matrix
  65381. * @returns the updated matrix
  65382. */
  65383. removeRotationAndScaling(): Matrix;
  65384. /**
  65385. * Multiply two matrices
  65386. * @param other defines the second operand
  65387. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65388. */
  65389. multiply(other: DeepImmutable<Matrix>): Matrix;
  65390. /**
  65391. * Copy the current matrix from the given one
  65392. * @param other defines the source matrix
  65393. * @returns the current updated matrix
  65394. */
  65395. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65396. /**
  65397. * Populates the given array from the starting index with the current matrix values
  65398. * @param array defines the target array
  65399. * @param offset defines the offset in the target array where to start storing values
  65400. * @returns the current matrix
  65401. */
  65402. copyToArray(array: Float32Array, offset?: number): Matrix;
  65403. /**
  65404. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65405. * @param other defines the second operand
  65406. * @param result defines the matrix where to store the multiplication
  65407. * @returns the current matrix
  65408. */
  65409. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65410. /**
  65411. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65412. * @param other defines the second operand
  65413. * @param result defines the array where to store the multiplication
  65414. * @param offset defines the offset in the target array where to start storing values
  65415. * @returns the current matrix
  65416. */
  65417. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65418. /**
  65419. * Check equality between this matrix and a second one
  65420. * @param value defines the second matrix to compare
  65421. * @returns true is the current matrix and the given one values are strictly equal
  65422. */
  65423. equals(value: DeepImmutable<Matrix>): boolean;
  65424. /**
  65425. * Clone the current matrix
  65426. * @returns a new matrix from the current matrix
  65427. */
  65428. clone(): Matrix;
  65429. /**
  65430. * Returns the name of the current matrix class
  65431. * @returns the string "Matrix"
  65432. */
  65433. getClassName(): string;
  65434. /**
  65435. * Gets the hash code of the current matrix
  65436. * @returns the hash code
  65437. */
  65438. getHashCode(): number;
  65439. /**
  65440. * Decomposes the current Matrix into a translation, rotation and scaling components
  65441. * @param scale defines the scale vector3 given as a reference to update
  65442. * @param rotation defines the rotation quaternion given as a reference to update
  65443. * @param translation defines the translation vector3 given as a reference to update
  65444. * @returns true if operation was successful
  65445. */
  65446. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65447. /**
  65448. * Gets specific row of the matrix
  65449. * @param index defines the number of the row to get
  65450. * @returns the index-th row of the current matrix as a new Vector4
  65451. */
  65452. getRow(index: number): Nullable<Vector4>;
  65453. /**
  65454. * Sets the index-th row of the current matrix to the vector4 values
  65455. * @param index defines the number of the row to set
  65456. * @param row defines the target vector4
  65457. * @returns the updated current matrix
  65458. */
  65459. setRow(index: number, row: Vector4): Matrix;
  65460. /**
  65461. * Compute the transpose of the matrix
  65462. * @returns the new transposed matrix
  65463. */
  65464. transpose(): Matrix;
  65465. /**
  65466. * Compute the transpose of the matrix and store it in a given matrix
  65467. * @param result defines the target matrix
  65468. * @returns the current matrix
  65469. */
  65470. transposeToRef(result: Matrix): Matrix;
  65471. /**
  65472. * Sets the index-th row of the current matrix with the given 4 x float values
  65473. * @param index defines the row index
  65474. * @param x defines the x component to set
  65475. * @param y defines the y component to set
  65476. * @param z defines the z component to set
  65477. * @param w defines the w component to set
  65478. * @returns the updated current matrix
  65479. */
  65480. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65481. /**
  65482. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65483. * @param scale defines the scale factor
  65484. * @returns a new matrix
  65485. */
  65486. scale(scale: number): Matrix;
  65487. /**
  65488. * Scale the current matrix values by a factor to a given result matrix
  65489. * @param scale defines the scale factor
  65490. * @param result defines the matrix to store the result
  65491. * @returns the current matrix
  65492. */
  65493. scaleToRef(scale: number, result: Matrix): Matrix;
  65494. /**
  65495. * Scale the current matrix values by a factor and add the result to a given matrix
  65496. * @param scale defines the scale factor
  65497. * @param result defines the Matrix to store the result
  65498. * @returns the current matrix
  65499. */
  65500. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65501. /**
  65502. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65503. * @param ref matrix to store the result
  65504. */
  65505. toNormalMatrix(ref: Matrix): void;
  65506. /**
  65507. * Gets only rotation part of the current matrix
  65508. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65509. */
  65510. getRotationMatrix(): Matrix;
  65511. /**
  65512. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65513. * @param result defines the target matrix to store data to
  65514. * @returns the current matrix
  65515. */
  65516. getRotationMatrixToRef(result: Matrix): Matrix;
  65517. /**
  65518. * Toggles model matrix from being right handed to left handed in place and vice versa
  65519. */
  65520. toggleModelMatrixHandInPlace(): void;
  65521. /**
  65522. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65523. */
  65524. toggleProjectionMatrixHandInPlace(): void;
  65525. /**
  65526. * Creates a matrix from an array
  65527. * @param array defines the source array
  65528. * @param offset defines an offset in the source array
  65529. * @returns a new Matrix set from the starting index of the given array
  65530. */
  65531. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65532. /**
  65533. * Copy the content of an array into a given matrix
  65534. * @param array defines the source array
  65535. * @param offset defines an offset in the source array
  65536. * @param result defines the target matrix
  65537. */
  65538. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65539. /**
  65540. * Stores an array into a matrix after having multiplied each component by a given factor
  65541. * @param array defines the source array
  65542. * @param offset defines the offset in the source array
  65543. * @param scale defines the scaling factor
  65544. * @param result defines the target matrix
  65545. */
  65546. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65547. /**
  65548. * Gets an identity matrix that must not be updated
  65549. */
  65550. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65551. /**
  65552. * Stores a list of values (16) inside a given matrix
  65553. * @param initialM11 defines 1st value of 1st row
  65554. * @param initialM12 defines 2nd value of 1st row
  65555. * @param initialM13 defines 3rd value of 1st row
  65556. * @param initialM14 defines 4th value of 1st row
  65557. * @param initialM21 defines 1st value of 2nd row
  65558. * @param initialM22 defines 2nd value of 2nd row
  65559. * @param initialM23 defines 3rd value of 2nd row
  65560. * @param initialM24 defines 4th value of 2nd row
  65561. * @param initialM31 defines 1st value of 3rd row
  65562. * @param initialM32 defines 2nd value of 3rd row
  65563. * @param initialM33 defines 3rd value of 3rd row
  65564. * @param initialM34 defines 4th value of 3rd row
  65565. * @param initialM41 defines 1st value of 4th row
  65566. * @param initialM42 defines 2nd value of 4th row
  65567. * @param initialM43 defines 3rd value of 4th row
  65568. * @param initialM44 defines 4th value of 4th row
  65569. * @param result defines the target matrix
  65570. */
  65571. 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;
  65572. /**
  65573. * Creates new matrix from a list of values (16)
  65574. * @param initialM11 defines 1st value of 1st row
  65575. * @param initialM12 defines 2nd value of 1st row
  65576. * @param initialM13 defines 3rd value of 1st row
  65577. * @param initialM14 defines 4th value of 1st row
  65578. * @param initialM21 defines 1st value of 2nd row
  65579. * @param initialM22 defines 2nd value of 2nd row
  65580. * @param initialM23 defines 3rd value of 2nd row
  65581. * @param initialM24 defines 4th value of 2nd row
  65582. * @param initialM31 defines 1st value of 3rd row
  65583. * @param initialM32 defines 2nd value of 3rd row
  65584. * @param initialM33 defines 3rd value of 3rd row
  65585. * @param initialM34 defines 4th value of 3rd row
  65586. * @param initialM41 defines 1st value of 4th row
  65587. * @param initialM42 defines 2nd value of 4th row
  65588. * @param initialM43 defines 3rd value of 4th row
  65589. * @param initialM44 defines 4th value of 4th row
  65590. * @returns the new matrix
  65591. */
  65592. 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;
  65593. /**
  65594. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65595. * @param scale defines the scale vector3
  65596. * @param rotation defines the rotation quaternion
  65597. * @param translation defines the translation vector3
  65598. * @returns a new matrix
  65599. */
  65600. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65601. /**
  65602. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65603. * @param scale defines the scale vector3
  65604. * @param rotation defines the rotation quaternion
  65605. * @param translation defines the translation vector3
  65606. * @param result defines the target matrix
  65607. */
  65608. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65609. /**
  65610. * Creates a new identity matrix
  65611. * @returns a new identity matrix
  65612. */
  65613. static Identity(): Matrix;
  65614. /**
  65615. * Creates a new identity matrix and stores the result in a given matrix
  65616. * @param result defines the target matrix
  65617. */
  65618. static IdentityToRef(result: Matrix): void;
  65619. /**
  65620. * Creates a new zero matrix
  65621. * @returns a new zero matrix
  65622. */
  65623. static Zero(): Matrix;
  65624. /**
  65625. * Creates a new rotation matrix for "angle" radians around the X axis
  65626. * @param angle defines the angle (in radians) to use
  65627. * @return the new matrix
  65628. */
  65629. static RotationX(angle: number): Matrix;
  65630. /**
  65631. * Creates a new matrix as the invert of a given matrix
  65632. * @param source defines the source matrix
  65633. * @returns the new matrix
  65634. */
  65635. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65636. /**
  65637. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65638. * @param angle defines the angle (in radians) to use
  65639. * @param result defines the target matrix
  65640. */
  65641. static RotationXToRef(angle: number, result: Matrix): void;
  65642. /**
  65643. * Creates a new rotation matrix for "angle" radians around the Y axis
  65644. * @param angle defines the angle (in radians) to use
  65645. * @return the new matrix
  65646. */
  65647. static RotationY(angle: number): Matrix;
  65648. /**
  65649. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65650. * @param angle defines the angle (in radians) to use
  65651. * @param result defines the target matrix
  65652. */
  65653. static RotationYToRef(angle: number, result: Matrix): void;
  65654. /**
  65655. * Creates a new rotation matrix for "angle" radians around the Z axis
  65656. * @param angle defines the angle (in radians) to use
  65657. * @return the new matrix
  65658. */
  65659. static RotationZ(angle: number): Matrix;
  65660. /**
  65661. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65662. * @param angle defines the angle (in radians) to use
  65663. * @param result defines the target matrix
  65664. */
  65665. static RotationZToRef(angle: number, result: Matrix): void;
  65666. /**
  65667. * Creates a new rotation matrix for "angle" radians around the given axis
  65668. * @param axis defines the axis to use
  65669. * @param angle defines the angle (in radians) to use
  65670. * @return the new matrix
  65671. */
  65672. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65673. /**
  65674. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65675. * @param axis defines the axis to use
  65676. * @param angle defines the angle (in radians) to use
  65677. * @param result defines the target matrix
  65678. */
  65679. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65680. /**
  65681. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65682. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65683. * @param from defines the vector to align
  65684. * @param to defines the vector to align to
  65685. * @param result defines the target matrix
  65686. */
  65687. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65688. /**
  65689. * Creates a rotation matrix
  65690. * @param yaw defines the yaw angle in radians (Y axis)
  65691. * @param pitch defines the pitch angle in radians (X axis)
  65692. * @param roll defines the roll angle in radians (X axis)
  65693. * @returns the new rotation matrix
  65694. */
  65695. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65696. /**
  65697. * Creates a rotation matrix and stores it in a given matrix
  65698. * @param yaw defines the yaw angle in radians (Y axis)
  65699. * @param pitch defines the pitch angle in radians (X axis)
  65700. * @param roll defines the roll angle in radians (X axis)
  65701. * @param result defines the target matrix
  65702. */
  65703. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65704. /**
  65705. * Creates a scaling matrix
  65706. * @param x defines the scale factor on X axis
  65707. * @param y defines the scale factor on Y axis
  65708. * @param z defines the scale factor on Z axis
  65709. * @returns the new matrix
  65710. */
  65711. static Scaling(x: number, y: number, z: number): Matrix;
  65712. /**
  65713. * Creates a scaling matrix and stores it in a given matrix
  65714. * @param x defines the scale factor on X axis
  65715. * @param y defines the scale factor on Y axis
  65716. * @param z defines the scale factor on Z axis
  65717. * @param result defines the target matrix
  65718. */
  65719. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65720. /**
  65721. * Creates a translation matrix
  65722. * @param x defines the translation on X axis
  65723. * @param y defines the translation on Y axis
  65724. * @param z defines the translationon Z axis
  65725. * @returns the new matrix
  65726. */
  65727. static Translation(x: number, y: number, z: number): Matrix;
  65728. /**
  65729. * Creates a translation matrix and stores it in a given matrix
  65730. * @param x defines the translation on X axis
  65731. * @param y defines the translation on Y axis
  65732. * @param z defines the translationon Z axis
  65733. * @param result defines the target matrix
  65734. */
  65735. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65736. /**
  65737. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65738. * @param startValue defines the start value
  65739. * @param endValue defines the end value
  65740. * @param gradient defines the gradient factor
  65741. * @returns the new matrix
  65742. */
  65743. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65744. /**
  65745. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65746. * @param startValue defines the start value
  65747. * @param endValue defines the end value
  65748. * @param gradient defines the gradient factor
  65749. * @param result defines the Matrix object where to store data
  65750. */
  65751. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65752. /**
  65753. * Builds a new matrix whose values are computed by:
  65754. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65755. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65756. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65757. * @param startValue defines the first matrix
  65758. * @param endValue defines the second matrix
  65759. * @param gradient defines the gradient between the two matrices
  65760. * @returns the new matrix
  65761. */
  65762. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65763. /**
  65764. * Update a matrix to values which are computed by:
  65765. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65766. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65767. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65768. * @param startValue defines the first matrix
  65769. * @param endValue defines the second matrix
  65770. * @param gradient defines the gradient between the two matrices
  65771. * @param result defines the target matrix
  65772. */
  65773. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65774. /**
  65775. * 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"
  65776. * This function works in left handed mode
  65777. * @param eye defines the final position of the entity
  65778. * @param target defines where the entity should look at
  65779. * @param up defines the up vector for the entity
  65780. * @returns the new matrix
  65781. */
  65782. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65783. /**
  65784. * 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".
  65785. * This function works in left handed mode
  65786. * @param eye defines the final position of the entity
  65787. * @param target defines where the entity should look at
  65788. * @param up defines the up vector for the entity
  65789. * @param result defines the target matrix
  65790. */
  65791. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65792. /**
  65793. * 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"
  65794. * This function works in right handed mode
  65795. * @param eye defines the final position of the entity
  65796. * @param target defines where the entity should look at
  65797. * @param up defines the up vector for the entity
  65798. * @returns the new matrix
  65799. */
  65800. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65801. /**
  65802. * 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".
  65803. * This function works in right handed mode
  65804. * @param eye defines the final position of the entity
  65805. * @param target defines where the entity should look at
  65806. * @param up defines the up vector for the entity
  65807. * @param result defines the target matrix
  65808. */
  65809. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65810. /**
  65811. * Create a left-handed orthographic projection matrix
  65812. * @param width defines the viewport width
  65813. * @param height defines the viewport height
  65814. * @param znear defines the near clip plane
  65815. * @param zfar defines the far clip plane
  65816. * @returns a new matrix as a left-handed orthographic projection matrix
  65817. */
  65818. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65819. /**
  65820. * Store a left-handed orthographic projection to a given matrix
  65821. * @param width defines the viewport width
  65822. * @param height defines the viewport height
  65823. * @param znear defines the near clip plane
  65824. * @param zfar defines the far clip plane
  65825. * @param result defines the target matrix
  65826. */
  65827. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65828. /**
  65829. * Create a left-handed orthographic projection matrix
  65830. * @param left defines the viewport left coordinate
  65831. * @param right defines the viewport right coordinate
  65832. * @param bottom defines the viewport bottom coordinate
  65833. * @param top defines the viewport top coordinate
  65834. * @param znear defines the near clip plane
  65835. * @param zfar defines the far clip plane
  65836. * @returns a new matrix as a left-handed orthographic projection matrix
  65837. */
  65838. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65839. /**
  65840. * Stores a left-handed orthographic projection into a given matrix
  65841. * @param left defines the viewport left coordinate
  65842. * @param right defines the viewport right coordinate
  65843. * @param bottom defines the viewport bottom coordinate
  65844. * @param top defines the viewport top coordinate
  65845. * @param znear defines the near clip plane
  65846. * @param zfar defines the far clip plane
  65847. * @param result defines the target matrix
  65848. */
  65849. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65850. /**
  65851. * Creates a right-handed orthographic projection matrix
  65852. * @param left defines the viewport left coordinate
  65853. * @param right defines the viewport right coordinate
  65854. * @param bottom defines the viewport bottom coordinate
  65855. * @param top defines the viewport top coordinate
  65856. * @param znear defines the near clip plane
  65857. * @param zfar defines the far clip plane
  65858. * @returns a new matrix as a right-handed orthographic projection matrix
  65859. */
  65860. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65861. /**
  65862. * Stores a right-handed orthographic projection into a given matrix
  65863. * @param left defines the viewport left coordinate
  65864. * @param right defines the viewport right coordinate
  65865. * @param bottom defines the viewport bottom coordinate
  65866. * @param top defines the viewport top coordinate
  65867. * @param znear defines the near clip plane
  65868. * @param zfar defines the far clip plane
  65869. * @param result defines the target matrix
  65870. */
  65871. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65872. /**
  65873. * Creates a left-handed perspective projection matrix
  65874. * @param width defines the viewport width
  65875. * @param height defines the viewport height
  65876. * @param znear defines the near clip plane
  65877. * @param zfar defines the far clip plane
  65878. * @returns a new matrix as a left-handed perspective projection matrix
  65879. */
  65880. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65881. /**
  65882. * Creates a left-handed perspective projection matrix
  65883. * @param fov defines the horizontal field of view
  65884. * @param aspect defines the aspect ratio
  65885. * @param znear defines the near clip plane
  65886. * @param zfar defines the far clip plane
  65887. * @returns a new matrix as a left-handed perspective projection matrix
  65888. */
  65889. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65890. /**
  65891. * Stores a left-handed perspective projection into a given matrix
  65892. * @param fov defines the horizontal field of view
  65893. * @param aspect defines the aspect ratio
  65894. * @param znear defines the near clip plane
  65895. * @param zfar defines the far clip plane
  65896. * @param result defines the target matrix
  65897. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65898. */
  65899. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65900. /**
  65901. * Creates a right-handed perspective projection matrix
  65902. * @param fov defines the horizontal field of view
  65903. * @param aspect defines the aspect ratio
  65904. * @param znear defines the near clip plane
  65905. * @param zfar defines the far clip plane
  65906. * @returns a new matrix as a right-handed perspective projection matrix
  65907. */
  65908. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65909. /**
  65910. * Stores a right-handed perspective projection into a given matrix
  65911. * @param fov defines the horizontal field of view
  65912. * @param aspect defines the aspect ratio
  65913. * @param znear defines the near clip plane
  65914. * @param zfar defines the far clip plane
  65915. * @param result defines the target matrix
  65916. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65917. */
  65918. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65919. /**
  65920. * Stores a perspective projection for WebVR info a given matrix
  65921. * @param fov defines the field of view
  65922. * @param znear defines the near clip plane
  65923. * @param zfar defines the far clip plane
  65924. * @param result defines the target matrix
  65925. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  65926. */
  65927. static PerspectiveFovWebVRToRef(fov: {
  65928. upDegrees: number;
  65929. downDegrees: number;
  65930. leftDegrees: number;
  65931. rightDegrees: number;
  65932. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  65933. /**
  65934. * Computes a complete transformation matrix
  65935. * @param viewport defines the viewport to use
  65936. * @param world defines the world matrix
  65937. * @param view defines the view matrix
  65938. * @param projection defines the projection matrix
  65939. * @param zmin defines the near clip plane
  65940. * @param zmax defines the far clip plane
  65941. * @returns the transformation matrix
  65942. */
  65943. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  65944. /**
  65945. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  65946. * @param matrix defines the matrix to use
  65947. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  65948. */
  65949. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  65950. /**
  65951. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  65952. * @param matrix defines the matrix to use
  65953. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  65954. */
  65955. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  65956. /**
  65957. * Compute the transpose of a given matrix
  65958. * @param matrix defines the matrix to transpose
  65959. * @returns the new matrix
  65960. */
  65961. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  65962. /**
  65963. * Compute the transpose of a matrix and store it in a target matrix
  65964. * @param matrix defines the matrix to transpose
  65965. * @param result defines the target matrix
  65966. */
  65967. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  65968. /**
  65969. * Computes a reflection matrix from a plane
  65970. * @param plane defines the reflection plane
  65971. * @returns a new matrix
  65972. */
  65973. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  65974. /**
  65975. * Computes a reflection matrix from a plane
  65976. * @param plane defines the reflection plane
  65977. * @param result defines the target matrix
  65978. */
  65979. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  65980. /**
  65981. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  65982. * @param xaxis defines the value of the 1st axis
  65983. * @param yaxis defines the value of the 2nd axis
  65984. * @param zaxis defines the value of the 3rd axis
  65985. * @param result defines the target matrix
  65986. */
  65987. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  65988. /**
  65989. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  65990. * @param quat defines the quaternion to use
  65991. * @param result defines the target matrix
  65992. */
  65993. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  65994. }
  65995. /**
  65996. * Represens a plane by the equation ax + by + cz + d = 0
  65997. */
  65998. export class Plane {
  65999. /**
  66000. * Normal of the plane (a,b,c)
  66001. */
  66002. normal: Vector3;
  66003. /**
  66004. * d component of the plane
  66005. */
  66006. d: number;
  66007. /**
  66008. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66009. * @param a a component of the plane
  66010. * @param b b component of the plane
  66011. * @param c c component of the plane
  66012. * @param d d component of the plane
  66013. */
  66014. constructor(a: number, b: number, c: number, d: number);
  66015. /**
  66016. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66017. */
  66018. asArray(): number[];
  66019. /**
  66020. * @returns a new plane copied from the current Plane.
  66021. */
  66022. clone(): Plane;
  66023. /**
  66024. * @returns the string "Plane".
  66025. */
  66026. getClassName(): string;
  66027. /**
  66028. * @returns the Plane hash code.
  66029. */
  66030. getHashCode(): number;
  66031. /**
  66032. * Normalize the current Plane in place.
  66033. * @returns the updated Plane.
  66034. */
  66035. normalize(): Plane;
  66036. /**
  66037. * Applies a transformation the plane and returns the result
  66038. * @param transformation the transformation matrix to be applied to the plane
  66039. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66040. */
  66041. transform(transformation: DeepImmutable<Matrix>): Plane;
  66042. /**
  66043. * Calcualtte the dot product between the point and the plane normal
  66044. * @param point point to calculate the dot product with
  66045. * @returns the dot product (float) of the point coordinates and the plane normal.
  66046. */
  66047. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66048. /**
  66049. * Updates the current Plane from the plane defined by the three given points.
  66050. * @param point1 one of the points used to contruct the plane
  66051. * @param point2 one of the points used to contruct the plane
  66052. * @param point3 one of the points used to contruct the plane
  66053. * @returns the updated Plane.
  66054. */
  66055. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66056. /**
  66057. * Checks if the plane is facing a given direction
  66058. * @param direction the direction to check if the plane is facing
  66059. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66060. * @returns True is the vector "direction" is the same side than the plane normal.
  66061. */
  66062. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66063. /**
  66064. * Calculates the distance to a point
  66065. * @param point point to calculate distance to
  66066. * @returns the signed distance (float) from the given point to the Plane.
  66067. */
  66068. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66069. /**
  66070. * Creates a plane from an array
  66071. * @param array the array to create a plane from
  66072. * @returns a new Plane from the given array.
  66073. */
  66074. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66075. /**
  66076. * Creates a plane from three points
  66077. * @param point1 point used to create the plane
  66078. * @param point2 point used to create the plane
  66079. * @param point3 point used to create the plane
  66080. * @returns a new Plane defined by the three given points.
  66081. */
  66082. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66083. /**
  66084. * Creates a plane from an origin point and a normal
  66085. * @param origin origin of the plane to be constructed
  66086. * @param normal normal of the plane to be constructed
  66087. * @returns a new Plane the normal vector to this plane at the given origin point.
  66088. * Note : the vector "normal" is updated because normalized.
  66089. */
  66090. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66091. /**
  66092. * Calculates the distance from a plane and a point
  66093. * @param origin origin of the plane to be constructed
  66094. * @param normal normal of the plane to be constructed
  66095. * @param point point to calculate distance to
  66096. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66097. */
  66098. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66099. }
  66100. /**
  66101. * Class used to represent a viewport on screen
  66102. */
  66103. export class Viewport {
  66104. /** viewport left coordinate */
  66105. x: number;
  66106. /** viewport top coordinate */
  66107. y: number;
  66108. /**viewport width */
  66109. width: number;
  66110. /** viewport height */
  66111. height: number;
  66112. /**
  66113. * Creates a Viewport object located at (x, y) and sized (width, height)
  66114. * @param x defines viewport left coordinate
  66115. * @param y defines viewport top coordinate
  66116. * @param width defines the viewport width
  66117. * @param height defines the viewport height
  66118. */
  66119. constructor(
  66120. /** viewport left coordinate */
  66121. x: number,
  66122. /** viewport top coordinate */
  66123. y: number,
  66124. /**viewport width */
  66125. width: number,
  66126. /** viewport height */
  66127. height: number);
  66128. /**
  66129. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66130. * @param renderWidth defines the rendering width
  66131. * @param renderHeight defines the rendering height
  66132. * @returns a new Viewport
  66133. */
  66134. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66135. /**
  66136. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66137. * @param renderWidth defines the rendering width
  66138. * @param renderHeight defines the rendering height
  66139. * @param ref defines the target viewport
  66140. * @returns the current viewport
  66141. */
  66142. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66143. /**
  66144. * Returns a new Viewport copied from the current one
  66145. * @returns a new Viewport
  66146. */
  66147. clone(): Viewport;
  66148. }
  66149. /**
  66150. * Reprasents a camera frustum
  66151. */
  66152. export class Frustum {
  66153. /**
  66154. * Gets the planes representing the frustum
  66155. * @param transform matrix to be applied to the returned planes
  66156. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66157. */
  66158. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66159. /**
  66160. * Gets the near frustum plane transformed by the transform matrix
  66161. * @param transform transformation matrix to be applied to the resulting frustum plane
  66162. * @param frustumPlane the resuling frustum plane
  66163. */
  66164. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66165. /**
  66166. * Gets the far frustum plane transformed by the transform matrix
  66167. * @param transform transformation matrix to be applied to the resulting frustum plane
  66168. * @param frustumPlane the resuling frustum plane
  66169. */
  66170. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66171. /**
  66172. * Gets the left frustum plane transformed by the transform matrix
  66173. * @param transform transformation matrix to be applied to the resulting frustum plane
  66174. * @param frustumPlane the resuling frustum plane
  66175. */
  66176. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66177. /**
  66178. * Gets the right frustum plane transformed by the transform matrix
  66179. * @param transform transformation matrix to be applied to the resulting frustum plane
  66180. * @param frustumPlane the resuling frustum plane
  66181. */
  66182. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66183. /**
  66184. * Gets the top frustum plane transformed by the transform matrix
  66185. * @param transform transformation matrix to be applied to the resulting frustum plane
  66186. * @param frustumPlane the resuling frustum plane
  66187. */
  66188. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66189. /**
  66190. * Gets the bottom frustum plane transformed by the transform matrix
  66191. * @param transform transformation matrix to be applied to the resulting frustum plane
  66192. * @param frustumPlane the resuling frustum plane
  66193. */
  66194. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66195. /**
  66196. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66197. * @param transform transformation matrix to be applied to the resulting frustum planes
  66198. * @param frustumPlanes the resuling frustum planes
  66199. */
  66200. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66201. }
  66202. /** Defines supported spaces */
  66203. export enum Space {
  66204. /** Local (object) space */
  66205. LOCAL = 0,
  66206. /** World space */
  66207. WORLD = 1,
  66208. /** Bone space */
  66209. BONE = 2
  66210. }
  66211. /** Defines the 3 main axes */
  66212. export class Axis {
  66213. /** X axis */
  66214. static X: Vector3;
  66215. /** Y axis */
  66216. static Y: Vector3;
  66217. /** Z axis */
  66218. static Z: Vector3;
  66219. }
  66220. /** Class used to represent a Bezier curve */
  66221. export class BezierCurve {
  66222. /**
  66223. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66224. * @param t defines the time
  66225. * @param x1 defines the left coordinate on X axis
  66226. * @param y1 defines the left coordinate on Y axis
  66227. * @param x2 defines the right coordinate on X axis
  66228. * @param y2 defines the right coordinate on Y axis
  66229. * @returns the interpolated value
  66230. */
  66231. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66232. }
  66233. /**
  66234. * Defines potential orientation for back face culling
  66235. */
  66236. export enum Orientation {
  66237. /**
  66238. * Clockwise
  66239. */
  66240. CW = 0,
  66241. /** Counter clockwise */
  66242. CCW = 1
  66243. }
  66244. /**
  66245. * Defines angle representation
  66246. */
  66247. export class Angle {
  66248. private _radians;
  66249. /**
  66250. * Creates an Angle object of "radians" radians (float).
  66251. * @param radians the angle in radians
  66252. */
  66253. constructor(radians: number);
  66254. /**
  66255. * Get value in degrees
  66256. * @returns the Angle value in degrees (float)
  66257. */
  66258. degrees(): number;
  66259. /**
  66260. * Get value in radians
  66261. * @returns the Angle value in radians (float)
  66262. */
  66263. radians(): number;
  66264. /**
  66265. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66266. * @param a defines first vector
  66267. * @param b defines second vector
  66268. * @returns a new Angle
  66269. */
  66270. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66271. /**
  66272. * Gets a new Angle object from the given float in radians
  66273. * @param radians defines the angle value in radians
  66274. * @returns a new Angle
  66275. */
  66276. static FromRadians(radians: number): Angle;
  66277. /**
  66278. * Gets a new Angle object from the given float in degrees
  66279. * @param degrees defines the angle value in degrees
  66280. * @returns a new Angle
  66281. */
  66282. static FromDegrees(degrees: number): Angle;
  66283. }
  66284. /**
  66285. * This represents an arc in a 2d space.
  66286. */
  66287. export class Arc2 {
  66288. /** Defines the start point of the arc */
  66289. startPoint: Vector2;
  66290. /** Defines the mid point of the arc */
  66291. midPoint: Vector2;
  66292. /** Defines the end point of the arc */
  66293. endPoint: Vector2;
  66294. /**
  66295. * Defines the center point of the arc.
  66296. */
  66297. centerPoint: Vector2;
  66298. /**
  66299. * Defines the radius of the arc.
  66300. */
  66301. radius: number;
  66302. /**
  66303. * Defines the angle of the arc (from mid point to end point).
  66304. */
  66305. angle: Angle;
  66306. /**
  66307. * Defines the start angle of the arc (from start point to middle point).
  66308. */
  66309. startAngle: Angle;
  66310. /**
  66311. * Defines the orientation of the arc (clock wise/counter clock wise).
  66312. */
  66313. orientation: Orientation;
  66314. /**
  66315. * Creates an Arc object from the three given points : start, middle and end.
  66316. * @param startPoint Defines the start point of the arc
  66317. * @param midPoint Defines the midlle point of the arc
  66318. * @param endPoint Defines the end point of the arc
  66319. */
  66320. constructor(
  66321. /** Defines the start point of the arc */
  66322. startPoint: Vector2,
  66323. /** Defines the mid point of the arc */
  66324. midPoint: Vector2,
  66325. /** Defines the end point of the arc */
  66326. endPoint: Vector2);
  66327. }
  66328. /**
  66329. * Represents a 2D path made up of multiple 2D points
  66330. */
  66331. export class Path2 {
  66332. private _points;
  66333. private _length;
  66334. /**
  66335. * If the path start and end point are the same
  66336. */
  66337. closed: boolean;
  66338. /**
  66339. * Creates a Path2 object from the starting 2D coordinates x and y.
  66340. * @param x the starting points x value
  66341. * @param y the starting points y value
  66342. */
  66343. constructor(x: number, y: number);
  66344. /**
  66345. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66346. * @param x the added points x value
  66347. * @param y the added points y value
  66348. * @returns the updated Path2.
  66349. */
  66350. addLineTo(x: number, y: number): Path2;
  66351. /**
  66352. * 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.
  66353. * @param midX middle point x value
  66354. * @param midY middle point y value
  66355. * @param endX end point x value
  66356. * @param endY end point y value
  66357. * @param numberOfSegments (default: 36)
  66358. * @returns the updated Path2.
  66359. */
  66360. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66361. /**
  66362. * Closes the Path2.
  66363. * @returns the Path2.
  66364. */
  66365. close(): Path2;
  66366. /**
  66367. * Gets the sum of the distance between each sequential point in the path
  66368. * @returns the Path2 total length (float).
  66369. */
  66370. length(): number;
  66371. /**
  66372. * Gets the points which construct the path
  66373. * @returns the Path2 internal array of points.
  66374. */
  66375. getPoints(): Vector2[];
  66376. /**
  66377. * Retreives the point at the distance aways from the starting point
  66378. * @param normalizedLengthPosition the length along the path to retreive the point from
  66379. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66380. */
  66381. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66382. /**
  66383. * Creates a new path starting from an x and y position
  66384. * @param x starting x value
  66385. * @param y starting y value
  66386. * @returns a new Path2 starting at the coordinates (x, y).
  66387. */
  66388. static StartingAt(x: number, y: number): Path2;
  66389. }
  66390. /**
  66391. * Represents a 3D path made up of multiple 3D points
  66392. */
  66393. export class Path3D {
  66394. /**
  66395. * an array of Vector3, the curve axis of the Path3D
  66396. */
  66397. path: Vector3[];
  66398. private _curve;
  66399. private _distances;
  66400. private _tangents;
  66401. private _normals;
  66402. private _binormals;
  66403. private _raw;
  66404. /**
  66405. * new Path3D(path, normal, raw)
  66406. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66407. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66408. * @param path an array of Vector3, the curve axis of the Path3D
  66409. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66410. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66411. */
  66412. constructor(
  66413. /**
  66414. * an array of Vector3, the curve axis of the Path3D
  66415. */
  66416. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66417. /**
  66418. * Returns the Path3D array of successive Vector3 designing its curve.
  66419. * @returns the Path3D array of successive Vector3 designing its curve.
  66420. */
  66421. getCurve(): Vector3[];
  66422. /**
  66423. * Returns an array populated with tangent vectors on each Path3D curve point.
  66424. * @returns an array populated with tangent vectors on each Path3D curve point.
  66425. */
  66426. getTangents(): Vector3[];
  66427. /**
  66428. * Returns an array populated with normal vectors on each Path3D curve point.
  66429. * @returns an array populated with normal vectors on each Path3D curve point.
  66430. */
  66431. getNormals(): Vector3[];
  66432. /**
  66433. * Returns an array populated with binormal vectors on each Path3D curve point.
  66434. * @returns an array populated with binormal vectors on each Path3D curve point.
  66435. */
  66436. getBinormals(): Vector3[];
  66437. /**
  66438. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66439. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66440. */
  66441. getDistances(): number[];
  66442. /**
  66443. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66444. * @param path path which all values are copied into the curves points
  66445. * @param firstNormal which should be projected onto the curve
  66446. * @returns the same object updated.
  66447. */
  66448. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66449. private _compute;
  66450. private _getFirstNonNullVector;
  66451. private _getLastNonNullVector;
  66452. private _normalVector;
  66453. }
  66454. /**
  66455. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66456. * A Curve3 is designed from a series of successive Vector3.
  66457. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66458. */
  66459. export class Curve3 {
  66460. private _points;
  66461. private _length;
  66462. /**
  66463. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66464. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66465. * @param v1 (Vector3) the control point
  66466. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66467. * @param nbPoints (integer) the wanted number of points in the curve
  66468. * @returns the created Curve3
  66469. */
  66470. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66471. /**
  66472. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66473. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66474. * @param v1 (Vector3) the first control point
  66475. * @param v2 (Vector3) the second control point
  66476. * @param v3 (Vector3) the end point of the Cubic Bezier
  66477. * @param nbPoints (integer) the wanted number of points in the curve
  66478. * @returns the created Curve3
  66479. */
  66480. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66481. /**
  66482. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66483. * @param p1 (Vector3) the origin point of the Hermite Spline
  66484. * @param t1 (Vector3) the tangent vector at the origin point
  66485. * @param p2 (Vector3) the end point of the Hermite Spline
  66486. * @param t2 (Vector3) the tangent vector at the end point
  66487. * @param nbPoints (integer) the wanted number of points in the curve
  66488. * @returns the created Curve3
  66489. */
  66490. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66491. /**
  66492. * Returns a Curve3 object along a CatmullRom Spline curve :
  66493. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66494. * @param nbPoints (integer) the wanted number of points between each curve control points
  66495. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66496. * @returns the created Curve3
  66497. */
  66498. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66499. /**
  66500. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66501. * A Curve3 is designed from a series of successive Vector3.
  66502. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66503. * @param points points which make up the curve
  66504. */
  66505. constructor(points: Vector3[]);
  66506. /**
  66507. * @returns the Curve3 stored array of successive Vector3
  66508. */
  66509. getPoints(): Vector3[];
  66510. /**
  66511. * @returns the computed length (float) of the curve.
  66512. */
  66513. length(): number;
  66514. /**
  66515. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66516. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66517. * curveA and curveB keep unchanged.
  66518. * @param curve the curve to continue from this curve
  66519. * @returns the newly constructed curve
  66520. */
  66521. continue(curve: DeepImmutable<Curve3>): Curve3;
  66522. private _computeLength;
  66523. }
  66524. /**
  66525. * Contains position and normal vectors for a vertex
  66526. */
  66527. export class PositionNormalVertex {
  66528. /** the position of the vertex (defaut: 0,0,0) */
  66529. position: Vector3;
  66530. /** the normal of the vertex (defaut: 0,1,0) */
  66531. normal: Vector3;
  66532. /**
  66533. * Creates a PositionNormalVertex
  66534. * @param position the position of the vertex (defaut: 0,0,0)
  66535. * @param normal the normal of the vertex (defaut: 0,1,0)
  66536. */
  66537. constructor(
  66538. /** the position of the vertex (defaut: 0,0,0) */
  66539. position?: Vector3,
  66540. /** the normal of the vertex (defaut: 0,1,0) */
  66541. normal?: Vector3);
  66542. /**
  66543. * Clones the PositionNormalVertex
  66544. * @returns the cloned PositionNormalVertex
  66545. */
  66546. clone(): PositionNormalVertex;
  66547. }
  66548. /**
  66549. * Contains position, normal and uv vectors for a vertex
  66550. */
  66551. export class PositionNormalTextureVertex {
  66552. /** the position of the vertex (defaut: 0,0,0) */
  66553. position: Vector3;
  66554. /** the normal of the vertex (defaut: 0,1,0) */
  66555. normal: Vector3;
  66556. /** the uv of the vertex (default: 0,0) */
  66557. uv: Vector2;
  66558. /**
  66559. * Creates a PositionNormalTextureVertex
  66560. * @param position the position of the vertex (defaut: 0,0,0)
  66561. * @param normal the normal of the vertex (defaut: 0,1,0)
  66562. * @param uv the uv of the vertex (default: 0,0)
  66563. */
  66564. constructor(
  66565. /** the position of the vertex (defaut: 0,0,0) */
  66566. position?: Vector3,
  66567. /** the normal of the vertex (defaut: 0,1,0) */
  66568. normal?: Vector3,
  66569. /** the uv of the vertex (default: 0,0) */
  66570. uv?: Vector2);
  66571. /**
  66572. * Clones the PositionNormalTextureVertex
  66573. * @returns the cloned PositionNormalTextureVertex
  66574. */
  66575. clone(): PositionNormalTextureVertex;
  66576. }
  66577. /**
  66578. * @hidden
  66579. */
  66580. export class Tmp {
  66581. static Color3: Color3[];
  66582. static Color4: Color4[];
  66583. static Vector2: Vector2[];
  66584. static Vector3: Vector3[];
  66585. static Vector4: Vector4[];
  66586. static Quaternion: Quaternion[];
  66587. static Matrix: Matrix[];
  66588. }
  66589. }
  66590. declare module BABYLON {
  66591. /**
  66592. * Class used to enable access to offline support
  66593. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66594. */
  66595. export interface IOfflineProvider {
  66596. /**
  66597. * Gets a boolean indicating if scene must be saved in the database
  66598. */
  66599. enableSceneOffline: boolean;
  66600. /**
  66601. * Gets a boolean indicating if textures must be saved in the database
  66602. */
  66603. enableTexturesOffline: boolean;
  66604. /**
  66605. * Open the offline support and make it available
  66606. * @param successCallback defines the callback to call on success
  66607. * @param errorCallback defines the callback to call on error
  66608. */
  66609. open(successCallback: () => void, errorCallback: () => void): void;
  66610. /**
  66611. * Loads an image from the offline support
  66612. * @param url defines the url to load from
  66613. * @param image defines the target DOM image
  66614. */
  66615. loadImage(url: string, image: HTMLImageElement): void;
  66616. /**
  66617. * Loads a file from offline support
  66618. * @param url defines the URL to load from
  66619. * @param sceneLoaded defines a callback to call on success
  66620. * @param progressCallBack defines a callback to call when progress changed
  66621. * @param errorCallback defines a callback to call on error
  66622. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66623. */
  66624. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66625. }
  66626. }
  66627. declare module BABYLON {
  66628. /**
  66629. * A class serves as a medium between the observable and its observers
  66630. */
  66631. export class EventState {
  66632. /**
  66633. * Create a new EventState
  66634. * @param mask defines the mask associated with this state
  66635. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66636. * @param target defines the original target of the state
  66637. * @param currentTarget defines the current target of the state
  66638. */
  66639. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66640. /**
  66641. * Initialize the current event state
  66642. * @param mask defines the mask associated with this state
  66643. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66644. * @param target defines the original target of the state
  66645. * @param currentTarget defines the current target of the state
  66646. * @returns the current event state
  66647. */
  66648. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66649. /**
  66650. * An Observer can set this property to true to prevent subsequent observers of being notified
  66651. */
  66652. skipNextObservers: boolean;
  66653. /**
  66654. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66655. */
  66656. mask: number;
  66657. /**
  66658. * The object that originally notified the event
  66659. */
  66660. target?: any;
  66661. /**
  66662. * The current object in the bubbling phase
  66663. */
  66664. currentTarget?: any;
  66665. /**
  66666. * This will be populated with the return value of the last function that was executed.
  66667. * If it is the first function in the callback chain it will be the event data.
  66668. */
  66669. lastReturnValue?: any;
  66670. }
  66671. /**
  66672. * Represent an Observer registered to a given Observable object.
  66673. */
  66674. export class Observer<T> {
  66675. /**
  66676. * Defines the callback to call when the observer is notified
  66677. */
  66678. callback: (eventData: T, eventState: EventState) => void;
  66679. /**
  66680. * Defines the mask of the observer (used to filter notifications)
  66681. */
  66682. mask: number;
  66683. /**
  66684. * Defines the current scope used to restore the JS context
  66685. */
  66686. scope: any;
  66687. /** @hidden */
  66688. _willBeUnregistered: boolean;
  66689. /**
  66690. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66691. */
  66692. unregisterOnNextCall: boolean;
  66693. /**
  66694. * Creates a new observer
  66695. * @param callback defines the callback to call when the observer is notified
  66696. * @param mask defines the mask of the observer (used to filter notifications)
  66697. * @param scope defines the current scope used to restore the JS context
  66698. */
  66699. constructor(
  66700. /**
  66701. * Defines the callback to call when the observer is notified
  66702. */
  66703. callback: (eventData: T, eventState: EventState) => void,
  66704. /**
  66705. * Defines the mask of the observer (used to filter notifications)
  66706. */
  66707. mask: number,
  66708. /**
  66709. * Defines the current scope used to restore the JS context
  66710. */
  66711. scope?: any);
  66712. }
  66713. /**
  66714. * Represent a list of observers registered to multiple Observables object.
  66715. */
  66716. export class MultiObserver<T> {
  66717. private _observers;
  66718. private _observables;
  66719. /**
  66720. * Release associated resources
  66721. */
  66722. dispose(): void;
  66723. /**
  66724. * Raise a callback when one of the observable will notify
  66725. * @param observables defines a list of observables to watch
  66726. * @param callback defines the callback to call on notification
  66727. * @param mask defines the mask used to filter notifications
  66728. * @param scope defines the current scope used to restore the JS context
  66729. * @returns the new MultiObserver
  66730. */
  66731. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66732. }
  66733. /**
  66734. * The Observable class is a simple implementation of the Observable pattern.
  66735. *
  66736. * 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.
  66737. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66738. * 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).
  66739. * 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.
  66740. */
  66741. export class Observable<T> {
  66742. private _observers;
  66743. private _eventState;
  66744. private _onObserverAdded;
  66745. /**
  66746. * Creates a new observable
  66747. * @param onObserverAdded defines a callback to call when a new observer is added
  66748. */
  66749. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66750. /**
  66751. * Create a new Observer with the specified callback
  66752. * @param callback the callback that will be executed for that Observer
  66753. * @param mask the mask used to filter observers
  66754. * @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.
  66755. * @param scope optional scope for the callback to be called from
  66756. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66757. * @returns the new observer created for the callback
  66758. */
  66759. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66760. /**
  66761. * Create a new Observer with the specified callback and unregisters after the next notification
  66762. * @param callback the callback that will be executed for that Observer
  66763. * @returns the new observer created for the callback
  66764. */
  66765. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66766. /**
  66767. * Remove an Observer from the Observable object
  66768. * @param observer the instance of the Observer to remove
  66769. * @returns false if it doesn't belong to this Observable
  66770. */
  66771. remove(observer: Nullable<Observer<T>>): boolean;
  66772. /**
  66773. * Remove a callback from the Observable object
  66774. * @param callback the callback to remove
  66775. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66776. * @returns false if it doesn't belong to this Observable
  66777. */
  66778. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66779. private _deferUnregister;
  66780. private _remove;
  66781. /**
  66782. * Moves the observable to the top of the observer list making it get called first when notified
  66783. * @param observer the observer to move
  66784. */
  66785. makeObserverTopPriority(observer: Observer<T>): void;
  66786. /**
  66787. * Moves the observable to the bottom of the observer list making it get called last when notified
  66788. * @param observer the observer to move
  66789. */
  66790. makeObserverBottomPriority(observer: Observer<T>): void;
  66791. /**
  66792. * Notify all Observers by calling their respective callback with the given data
  66793. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66794. * @param eventData defines the data to send to all observers
  66795. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66796. * @param target defines the original target of the state
  66797. * @param currentTarget defines the current target of the state
  66798. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66799. */
  66800. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66801. /**
  66802. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66803. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66804. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66805. * and it is crucial that all callbacks will be executed.
  66806. * The order of the callbacks is kept, callbacks are not executed parallel.
  66807. *
  66808. * @param eventData The data to be sent to each callback
  66809. * @param mask is used to filter observers defaults to -1
  66810. * @param target defines the callback target (see EventState)
  66811. * @param currentTarget defines he current object in the bubbling phase
  66812. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66813. */
  66814. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66815. /**
  66816. * Notify a specific observer
  66817. * @param observer defines the observer to notify
  66818. * @param eventData defines the data to be sent to each callback
  66819. * @param mask is used to filter observers defaults to -1
  66820. */
  66821. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66822. /**
  66823. * Gets a boolean indicating if the observable has at least one observer
  66824. * @returns true is the Observable has at least one Observer registered
  66825. */
  66826. hasObservers(): boolean;
  66827. /**
  66828. * Clear the list of observers
  66829. */
  66830. clear(): void;
  66831. /**
  66832. * Clone the current observable
  66833. * @returns a new observable
  66834. */
  66835. clone(): Observable<T>;
  66836. /**
  66837. * Does this observable handles observer registered with a given mask
  66838. * @param mask defines the mask to be tested
  66839. * @return whether or not one observer registered with the given mask is handeled
  66840. **/
  66841. hasSpecificMask(mask?: number): boolean;
  66842. }
  66843. }
  66844. declare module BABYLON {
  66845. /**
  66846. * Class used to help managing file picking and drag'n'drop
  66847. * File Storage
  66848. */
  66849. export class FilesInputStore {
  66850. /**
  66851. * List of files ready to be loaded
  66852. */
  66853. static FilesToLoad: {
  66854. [key: string]: File;
  66855. };
  66856. }
  66857. }
  66858. declare module BABYLON {
  66859. /** Defines the cross module used constants to avoid circular dependncies */
  66860. export class Constants {
  66861. /** Defines that alpha blending is disabled */
  66862. static readonly ALPHA_DISABLE: number;
  66863. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  66864. static readonly ALPHA_ADD: number;
  66865. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  66866. static readonly ALPHA_COMBINE: number;
  66867. /** Defines that alpha blending to DEST - SRC * DEST */
  66868. static readonly ALPHA_SUBTRACT: number;
  66869. /** Defines that alpha blending to SRC * DEST */
  66870. static readonly ALPHA_MULTIPLY: number;
  66871. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  66872. static readonly ALPHA_MAXIMIZED: number;
  66873. /** Defines that alpha blending to SRC + DEST */
  66874. static readonly ALPHA_ONEONE: number;
  66875. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  66876. static readonly ALPHA_PREMULTIPLIED: number;
  66877. /**
  66878. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  66879. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  66880. */
  66881. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  66882. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  66883. static readonly ALPHA_INTERPOLATE: number;
  66884. /**
  66885. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  66886. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  66887. */
  66888. static readonly ALPHA_SCREENMODE: number;
  66889. /** Defines that the ressource is not delayed*/
  66890. static readonly DELAYLOADSTATE_NONE: number;
  66891. /** Defines that the ressource was successfully delay loaded */
  66892. static readonly DELAYLOADSTATE_LOADED: number;
  66893. /** Defines that the ressource is currently delay loading */
  66894. static readonly DELAYLOADSTATE_LOADING: number;
  66895. /** Defines that the ressource is delayed and has not started loading */
  66896. static readonly DELAYLOADSTATE_NOTLOADED: number;
  66897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  66898. static readonly NEVER: number;
  66899. /** 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 */
  66900. static readonly ALWAYS: number;
  66901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  66902. static readonly LESS: number;
  66903. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  66904. static readonly EQUAL: number;
  66905. /** 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 */
  66906. static readonly LEQUAL: number;
  66907. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  66908. static readonly GREATER: number;
  66909. /** 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 */
  66910. static readonly GEQUAL: number;
  66911. /** 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 */
  66912. static readonly NOTEQUAL: number;
  66913. /** Passed to stencilOperation to specify that stencil value must be kept */
  66914. static readonly KEEP: number;
  66915. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66916. static readonly REPLACE: number;
  66917. /** Passed to stencilOperation to specify that stencil value must be incremented */
  66918. static readonly INCR: number;
  66919. /** Passed to stencilOperation to specify that stencil value must be decremented */
  66920. static readonly DECR: number;
  66921. /** Passed to stencilOperation to specify that stencil value must be inverted */
  66922. static readonly INVERT: number;
  66923. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  66924. static readonly INCR_WRAP: number;
  66925. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  66926. static readonly DECR_WRAP: number;
  66927. /** Texture is not repeating outside of 0..1 UVs */
  66928. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  66929. /** Texture is repeating outside of 0..1 UVs */
  66930. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  66931. /** Texture is repeating and mirrored */
  66932. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  66933. /** ALPHA */
  66934. static readonly TEXTUREFORMAT_ALPHA: number;
  66935. /** LUMINANCE */
  66936. static readonly TEXTUREFORMAT_LUMINANCE: number;
  66937. /** LUMINANCE_ALPHA */
  66938. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  66939. /** RGB */
  66940. static readonly TEXTUREFORMAT_RGB: number;
  66941. /** RGBA */
  66942. static readonly TEXTUREFORMAT_RGBA: number;
  66943. /** RED */
  66944. static readonly TEXTUREFORMAT_RED: number;
  66945. /** RED (2nd reference) */
  66946. static readonly TEXTUREFORMAT_R: number;
  66947. /** RG */
  66948. static readonly TEXTUREFORMAT_RG: number;
  66949. /** RED_INTEGER */
  66950. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  66951. /** RED_INTEGER (2nd reference) */
  66952. static readonly TEXTUREFORMAT_R_INTEGER: number;
  66953. /** RG_INTEGER */
  66954. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  66955. /** RGB_INTEGER */
  66956. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  66957. /** RGBA_INTEGER */
  66958. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  66959. /** UNSIGNED_BYTE */
  66960. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  66961. /** UNSIGNED_BYTE (2nd reference) */
  66962. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  66963. /** FLOAT */
  66964. static readonly TEXTURETYPE_FLOAT: number;
  66965. /** HALF_FLOAT */
  66966. static readonly TEXTURETYPE_HALF_FLOAT: number;
  66967. /** BYTE */
  66968. static readonly TEXTURETYPE_BYTE: number;
  66969. /** SHORT */
  66970. static readonly TEXTURETYPE_SHORT: number;
  66971. /** UNSIGNED_SHORT */
  66972. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  66973. /** INT */
  66974. static readonly TEXTURETYPE_INT: number;
  66975. /** UNSIGNED_INT */
  66976. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  66977. /** UNSIGNED_SHORT_4_4_4_4 */
  66978. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  66979. /** UNSIGNED_SHORT_5_5_5_1 */
  66980. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  66981. /** UNSIGNED_SHORT_5_6_5 */
  66982. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  66983. /** UNSIGNED_INT_2_10_10_10_REV */
  66984. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  66985. /** UNSIGNED_INT_24_8 */
  66986. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  66987. /** UNSIGNED_INT_10F_11F_11F_REV */
  66988. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  66989. /** UNSIGNED_INT_5_9_9_9_REV */
  66990. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  66991. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  66992. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66993. /** nearest is mag = nearest and min = nearest and mip = linear */
  66994. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  66995. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66996. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  66997. /** Trilinear is mag = linear and min = linear and mip = linear */
  66998. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  66999. /** nearest is mag = nearest and min = nearest and mip = linear */
  67000. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67001. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67002. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67003. /** Trilinear is mag = linear and min = linear and mip = linear */
  67004. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67005. /** mag = nearest and min = nearest and mip = nearest */
  67006. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67007. /** mag = nearest and min = linear and mip = nearest */
  67008. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67009. /** mag = nearest and min = linear and mip = linear */
  67010. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67011. /** mag = nearest and min = linear and mip = none */
  67012. static readonly TEXTURE_NEAREST_LINEAR: number;
  67013. /** mag = nearest and min = nearest and mip = none */
  67014. static readonly TEXTURE_NEAREST_NEAREST: number;
  67015. /** mag = linear and min = nearest and mip = nearest */
  67016. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67017. /** mag = linear and min = nearest and mip = linear */
  67018. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67019. /** mag = linear and min = linear and mip = none */
  67020. static readonly TEXTURE_LINEAR_LINEAR: number;
  67021. /** mag = linear and min = nearest and mip = none */
  67022. static readonly TEXTURE_LINEAR_NEAREST: number;
  67023. /** Explicit coordinates mode */
  67024. static readonly TEXTURE_EXPLICIT_MODE: number;
  67025. /** Spherical coordinates mode */
  67026. static readonly TEXTURE_SPHERICAL_MODE: number;
  67027. /** Planar coordinates mode */
  67028. static readonly TEXTURE_PLANAR_MODE: number;
  67029. /** Cubic coordinates mode */
  67030. static readonly TEXTURE_CUBIC_MODE: number;
  67031. /** Projection coordinates mode */
  67032. static readonly TEXTURE_PROJECTION_MODE: number;
  67033. /** Skybox coordinates mode */
  67034. static readonly TEXTURE_SKYBOX_MODE: number;
  67035. /** Inverse Cubic coordinates mode */
  67036. static readonly TEXTURE_INVCUBIC_MODE: number;
  67037. /** Equirectangular coordinates mode */
  67038. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67039. /** Equirectangular Fixed coordinates mode */
  67040. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67041. /** Equirectangular Fixed Mirrored coordinates mode */
  67042. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67043. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67044. static readonly SCALEMODE_FLOOR: number;
  67045. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67046. static readonly SCALEMODE_NEAREST: number;
  67047. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67048. static readonly SCALEMODE_CEILING: number;
  67049. /**
  67050. * The dirty texture flag value
  67051. */
  67052. static readonly MATERIAL_TextureDirtyFlag: number;
  67053. /**
  67054. * The dirty light flag value
  67055. */
  67056. static readonly MATERIAL_LightDirtyFlag: number;
  67057. /**
  67058. * The dirty fresnel flag value
  67059. */
  67060. static readonly MATERIAL_FresnelDirtyFlag: number;
  67061. /**
  67062. * The dirty attribute flag value
  67063. */
  67064. static readonly MATERIAL_AttributesDirtyFlag: number;
  67065. /**
  67066. * The dirty misc flag value
  67067. */
  67068. static readonly MATERIAL_MiscDirtyFlag: number;
  67069. /**
  67070. * The all dirty flag value
  67071. */
  67072. static readonly MATERIAL_AllDirtyFlag: number;
  67073. /**
  67074. * Returns the triangle fill mode
  67075. */
  67076. static readonly MATERIAL_TriangleFillMode: number;
  67077. /**
  67078. * Returns the wireframe mode
  67079. */
  67080. static readonly MATERIAL_WireFrameFillMode: number;
  67081. /**
  67082. * Returns the point fill mode
  67083. */
  67084. static readonly MATERIAL_PointFillMode: number;
  67085. /**
  67086. * Returns the point list draw mode
  67087. */
  67088. static readonly MATERIAL_PointListDrawMode: number;
  67089. /**
  67090. * Returns the line list draw mode
  67091. */
  67092. static readonly MATERIAL_LineListDrawMode: number;
  67093. /**
  67094. * Returns the line loop draw mode
  67095. */
  67096. static readonly MATERIAL_LineLoopDrawMode: number;
  67097. /**
  67098. * Returns the line strip draw mode
  67099. */
  67100. static readonly MATERIAL_LineStripDrawMode: number;
  67101. /**
  67102. * Returns the triangle strip draw mode
  67103. */
  67104. static readonly MATERIAL_TriangleStripDrawMode: number;
  67105. /**
  67106. * Returns the triangle fan draw mode
  67107. */
  67108. static readonly MATERIAL_TriangleFanDrawMode: number;
  67109. /**
  67110. * Stores the clock-wise side orientation
  67111. */
  67112. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67113. /**
  67114. * Stores the counter clock-wise side orientation
  67115. */
  67116. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67117. /**
  67118. * Nothing
  67119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67120. */
  67121. static readonly ACTION_NothingTrigger: number;
  67122. /**
  67123. * On pick
  67124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67125. */
  67126. static readonly ACTION_OnPickTrigger: number;
  67127. /**
  67128. * On left pick
  67129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67130. */
  67131. static readonly ACTION_OnLeftPickTrigger: number;
  67132. /**
  67133. * On right pick
  67134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67135. */
  67136. static readonly ACTION_OnRightPickTrigger: number;
  67137. /**
  67138. * On center pick
  67139. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67140. */
  67141. static readonly ACTION_OnCenterPickTrigger: number;
  67142. /**
  67143. * On pick down
  67144. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67145. */
  67146. static readonly ACTION_OnPickDownTrigger: number;
  67147. /**
  67148. * On double pick
  67149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67150. */
  67151. static readonly ACTION_OnDoublePickTrigger: number;
  67152. /**
  67153. * On pick up
  67154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67155. */
  67156. static readonly ACTION_OnPickUpTrigger: number;
  67157. /**
  67158. * On pick out.
  67159. * This trigger will only be raised if you also declared a OnPickDown
  67160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67161. */
  67162. static readonly ACTION_OnPickOutTrigger: number;
  67163. /**
  67164. * On long press
  67165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67166. */
  67167. static readonly ACTION_OnLongPressTrigger: number;
  67168. /**
  67169. * On pointer over
  67170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67171. */
  67172. static readonly ACTION_OnPointerOverTrigger: number;
  67173. /**
  67174. * On pointer out
  67175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67176. */
  67177. static readonly ACTION_OnPointerOutTrigger: number;
  67178. /**
  67179. * On every frame
  67180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67181. */
  67182. static readonly ACTION_OnEveryFrameTrigger: number;
  67183. /**
  67184. * On intersection enter
  67185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67186. */
  67187. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67188. /**
  67189. * On intersection exit
  67190. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67191. */
  67192. static readonly ACTION_OnIntersectionExitTrigger: number;
  67193. /**
  67194. * On key down
  67195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67196. */
  67197. static readonly ACTION_OnKeyDownTrigger: number;
  67198. /**
  67199. * On key up
  67200. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67201. */
  67202. static readonly ACTION_OnKeyUpTrigger: number;
  67203. /**
  67204. * Billboard mode will only apply to Y axis
  67205. */
  67206. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67207. /**
  67208. * Billboard mode will apply to all axes
  67209. */
  67210. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67211. /**
  67212. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67213. */
  67214. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67215. /**
  67216. * Gets or sets base Assets URL
  67217. */
  67218. static PARTICLES_BaseAssetsUrl: string;
  67219. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67220. * Test order :
  67221. * Is the bounding sphere outside the frustum ?
  67222. * If not, are the bounding box vertices outside the frustum ?
  67223. * It not, then the cullable object is in the frustum.
  67224. */
  67225. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67226. /** Culling strategy : Bounding Sphere Only.
  67227. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67228. * It's also less accurate than the standard because some not visible objects can still be selected.
  67229. * Test : is the bounding sphere outside the frustum ?
  67230. * If not, then the cullable object is in the frustum.
  67231. */
  67232. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67233. /** Culling strategy : Optimistic Inclusion.
  67234. * This in an inclusion test first, then the standard exclusion test.
  67235. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67236. * 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.
  67237. * Anyway, it's as accurate as the standard strategy.
  67238. * Test :
  67239. * Is the cullable object bounding sphere center in the frustum ?
  67240. * If not, apply the default culling strategy.
  67241. */
  67242. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67243. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67244. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67245. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67246. * 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.
  67247. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67248. * Test :
  67249. * Is the cullable object bounding sphere center in the frustum ?
  67250. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67251. */
  67252. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67253. /**
  67254. * No logging while loading
  67255. */
  67256. static readonly SCENELOADER_NO_LOGGING: number;
  67257. /**
  67258. * Minimal logging while loading
  67259. */
  67260. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67261. /**
  67262. * Summary logging while loading
  67263. */
  67264. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67265. /**
  67266. * Detailled logging while loading
  67267. */
  67268. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67269. }
  67270. }
  67271. declare module BABYLON {
  67272. /**
  67273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67274. * Babylon.js
  67275. */
  67276. export class DomManagement {
  67277. /**
  67278. * Checks if the window object exists
  67279. * @returns true if the window object exists
  67280. */
  67281. static IsWindowObjectExist(): boolean;
  67282. /**
  67283. * Extracts text content from a DOM element hierarchy
  67284. * @param element defines the root element
  67285. * @returns a string
  67286. */
  67287. static GetDOMTextContent(element: HTMLElement): string;
  67288. }
  67289. }
  67290. declare module BABYLON {
  67291. /**
  67292. * Logger used througouht the application to allow configuration of
  67293. * the log level required for the messages.
  67294. */
  67295. export class Logger {
  67296. /**
  67297. * No log
  67298. */
  67299. static readonly NoneLogLevel: number;
  67300. /**
  67301. * Only message logs
  67302. */
  67303. static readonly MessageLogLevel: number;
  67304. /**
  67305. * Only warning logs
  67306. */
  67307. static readonly WarningLogLevel: number;
  67308. /**
  67309. * Only error logs
  67310. */
  67311. static readonly ErrorLogLevel: number;
  67312. /**
  67313. * All logs
  67314. */
  67315. static readonly AllLogLevel: number;
  67316. private static _LogCache;
  67317. /**
  67318. * Gets a value indicating the number of loading errors
  67319. * @ignorenaming
  67320. */
  67321. static errorsCount: number;
  67322. /**
  67323. * Callback called when a new log is added
  67324. */
  67325. static OnNewCacheEntry: (entry: string) => void;
  67326. private static _AddLogEntry;
  67327. private static _FormatMessage;
  67328. private static _LogDisabled;
  67329. private static _LogEnabled;
  67330. private static _WarnDisabled;
  67331. private static _WarnEnabled;
  67332. private static _ErrorDisabled;
  67333. private static _ErrorEnabled;
  67334. /**
  67335. * Log a message to the console
  67336. */
  67337. static Log: (message: string) => void;
  67338. /**
  67339. * Write a warning message to the console
  67340. */
  67341. static Warn: (message: string) => void;
  67342. /**
  67343. * Write an error message to the console
  67344. */
  67345. static Error: (message: string) => void;
  67346. /**
  67347. * Gets current log cache (list of logs)
  67348. */
  67349. static readonly LogCache: string;
  67350. /**
  67351. * Clears the log cache
  67352. */
  67353. static ClearLogCache(): void;
  67354. /**
  67355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67356. */
  67357. static LogLevels: number;
  67358. }
  67359. }
  67360. declare module BABYLON {
  67361. /** @hidden */
  67362. export class _TypeStore {
  67363. /** @hidden */
  67364. static RegisteredTypes: {
  67365. [key: string]: Object;
  67366. };
  67367. /** @hidden */
  67368. static GetClass(fqdn: string): any;
  67369. }
  67370. }
  67371. declare module BABYLON {
  67372. /**
  67373. * Class containing a set of static utilities functions for deep copy.
  67374. */
  67375. export class DeepCopier {
  67376. /**
  67377. * Tries to copy an object by duplicating every property
  67378. * @param source defines the source object
  67379. * @param destination defines the target object
  67380. * @param doNotCopyList defines a list of properties to avoid
  67381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67382. */
  67383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67384. }
  67385. }
  67386. declare module BABYLON {
  67387. /**
  67388. * Class containing a set of static utilities functions for precision date
  67389. */
  67390. export class PrecisionDate {
  67391. /**
  67392. * Gets either window.performance.now() if supported or Date.now() else
  67393. */
  67394. static readonly Now: number;
  67395. }
  67396. }
  67397. declare module BABYLON {
  67398. /** @hidden */
  67399. export class _DevTools {
  67400. static WarnImport(name: string): string;
  67401. }
  67402. }
  67403. declare module BABYLON {
  67404. /**
  67405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67406. */
  67407. export class WebRequest {
  67408. private _xhr;
  67409. /**
  67410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67411. * i.e. when loading files, where the server/service expects an Authorization header
  67412. */
  67413. static CustomRequestHeaders: {
  67414. [key: string]: string;
  67415. };
  67416. /**
  67417. * Add callback functions in this array to update all the requests before they get sent to the network
  67418. */
  67419. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67420. private _injectCustomRequestHeaders;
  67421. /**
  67422. * Gets or sets a function to be called when loading progress changes
  67423. */
  67424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67425. /**
  67426. * Returns client's state
  67427. */
  67428. readonly readyState: number;
  67429. /**
  67430. * Returns client's status
  67431. */
  67432. readonly status: number;
  67433. /**
  67434. * Returns client's status as a text
  67435. */
  67436. readonly statusText: string;
  67437. /**
  67438. * Returns client's response
  67439. */
  67440. readonly response: any;
  67441. /**
  67442. * Returns client's response url
  67443. */
  67444. readonly responseURL: string;
  67445. /**
  67446. * Returns client's response as text
  67447. */
  67448. readonly responseText: string;
  67449. /**
  67450. * Gets or sets the expected response type
  67451. */
  67452. responseType: XMLHttpRequestResponseType;
  67453. /** @hidden */
  67454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67455. /** @hidden */
  67456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67457. /**
  67458. * Cancels any network activity
  67459. */
  67460. abort(): void;
  67461. /**
  67462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67463. * @param body defines an optional request body
  67464. */
  67465. send(body?: Document | BodyInit | null): void;
  67466. /**
  67467. * Sets the request method, request URL
  67468. * @param method defines the method to use (GET, POST, etc..)
  67469. * @param url defines the url to connect with
  67470. */
  67471. open(method: string, url: string): void;
  67472. }
  67473. }
  67474. declare module BABYLON {
  67475. /**
  67476. * Class used to evalaute queries containing `and` and `or` operators
  67477. */
  67478. export class AndOrNotEvaluator {
  67479. /**
  67480. * Evaluate a query
  67481. * @param query defines the query to evaluate
  67482. * @param evaluateCallback defines the callback used to filter result
  67483. * @returns true if the query matches
  67484. */
  67485. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67486. private static _HandleParenthesisContent;
  67487. private static _SimplifyNegation;
  67488. }
  67489. }
  67490. declare module BABYLON {
  67491. /**
  67492. * Class used to store custom tags
  67493. */
  67494. export class Tags {
  67495. /**
  67496. * Adds support for tags on the given object
  67497. * @param obj defines the object to use
  67498. */
  67499. static EnableFor(obj: any): void;
  67500. /**
  67501. * Removes tags support
  67502. * @param obj defines the object to use
  67503. */
  67504. static DisableFor(obj: any): void;
  67505. /**
  67506. * Gets a boolean indicating if the given object has tags
  67507. * @param obj defines the object to use
  67508. * @returns a boolean
  67509. */
  67510. static HasTags(obj: any): boolean;
  67511. /**
  67512. * Gets the tags available on a given object
  67513. * @param obj defines the object to use
  67514. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67515. * @returns the tags
  67516. */
  67517. static GetTags(obj: any, asString?: boolean): any;
  67518. /**
  67519. * Adds tags to an object
  67520. * @param obj defines the object to use
  67521. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67522. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67523. */
  67524. static AddTagsTo(obj: any, tagsString: string): void;
  67525. /**
  67526. * @hidden
  67527. */
  67528. static _AddTagTo(obj: any, tag: string): void;
  67529. /**
  67530. * Removes specific tags from a specific object
  67531. * @param obj defines the object to use
  67532. * @param tagsString defines the tags to remove
  67533. */
  67534. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67535. /**
  67536. * @hidden
  67537. */
  67538. static _RemoveTagFrom(obj: any, tag: string): void;
  67539. /**
  67540. * Defines if tags hosted on an object match a given query
  67541. * @param obj defines the object to use
  67542. * @param tagsQuery defines the tag query
  67543. * @returns a boolean
  67544. */
  67545. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67546. }
  67547. }
  67548. declare module BABYLON {
  67549. /**
  67550. * Manages the defines for the Material
  67551. */
  67552. export class MaterialDefines {
  67553. /** @hidden */
  67554. protected _keys: string[];
  67555. private _isDirty;
  67556. /** @hidden */
  67557. _renderId: number;
  67558. /** @hidden */
  67559. _areLightsDirty: boolean;
  67560. /** @hidden */
  67561. _areAttributesDirty: boolean;
  67562. /** @hidden */
  67563. _areTexturesDirty: boolean;
  67564. /** @hidden */
  67565. _areFresnelDirty: boolean;
  67566. /** @hidden */
  67567. _areMiscDirty: boolean;
  67568. /** @hidden */
  67569. _areImageProcessingDirty: boolean;
  67570. /** @hidden */
  67571. _normals: boolean;
  67572. /** @hidden */
  67573. _uvs: boolean;
  67574. /** @hidden */
  67575. _needNormals: boolean;
  67576. /** @hidden */
  67577. _needUVs: boolean;
  67578. [id: string]: any;
  67579. /**
  67580. * Specifies if the material needs to be re-calculated
  67581. */
  67582. readonly isDirty: boolean;
  67583. /**
  67584. * Marks the material to indicate that it has been re-calculated
  67585. */
  67586. markAsProcessed(): void;
  67587. /**
  67588. * Marks the material to indicate that it needs to be re-calculated
  67589. */
  67590. markAsUnprocessed(): void;
  67591. /**
  67592. * Marks the material to indicate all of its defines need to be re-calculated
  67593. */
  67594. markAllAsDirty(): void;
  67595. /**
  67596. * Marks the material to indicate that image processing needs to be re-calculated
  67597. */
  67598. markAsImageProcessingDirty(): void;
  67599. /**
  67600. * Marks the material to indicate the lights need to be re-calculated
  67601. */
  67602. markAsLightDirty(): void;
  67603. /**
  67604. * Marks the attribute state as changed
  67605. */
  67606. markAsAttributesDirty(): void;
  67607. /**
  67608. * Marks the texture state as changed
  67609. */
  67610. markAsTexturesDirty(): void;
  67611. /**
  67612. * Marks the fresnel state as changed
  67613. */
  67614. markAsFresnelDirty(): void;
  67615. /**
  67616. * Marks the misc state as changed
  67617. */
  67618. markAsMiscDirty(): void;
  67619. /**
  67620. * Rebuilds the material defines
  67621. */
  67622. rebuild(): void;
  67623. /**
  67624. * Specifies if two material defines are equal
  67625. * @param other - A material define instance to compare to
  67626. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67627. */
  67628. isEqual(other: MaterialDefines): boolean;
  67629. /**
  67630. * Clones this instance's defines to another instance
  67631. * @param other - material defines to clone values to
  67632. */
  67633. cloneTo(other: MaterialDefines): void;
  67634. /**
  67635. * Resets the material define values
  67636. */
  67637. reset(): void;
  67638. /**
  67639. * Converts the material define values to a string
  67640. * @returns - String of material define information
  67641. */
  67642. toString(): string;
  67643. }
  67644. }
  67645. declare module BABYLON {
  67646. /**
  67647. * Class used to store and describe the pipeline context associated with an effect
  67648. */
  67649. export interface IPipelineContext {
  67650. /**
  67651. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67652. */
  67653. isAsync: boolean;
  67654. /**
  67655. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67656. */
  67657. isReady: boolean;
  67658. /** @hidden */
  67659. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67660. }
  67661. }
  67662. declare module BABYLON {
  67663. /**
  67664. * Class used to store gfx data (like WebGLBuffer)
  67665. */
  67666. export class DataBuffer {
  67667. /**
  67668. * Gets or sets the number of objects referencing this buffer
  67669. */
  67670. references: number;
  67671. /** Gets or sets the size of the underlying buffer */
  67672. capacity: number;
  67673. /**
  67674. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67675. */
  67676. is32Bits: boolean;
  67677. /**
  67678. * Gets the underlying buffer
  67679. */
  67680. readonly underlyingResource: any;
  67681. }
  67682. }
  67683. declare module BABYLON {
  67684. /** @hidden */
  67685. export interface IShaderProcessor {
  67686. attributeProcessor?: (attribute: string) => string;
  67687. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67688. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67689. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67690. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67691. lineProcessor?: (line: string, isFragment: boolean) => string;
  67692. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67693. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67694. }
  67695. }
  67696. declare module BABYLON {
  67697. /** @hidden */
  67698. export interface ProcessingOptions {
  67699. defines: string[];
  67700. indexParameters: any;
  67701. isFragment: boolean;
  67702. shouldUseHighPrecisionShader: boolean;
  67703. supportsUniformBuffers: boolean;
  67704. shadersRepository: string;
  67705. includesShadersStore: {
  67706. [key: string]: string;
  67707. };
  67708. processor?: IShaderProcessor;
  67709. version: string;
  67710. platformName: string;
  67711. lookForClosingBracketForUniformBuffer?: boolean;
  67712. }
  67713. }
  67714. declare module BABYLON {
  67715. /** @hidden */
  67716. export class ShaderCodeNode {
  67717. line: string;
  67718. children: ShaderCodeNode[];
  67719. additionalDefineKey?: string;
  67720. additionalDefineValue?: string;
  67721. isValid(preprocessors: {
  67722. [key: string]: string;
  67723. }): boolean;
  67724. process(preprocessors: {
  67725. [key: string]: string;
  67726. }, options: ProcessingOptions): string;
  67727. }
  67728. }
  67729. declare module BABYLON {
  67730. /** @hidden */
  67731. export class ShaderCodeCursor {
  67732. private _lines;
  67733. lineIndex: number;
  67734. readonly currentLine: string;
  67735. readonly canRead: boolean;
  67736. lines: string[];
  67737. }
  67738. }
  67739. declare module BABYLON {
  67740. /** @hidden */
  67741. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67742. process(preprocessors: {
  67743. [key: string]: string;
  67744. }, options: ProcessingOptions): string;
  67745. }
  67746. }
  67747. declare module BABYLON {
  67748. /** @hidden */
  67749. export class ShaderDefineExpression {
  67750. isTrue(preprocessors: {
  67751. [key: string]: string;
  67752. }): boolean;
  67753. }
  67754. }
  67755. declare module BABYLON {
  67756. /** @hidden */
  67757. export class ShaderCodeTestNode extends ShaderCodeNode {
  67758. testExpression: ShaderDefineExpression;
  67759. isValid(preprocessors: {
  67760. [key: string]: string;
  67761. }): boolean;
  67762. }
  67763. }
  67764. declare module BABYLON {
  67765. /** @hidden */
  67766. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67767. define: string;
  67768. not: boolean;
  67769. constructor(define: string, not?: boolean);
  67770. isTrue(preprocessors: {
  67771. [key: string]: string;
  67772. }): boolean;
  67773. }
  67774. }
  67775. declare module BABYLON {
  67776. /** @hidden */
  67777. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67778. leftOperand: ShaderDefineExpression;
  67779. rightOperand: ShaderDefineExpression;
  67780. isTrue(preprocessors: {
  67781. [key: string]: string;
  67782. }): boolean;
  67783. }
  67784. }
  67785. declare module BABYLON {
  67786. /** @hidden */
  67787. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67788. leftOperand: ShaderDefineExpression;
  67789. rightOperand: ShaderDefineExpression;
  67790. isTrue(preprocessors: {
  67791. [key: string]: string;
  67792. }): boolean;
  67793. }
  67794. }
  67795. declare module BABYLON {
  67796. /** @hidden */
  67797. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67798. define: string;
  67799. operand: string;
  67800. testValue: string;
  67801. constructor(define: string, operand: string, testValue: string);
  67802. isTrue(preprocessors: {
  67803. [key: string]: string;
  67804. }): boolean;
  67805. }
  67806. }
  67807. declare module BABYLON {
  67808. /** @hidden */
  67809. export class ShaderProcessor {
  67810. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67811. private static _ProcessPrecision;
  67812. private static _ExtractOperation;
  67813. private static _BuildSubExpression;
  67814. private static _BuildExpression;
  67815. private static _MoveCursorWithinIf;
  67816. private static _MoveCursor;
  67817. private static _EvaluatePreProcessors;
  67818. private static _PreparePreProcessors;
  67819. private static _ProcessShaderConversion;
  67820. private static _ProcessIncludes;
  67821. }
  67822. }
  67823. declare module BABYLON {
  67824. /**
  67825. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67826. */
  67827. export class PerformanceMonitor {
  67828. private _enabled;
  67829. private _rollingFrameTime;
  67830. private _lastFrameTimeMs;
  67831. /**
  67832. * constructor
  67833. * @param frameSampleSize The number of samples required to saturate the sliding window
  67834. */
  67835. constructor(frameSampleSize?: number);
  67836. /**
  67837. * Samples current frame
  67838. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  67839. */
  67840. sampleFrame(timeMs?: number): void;
  67841. /**
  67842. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67843. */
  67844. readonly averageFrameTime: number;
  67845. /**
  67846. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67847. */
  67848. readonly averageFrameTimeVariance: number;
  67849. /**
  67850. * Returns the frame time of the most recent frame
  67851. */
  67852. readonly instantaneousFrameTime: number;
  67853. /**
  67854. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  67855. */
  67856. readonly averageFPS: number;
  67857. /**
  67858. * Returns the average framerate in frames per second using the most recent frame time
  67859. */
  67860. readonly instantaneousFPS: number;
  67861. /**
  67862. * Returns true if enough samples have been taken to completely fill the sliding window
  67863. */
  67864. readonly isSaturated: boolean;
  67865. /**
  67866. * Enables contributions to the sliding window sample set
  67867. */
  67868. enable(): void;
  67869. /**
  67870. * Disables contributions to the sliding window sample set
  67871. * Samples will not be interpolated over the disabled period
  67872. */
  67873. disable(): void;
  67874. /**
  67875. * Returns true if sampling is enabled
  67876. */
  67877. readonly isEnabled: boolean;
  67878. /**
  67879. * Resets performance monitor
  67880. */
  67881. reset(): void;
  67882. }
  67883. /**
  67884. * RollingAverage
  67885. *
  67886. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  67887. */
  67888. export class RollingAverage {
  67889. /**
  67890. * Current average
  67891. */
  67892. average: number;
  67893. /**
  67894. * Current variance
  67895. */
  67896. variance: number;
  67897. protected _samples: Array<number>;
  67898. protected _sampleCount: number;
  67899. protected _pos: number;
  67900. protected _m2: number;
  67901. /**
  67902. * constructor
  67903. * @param length The number of samples required to saturate the sliding window
  67904. */
  67905. constructor(length: number);
  67906. /**
  67907. * Adds a sample to the sample set
  67908. * @param v The sample value
  67909. */
  67910. add(v: number): void;
  67911. /**
  67912. * Returns previously added values or null if outside of history or outside the sliding window domain
  67913. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  67914. * @return Value previously recorded with add() or null if outside of range
  67915. */
  67916. history(i: number): number;
  67917. /**
  67918. * Returns true if enough samples have been taken to completely fill the sliding window
  67919. * @return true if sample-set saturated
  67920. */
  67921. isSaturated(): boolean;
  67922. /**
  67923. * Resets the rolling average (equivalent to 0 samples taken so far)
  67924. */
  67925. reset(): void;
  67926. /**
  67927. * Wraps a value around the sample range boundaries
  67928. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  67929. * @return Wrapped position in sample range
  67930. */
  67931. protected _wrapPosition(i: number): number;
  67932. }
  67933. }
  67934. declare module BABYLON {
  67935. /**
  67936. * This class implement a typical dictionary using a string as key and the generic type T as value.
  67937. * The underlying implementation relies on an associative array to ensure the best performances.
  67938. * The value can be anything including 'null' but except 'undefined'
  67939. */
  67940. export class StringDictionary<T> {
  67941. /**
  67942. * This will clear this dictionary and copy the content from the 'source' one.
  67943. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  67944. * @param source the dictionary to take the content from and copy to this dictionary
  67945. */
  67946. copyFrom(source: StringDictionary<T>): void;
  67947. /**
  67948. * Get a value based from its key
  67949. * @param key the given key to get the matching value from
  67950. * @return the value if found, otherwise undefined is returned
  67951. */
  67952. get(key: string): T | undefined;
  67953. /**
  67954. * Get a value from its key or add it if it doesn't exist.
  67955. * This method will ensure you that a given key/data will be present in the dictionary.
  67956. * @param key the given key to get the matching value from
  67957. * @param factory the factory that will create the value if the key is not present in the dictionary.
  67958. * The factory will only be invoked if there's no data for the given key.
  67959. * @return the value corresponding to the key.
  67960. */
  67961. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  67962. /**
  67963. * Get a value from its key if present in the dictionary otherwise add it
  67964. * @param key the key to get the value from
  67965. * @param val if there's no such key/value pair in the dictionary add it with this value
  67966. * @return the value corresponding to the key
  67967. */
  67968. getOrAdd(key: string, val: T): T;
  67969. /**
  67970. * Check if there's a given key in the dictionary
  67971. * @param key the key to check for
  67972. * @return true if the key is present, false otherwise
  67973. */
  67974. contains(key: string): boolean;
  67975. /**
  67976. * Add a new key and its corresponding value
  67977. * @param key the key to add
  67978. * @param value the value corresponding to the key
  67979. * @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
  67980. */
  67981. add(key: string, value: T): boolean;
  67982. /**
  67983. * Update a specific value associated to a key
  67984. * @param key defines the key to use
  67985. * @param value defines the value to store
  67986. * @returns true if the value was updated (or false if the key was not found)
  67987. */
  67988. set(key: string, value: T): boolean;
  67989. /**
  67990. * Get the element of the given key and remove it from the dictionary
  67991. * @param key defines the key to search
  67992. * @returns the value associated with the key or null if not found
  67993. */
  67994. getAndRemove(key: string): Nullable<T>;
  67995. /**
  67996. * Remove a key/value from the dictionary.
  67997. * @param key the key to remove
  67998. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  67999. */
  68000. remove(key: string): boolean;
  68001. /**
  68002. * Clear the whole content of the dictionary
  68003. */
  68004. clear(): void;
  68005. /**
  68006. * Gets the current count
  68007. */
  68008. readonly count: number;
  68009. /**
  68010. * Execute a callback on each key/val of the dictionary.
  68011. * Note that you can remove any element in this dictionary in the callback implementation
  68012. * @param callback the callback to execute on a given key/value pair
  68013. */
  68014. forEach(callback: (key: string, val: T) => void): void;
  68015. /**
  68016. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68017. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68018. * Note that you can remove any element in this dictionary in the callback implementation
  68019. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68020. * @returns the first item
  68021. */
  68022. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68023. private _count;
  68024. private _data;
  68025. }
  68026. }
  68027. declare module BABYLON {
  68028. /**
  68029. * Helper class that provides a small promise polyfill
  68030. */
  68031. export class PromisePolyfill {
  68032. /**
  68033. * Static function used to check if the polyfill is required
  68034. * If this is the case then the function will inject the polyfill to window.Promise
  68035. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68036. */
  68037. static Apply(force?: boolean): void;
  68038. }
  68039. }
  68040. declare module BABYLON {
  68041. /**
  68042. * Class used to store data that will be store in GPU memory
  68043. */
  68044. export class Buffer {
  68045. private _engine;
  68046. private _buffer;
  68047. /** @hidden */
  68048. _data: Nullable<DataArray>;
  68049. private _updatable;
  68050. private _instanced;
  68051. /**
  68052. * Gets the byte stride.
  68053. */
  68054. readonly byteStride: number;
  68055. /**
  68056. * Constructor
  68057. * @param engine the engine
  68058. * @param data the data to use for this buffer
  68059. * @param updatable whether the data is updatable
  68060. * @param stride the stride (optional)
  68061. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68062. * @param instanced whether the buffer is instanced (optional)
  68063. * @param useBytes set to true if the stride in in bytes (optional)
  68064. */
  68065. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68066. /**
  68067. * Create a new VertexBuffer based on the current buffer
  68068. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68069. * @param offset defines offset in the buffer (0 by default)
  68070. * @param size defines the size in floats of attributes (position is 3 for instance)
  68071. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68072. * @param instanced defines if the vertex buffer contains indexed data
  68073. * @param useBytes defines if the offset and stride are in bytes
  68074. * @returns the new vertex buffer
  68075. */
  68076. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68077. /**
  68078. * Gets a boolean indicating if the Buffer is updatable?
  68079. * @returns true if the buffer is updatable
  68080. */
  68081. isUpdatable(): boolean;
  68082. /**
  68083. * Gets current buffer's data
  68084. * @returns a DataArray or null
  68085. */
  68086. getData(): Nullable<DataArray>;
  68087. /**
  68088. * Gets underlying native buffer
  68089. * @returns underlying native buffer
  68090. */
  68091. getBuffer(): Nullable<DataBuffer>;
  68092. /**
  68093. * Gets the stride in float32 units (i.e. byte stride / 4).
  68094. * May not be an integer if the byte stride is not divisible by 4.
  68095. * DEPRECATED. Use byteStride instead.
  68096. * @returns the stride in float32 units
  68097. */
  68098. getStrideSize(): number;
  68099. /**
  68100. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68101. * @param data defines the data to store
  68102. */
  68103. create(data?: Nullable<DataArray>): void;
  68104. /** @hidden */
  68105. _rebuild(): void;
  68106. /**
  68107. * Update current buffer data
  68108. * @param data defines the data to store
  68109. */
  68110. update(data: DataArray): void;
  68111. /**
  68112. * Updates the data directly.
  68113. * @param data the new data
  68114. * @param offset the new offset
  68115. * @param vertexCount the vertex count (optional)
  68116. * @param useBytes set to true if the offset is in bytes
  68117. */
  68118. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68119. /**
  68120. * Release all resources
  68121. */
  68122. dispose(): void;
  68123. }
  68124. /**
  68125. * Specialized buffer used to store vertex data
  68126. */
  68127. export class VertexBuffer {
  68128. /** @hidden */
  68129. _buffer: Buffer;
  68130. private _kind;
  68131. private _size;
  68132. private _ownsBuffer;
  68133. private _instanced;
  68134. private _instanceDivisor;
  68135. /**
  68136. * The byte type.
  68137. */
  68138. static readonly BYTE: number;
  68139. /**
  68140. * The unsigned byte type.
  68141. */
  68142. static readonly UNSIGNED_BYTE: number;
  68143. /**
  68144. * The short type.
  68145. */
  68146. static readonly SHORT: number;
  68147. /**
  68148. * The unsigned short type.
  68149. */
  68150. static readonly UNSIGNED_SHORT: number;
  68151. /**
  68152. * The integer type.
  68153. */
  68154. static readonly INT: number;
  68155. /**
  68156. * The unsigned integer type.
  68157. */
  68158. static readonly UNSIGNED_INT: number;
  68159. /**
  68160. * The float type.
  68161. */
  68162. static readonly FLOAT: number;
  68163. /**
  68164. * Gets or sets the instance divisor when in instanced mode
  68165. */
  68166. instanceDivisor: number;
  68167. /**
  68168. * Gets the byte stride.
  68169. */
  68170. readonly byteStride: number;
  68171. /**
  68172. * Gets the byte offset.
  68173. */
  68174. readonly byteOffset: number;
  68175. /**
  68176. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68177. */
  68178. readonly normalized: boolean;
  68179. /**
  68180. * Gets the data type of each component in the array.
  68181. */
  68182. readonly type: number;
  68183. /**
  68184. * Constructor
  68185. * @param engine the engine
  68186. * @param data the data to use for this vertex buffer
  68187. * @param kind the vertex buffer kind
  68188. * @param updatable whether the data is updatable
  68189. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68190. * @param stride the stride (optional)
  68191. * @param instanced whether the buffer is instanced (optional)
  68192. * @param offset the offset of the data (optional)
  68193. * @param size the number of components (optional)
  68194. * @param type the type of the component (optional)
  68195. * @param normalized whether the data contains normalized data (optional)
  68196. * @param useBytes set to true if stride and offset are in bytes (optional)
  68197. */
  68198. 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);
  68199. /** @hidden */
  68200. _rebuild(): void;
  68201. /**
  68202. * Returns the kind of the VertexBuffer (string)
  68203. * @returns a string
  68204. */
  68205. getKind(): string;
  68206. /**
  68207. * Gets a boolean indicating if the VertexBuffer is updatable?
  68208. * @returns true if the buffer is updatable
  68209. */
  68210. isUpdatable(): boolean;
  68211. /**
  68212. * Gets current buffer's data
  68213. * @returns a DataArray or null
  68214. */
  68215. getData(): Nullable<DataArray>;
  68216. /**
  68217. * Gets underlying native buffer
  68218. * @returns underlying native buffer
  68219. */
  68220. getBuffer(): Nullable<DataBuffer>;
  68221. /**
  68222. * Gets the stride in float32 units (i.e. byte stride / 4).
  68223. * May not be an integer if the byte stride is not divisible by 4.
  68224. * DEPRECATED. Use byteStride instead.
  68225. * @returns the stride in float32 units
  68226. */
  68227. getStrideSize(): number;
  68228. /**
  68229. * Returns the offset as a multiple of the type byte length.
  68230. * DEPRECATED. Use byteOffset instead.
  68231. * @returns the offset in bytes
  68232. */
  68233. getOffset(): number;
  68234. /**
  68235. * Returns the number of components per vertex attribute (integer)
  68236. * @returns the size in float
  68237. */
  68238. getSize(): number;
  68239. /**
  68240. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68241. * @returns true if this buffer is instanced
  68242. */
  68243. getIsInstanced(): boolean;
  68244. /**
  68245. * Returns the instancing divisor, zero for non-instanced (integer).
  68246. * @returns a number
  68247. */
  68248. getInstanceDivisor(): number;
  68249. /**
  68250. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68251. * @param data defines the data to store
  68252. */
  68253. create(data?: DataArray): void;
  68254. /**
  68255. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68256. * This function will create a new buffer if the current one is not updatable
  68257. * @param data defines the data to store
  68258. */
  68259. update(data: DataArray): void;
  68260. /**
  68261. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68262. * Returns the directly updated WebGLBuffer.
  68263. * @param data the new data
  68264. * @param offset the new offset
  68265. * @param useBytes set to true if the offset is in bytes
  68266. */
  68267. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68268. /**
  68269. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68270. */
  68271. dispose(): void;
  68272. /**
  68273. * Enumerates each value of this vertex buffer as numbers.
  68274. * @param count the number of values to enumerate
  68275. * @param callback the callback function called for each value
  68276. */
  68277. forEach(count: number, callback: (value: number, index: number) => void): void;
  68278. /**
  68279. * Positions
  68280. */
  68281. static readonly PositionKind: string;
  68282. /**
  68283. * Normals
  68284. */
  68285. static readonly NormalKind: string;
  68286. /**
  68287. * Tangents
  68288. */
  68289. static readonly TangentKind: string;
  68290. /**
  68291. * Texture coordinates
  68292. */
  68293. static readonly UVKind: string;
  68294. /**
  68295. * Texture coordinates 2
  68296. */
  68297. static readonly UV2Kind: string;
  68298. /**
  68299. * Texture coordinates 3
  68300. */
  68301. static readonly UV3Kind: string;
  68302. /**
  68303. * Texture coordinates 4
  68304. */
  68305. static readonly UV4Kind: string;
  68306. /**
  68307. * Texture coordinates 5
  68308. */
  68309. static readonly UV5Kind: string;
  68310. /**
  68311. * Texture coordinates 6
  68312. */
  68313. static readonly UV6Kind: string;
  68314. /**
  68315. * Colors
  68316. */
  68317. static readonly ColorKind: string;
  68318. /**
  68319. * Matrix indices (for bones)
  68320. */
  68321. static readonly MatricesIndicesKind: string;
  68322. /**
  68323. * Matrix weights (for bones)
  68324. */
  68325. static readonly MatricesWeightsKind: string;
  68326. /**
  68327. * Additional matrix indices (for bones)
  68328. */
  68329. static readonly MatricesIndicesExtraKind: string;
  68330. /**
  68331. * Additional matrix weights (for bones)
  68332. */
  68333. static readonly MatricesWeightsExtraKind: string;
  68334. /**
  68335. * Deduces the stride given a kind.
  68336. * @param kind The kind string to deduce
  68337. * @returns The deduced stride
  68338. */
  68339. static DeduceStride(kind: string): number;
  68340. /**
  68341. * Gets the byte length of the given type.
  68342. * @param type the type
  68343. * @returns the number of bytes
  68344. */
  68345. static GetTypeByteLength(type: number): number;
  68346. /**
  68347. * Enumerates each value of the given parameters as numbers.
  68348. * @param data the data to enumerate
  68349. * @param byteOffset the byte offset of the data
  68350. * @param byteStride the byte stride of the data
  68351. * @param componentCount the number of components per element
  68352. * @param componentType the type of the component
  68353. * @param count the total number of components
  68354. * @param normalized whether the data is normalized
  68355. * @param callback the callback function called for each value
  68356. */
  68357. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68358. private static _GetFloatValue;
  68359. }
  68360. }
  68361. declare module BABYLON {
  68362. /**
  68363. * Class representing spherical harmonics coefficients to the 3rd degree
  68364. */
  68365. export class SphericalHarmonics {
  68366. /**
  68367. * Defines whether or not the harmonics have been prescaled for rendering.
  68368. */
  68369. preScaled: boolean;
  68370. /**
  68371. * The l0,0 coefficients of the spherical harmonics
  68372. */
  68373. l00: Vector3;
  68374. /**
  68375. * The l1,-1 coefficients of the spherical harmonics
  68376. */
  68377. l1_1: Vector3;
  68378. /**
  68379. * The l1,0 coefficients of the spherical harmonics
  68380. */
  68381. l10: Vector3;
  68382. /**
  68383. * The l1,1 coefficients of the spherical harmonics
  68384. */
  68385. l11: Vector3;
  68386. /**
  68387. * The l2,-2 coefficients of the spherical harmonics
  68388. */
  68389. l2_2: Vector3;
  68390. /**
  68391. * The l2,-1 coefficients of the spherical harmonics
  68392. */
  68393. l2_1: Vector3;
  68394. /**
  68395. * The l2,0 coefficients of the spherical harmonics
  68396. */
  68397. l20: Vector3;
  68398. /**
  68399. * The l2,1 coefficients of the spherical harmonics
  68400. */
  68401. l21: Vector3;
  68402. /**
  68403. * The l2,2 coefficients of the spherical harmonics
  68404. */
  68405. l22: Vector3;
  68406. /**
  68407. * Adds a light to the spherical harmonics
  68408. * @param direction the direction of the light
  68409. * @param color the color of the light
  68410. * @param deltaSolidAngle the delta solid angle of the light
  68411. */
  68412. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68413. /**
  68414. * Scales the spherical harmonics by the given amount
  68415. * @param scale the amount to scale
  68416. */
  68417. scaleInPlace(scale: number): void;
  68418. /**
  68419. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68420. *
  68421. * ```
  68422. * E_lm = A_l * L_lm
  68423. * ```
  68424. *
  68425. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68426. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68427. * the scaling factors are given in equation 9.
  68428. */
  68429. convertIncidentRadianceToIrradiance(): void;
  68430. /**
  68431. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68432. *
  68433. * ```
  68434. * L = (1/pi) * E * rho
  68435. * ```
  68436. *
  68437. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68438. */
  68439. convertIrradianceToLambertianRadiance(): void;
  68440. /**
  68441. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68442. * required operations at run time.
  68443. *
  68444. * This is simply done by scaling back the SH with Ylm constants parameter.
  68445. * The trigonometric part being applied by the shader at run time.
  68446. */
  68447. preScaleForRendering(): void;
  68448. /**
  68449. * Constructs a spherical harmonics from an array.
  68450. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68451. * @returns the spherical harmonics
  68452. */
  68453. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68454. /**
  68455. * Gets the spherical harmonics from polynomial
  68456. * @param polynomial the spherical polynomial
  68457. * @returns the spherical harmonics
  68458. */
  68459. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68460. }
  68461. /**
  68462. * Class representing spherical polynomial coefficients to the 3rd degree
  68463. */
  68464. export class SphericalPolynomial {
  68465. private _harmonics;
  68466. /**
  68467. * The spherical harmonics used to create the polynomials.
  68468. */
  68469. readonly preScaledHarmonics: SphericalHarmonics;
  68470. /**
  68471. * The x coefficients of the spherical polynomial
  68472. */
  68473. x: Vector3;
  68474. /**
  68475. * The y coefficients of the spherical polynomial
  68476. */
  68477. y: Vector3;
  68478. /**
  68479. * The z coefficients of the spherical polynomial
  68480. */
  68481. z: Vector3;
  68482. /**
  68483. * The xx coefficients of the spherical polynomial
  68484. */
  68485. xx: Vector3;
  68486. /**
  68487. * The yy coefficients of the spherical polynomial
  68488. */
  68489. yy: Vector3;
  68490. /**
  68491. * The zz coefficients of the spherical polynomial
  68492. */
  68493. zz: Vector3;
  68494. /**
  68495. * The xy coefficients of the spherical polynomial
  68496. */
  68497. xy: Vector3;
  68498. /**
  68499. * The yz coefficients of the spherical polynomial
  68500. */
  68501. yz: Vector3;
  68502. /**
  68503. * The zx coefficients of the spherical polynomial
  68504. */
  68505. zx: Vector3;
  68506. /**
  68507. * Adds an ambient color to the spherical polynomial
  68508. * @param color the color to add
  68509. */
  68510. addAmbient(color: Color3): void;
  68511. /**
  68512. * Scales the spherical polynomial by the given amount
  68513. * @param scale the amount to scale
  68514. */
  68515. scaleInPlace(scale: number): void;
  68516. /**
  68517. * Gets the spherical polynomial from harmonics
  68518. * @param harmonics the spherical harmonics
  68519. * @returns the spherical polynomial
  68520. */
  68521. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68522. /**
  68523. * Constructs a spherical polynomial from an array.
  68524. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68525. * @returns the spherical polynomial
  68526. */
  68527. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68528. }
  68529. }
  68530. declare module BABYLON {
  68531. /**
  68532. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68533. */
  68534. export interface CubeMapInfo {
  68535. /**
  68536. * The pixel array for the front face.
  68537. * This is stored in format, left to right, up to down format.
  68538. */
  68539. front: Nullable<ArrayBufferView>;
  68540. /**
  68541. * The pixel array for the back face.
  68542. * This is stored in format, left to right, up to down format.
  68543. */
  68544. back: Nullable<ArrayBufferView>;
  68545. /**
  68546. * The pixel array for the left face.
  68547. * This is stored in format, left to right, up to down format.
  68548. */
  68549. left: Nullable<ArrayBufferView>;
  68550. /**
  68551. * The pixel array for the right face.
  68552. * This is stored in format, left to right, up to down format.
  68553. */
  68554. right: Nullable<ArrayBufferView>;
  68555. /**
  68556. * The pixel array for the up face.
  68557. * This is stored in format, left to right, up to down format.
  68558. */
  68559. up: Nullable<ArrayBufferView>;
  68560. /**
  68561. * The pixel array for the down face.
  68562. * This is stored in format, left to right, up to down format.
  68563. */
  68564. down: Nullable<ArrayBufferView>;
  68565. /**
  68566. * The size of the cubemap stored.
  68567. *
  68568. * Each faces will be size * size pixels.
  68569. */
  68570. size: number;
  68571. /**
  68572. * The format of the texture.
  68573. *
  68574. * RGBA, RGB.
  68575. */
  68576. format: number;
  68577. /**
  68578. * The type of the texture data.
  68579. *
  68580. * UNSIGNED_INT, FLOAT.
  68581. */
  68582. type: number;
  68583. /**
  68584. * Specifies whether the texture is in gamma space.
  68585. */
  68586. gammaSpace: boolean;
  68587. }
  68588. /**
  68589. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68590. */
  68591. export class PanoramaToCubeMapTools {
  68592. private static FACE_FRONT;
  68593. private static FACE_BACK;
  68594. private static FACE_RIGHT;
  68595. private static FACE_LEFT;
  68596. private static FACE_DOWN;
  68597. private static FACE_UP;
  68598. /**
  68599. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68600. *
  68601. * @param float32Array The source data.
  68602. * @param inputWidth The width of the input panorama.
  68603. * @param inputHeight The height of the input panorama.
  68604. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68605. * @return The cubemap data
  68606. */
  68607. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68608. private static CreateCubemapTexture;
  68609. private static CalcProjectionSpherical;
  68610. }
  68611. }
  68612. declare module BABYLON {
  68613. /**
  68614. * Helper class dealing with the extraction of spherical polynomial dataArray
  68615. * from a cube map.
  68616. */
  68617. export class CubeMapToSphericalPolynomialTools {
  68618. private static FileFaces;
  68619. /**
  68620. * Converts a texture to the according Spherical Polynomial data.
  68621. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68622. *
  68623. * @param texture The texture to extract the information from.
  68624. * @return The Spherical Polynomial data.
  68625. */
  68626. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68627. /**
  68628. * Converts a cubemap to the according Spherical Polynomial data.
  68629. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68630. *
  68631. * @param cubeInfo The Cube map to extract the information from.
  68632. * @return The Spherical Polynomial data.
  68633. */
  68634. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68635. }
  68636. }
  68637. declare module BABYLON {
  68638. /**
  68639. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68640. * during the life time of the application.
  68641. */
  68642. export class EngineStore {
  68643. /** Gets the list of created engines */
  68644. static Instances: Engine[];
  68645. /** @hidden */
  68646. static _LastCreatedScene: Nullable<Scene>;
  68647. /**
  68648. * Gets the latest created engine
  68649. */
  68650. static readonly LastCreatedEngine: Nullable<Engine>;
  68651. /**
  68652. * Gets the latest created scene
  68653. */
  68654. static readonly LastCreatedScene: Nullable<Scene>;
  68655. }
  68656. }
  68657. declare module BABYLON {
  68658. /**
  68659. * Define options used to create a render target texture
  68660. */
  68661. export class RenderTargetCreationOptions {
  68662. /**
  68663. * Specifies is mipmaps must be generated
  68664. */
  68665. generateMipMaps?: boolean;
  68666. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68667. generateDepthBuffer?: boolean;
  68668. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68669. generateStencilBuffer?: boolean;
  68670. /** Defines texture type (int by default) */
  68671. type?: number;
  68672. /** Defines sampling mode (trilinear by default) */
  68673. samplingMode?: number;
  68674. /** Defines format (RGBA by default) */
  68675. format?: number;
  68676. }
  68677. }
  68678. declare module BABYLON {
  68679. /**
  68680. * @hidden
  68681. **/
  68682. export class _AlphaState {
  68683. private _isAlphaBlendDirty;
  68684. private _isBlendFunctionParametersDirty;
  68685. private _isBlendEquationParametersDirty;
  68686. private _isBlendConstantsDirty;
  68687. private _alphaBlend;
  68688. private _blendFunctionParameters;
  68689. private _blendEquationParameters;
  68690. private _blendConstants;
  68691. /**
  68692. * Initializes the state.
  68693. */
  68694. constructor();
  68695. readonly isDirty: boolean;
  68696. alphaBlend: boolean;
  68697. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68698. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68699. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68700. reset(): void;
  68701. apply(gl: WebGLRenderingContext): void;
  68702. }
  68703. }
  68704. declare module BABYLON {
  68705. /**
  68706. * @hidden
  68707. **/
  68708. export class _DepthCullingState {
  68709. private _isDepthTestDirty;
  68710. private _isDepthMaskDirty;
  68711. private _isDepthFuncDirty;
  68712. private _isCullFaceDirty;
  68713. private _isCullDirty;
  68714. private _isZOffsetDirty;
  68715. private _isFrontFaceDirty;
  68716. private _depthTest;
  68717. private _depthMask;
  68718. private _depthFunc;
  68719. private _cull;
  68720. private _cullFace;
  68721. private _zOffset;
  68722. private _frontFace;
  68723. /**
  68724. * Initializes the state.
  68725. */
  68726. constructor();
  68727. readonly isDirty: boolean;
  68728. zOffset: number;
  68729. cullFace: Nullable<number>;
  68730. cull: Nullable<boolean>;
  68731. depthFunc: Nullable<number>;
  68732. depthMask: boolean;
  68733. depthTest: boolean;
  68734. frontFace: Nullable<number>;
  68735. reset(): void;
  68736. apply(gl: WebGLRenderingContext): void;
  68737. }
  68738. }
  68739. declare module BABYLON {
  68740. /**
  68741. * @hidden
  68742. **/
  68743. export class _StencilState {
  68744. /** 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 */
  68745. static readonly ALWAYS: number;
  68746. /** Passed to stencilOperation to specify that stencil value must be kept */
  68747. static readonly KEEP: number;
  68748. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68749. static readonly REPLACE: number;
  68750. private _isStencilTestDirty;
  68751. private _isStencilMaskDirty;
  68752. private _isStencilFuncDirty;
  68753. private _isStencilOpDirty;
  68754. private _stencilTest;
  68755. private _stencilMask;
  68756. private _stencilFunc;
  68757. private _stencilFuncRef;
  68758. private _stencilFuncMask;
  68759. private _stencilOpStencilFail;
  68760. private _stencilOpDepthFail;
  68761. private _stencilOpStencilDepthPass;
  68762. readonly isDirty: boolean;
  68763. stencilFunc: number;
  68764. stencilFuncRef: number;
  68765. stencilFuncMask: number;
  68766. stencilOpStencilFail: number;
  68767. stencilOpDepthFail: number;
  68768. stencilOpStencilDepthPass: number;
  68769. stencilMask: number;
  68770. stencilTest: boolean;
  68771. constructor();
  68772. reset(): void;
  68773. apply(gl: WebGLRenderingContext): void;
  68774. }
  68775. }
  68776. declare module BABYLON {
  68777. /**
  68778. * @hidden
  68779. **/
  68780. export class _TimeToken {
  68781. _startTimeQuery: Nullable<WebGLQuery>;
  68782. _endTimeQuery: Nullable<WebGLQuery>;
  68783. _timeElapsedQuery: Nullable<WebGLQuery>;
  68784. _timeElapsedQueryEnded: boolean;
  68785. }
  68786. }
  68787. declare module BABYLON {
  68788. /**
  68789. * Class used to store data associated with WebGL texture data for the engine
  68790. * This class should not be used directly
  68791. */
  68792. export class InternalTexture {
  68793. /** @hidden */
  68794. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68795. /**
  68796. * The source of the texture data is unknown
  68797. */
  68798. static DATASOURCE_UNKNOWN: number;
  68799. /**
  68800. * Texture data comes from an URL
  68801. */
  68802. static DATASOURCE_URL: number;
  68803. /**
  68804. * Texture data is only used for temporary storage
  68805. */
  68806. static DATASOURCE_TEMP: number;
  68807. /**
  68808. * Texture data comes from raw data (ArrayBuffer)
  68809. */
  68810. static DATASOURCE_RAW: number;
  68811. /**
  68812. * Texture content is dynamic (video or dynamic texture)
  68813. */
  68814. static DATASOURCE_DYNAMIC: number;
  68815. /**
  68816. * Texture content is generated by rendering to it
  68817. */
  68818. static DATASOURCE_RENDERTARGET: number;
  68819. /**
  68820. * Texture content is part of a multi render target process
  68821. */
  68822. static DATASOURCE_MULTIRENDERTARGET: number;
  68823. /**
  68824. * Texture data comes from a cube data file
  68825. */
  68826. static DATASOURCE_CUBE: number;
  68827. /**
  68828. * Texture data comes from a raw cube data
  68829. */
  68830. static DATASOURCE_CUBERAW: number;
  68831. /**
  68832. * Texture data come from a prefiltered cube data file
  68833. */
  68834. static DATASOURCE_CUBEPREFILTERED: number;
  68835. /**
  68836. * Texture content is raw 3D data
  68837. */
  68838. static DATASOURCE_RAW3D: number;
  68839. /**
  68840. * Texture content is a depth texture
  68841. */
  68842. static DATASOURCE_DEPTHTEXTURE: number;
  68843. /**
  68844. * Texture data comes from a raw cube data encoded with RGBD
  68845. */
  68846. static DATASOURCE_CUBERAW_RGBD: number;
  68847. /**
  68848. * Defines if the texture is ready
  68849. */
  68850. isReady: boolean;
  68851. /**
  68852. * Defines if the texture is a cube texture
  68853. */
  68854. isCube: boolean;
  68855. /**
  68856. * Defines if the texture contains 3D data
  68857. */
  68858. is3D: boolean;
  68859. /**
  68860. * Defines if the texture contains multiview data
  68861. */
  68862. isMultiview: boolean;
  68863. /**
  68864. * Gets the URL used to load this texture
  68865. */
  68866. url: string;
  68867. /**
  68868. * Gets the sampling mode of the texture
  68869. */
  68870. samplingMode: number;
  68871. /**
  68872. * Gets a boolean indicating if the texture needs mipmaps generation
  68873. */
  68874. generateMipMaps: boolean;
  68875. /**
  68876. * Gets the number of samples used by the texture (WebGL2+ only)
  68877. */
  68878. samples: number;
  68879. /**
  68880. * Gets the type of the texture (int, float...)
  68881. */
  68882. type: number;
  68883. /**
  68884. * Gets the format of the texture (RGB, RGBA...)
  68885. */
  68886. format: number;
  68887. /**
  68888. * Observable called when the texture is loaded
  68889. */
  68890. onLoadedObservable: Observable<InternalTexture>;
  68891. /**
  68892. * Gets the width of the texture
  68893. */
  68894. width: number;
  68895. /**
  68896. * Gets the height of the texture
  68897. */
  68898. height: number;
  68899. /**
  68900. * Gets the depth of the texture
  68901. */
  68902. depth: number;
  68903. /**
  68904. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  68905. */
  68906. baseWidth: number;
  68907. /**
  68908. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  68909. */
  68910. baseHeight: number;
  68911. /**
  68912. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  68913. */
  68914. baseDepth: number;
  68915. /**
  68916. * Gets a boolean indicating if the texture is inverted on Y axis
  68917. */
  68918. invertY: boolean;
  68919. /** @hidden */
  68920. _invertVScale: boolean;
  68921. /** @hidden */
  68922. _associatedChannel: number;
  68923. /** @hidden */
  68924. _dataSource: number;
  68925. /** @hidden */
  68926. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68927. /** @hidden */
  68928. _bufferView: Nullable<ArrayBufferView>;
  68929. /** @hidden */
  68930. _bufferViewArray: Nullable<ArrayBufferView[]>;
  68931. /** @hidden */
  68932. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  68933. /** @hidden */
  68934. _size: number;
  68935. /** @hidden */
  68936. _extension: string;
  68937. /** @hidden */
  68938. _files: Nullable<string[]>;
  68939. /** @hidden */
  68940. _workingCanvas: Nullable<HTMLCanvasElement>;
  68941. /** @hidden */
  68942. _workingContext: Nullable<CanvasRenderingContext2D>;
  68943. /** @hidden */
  68944. _framebuffer: Nullable<WebGLFramebuffer>;
  68945. /** @hidden */
  68946. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  68947. /** @hidden */
  68948. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  68949. /** @hidden */
  68950. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  68951. /** @hidden */
  68952. _attachments: Nullable<number[]>;
  68953. /** @hidden */
  68954. _cachedCoordinatesMode: Nullable<number>;
  68955. /** @hidden */
  68956. _cachedWrapU: Nullable<number>;
  68957. /** @hidden */
  68958. _cachedWrapV: Nullable<number>;
  68959. /** @hidden */
  68960. _cachedWrapR: Nullable<number>;
  68961. /** @hidden */
  68962. _cachedAnisotropicFilteringLevel: Nullable<number>;
  68963. /** @hidden */
  68964. _isDisabled: boolean;
  68965. /** @hidden */
  68966. _compression: Nullable<string>;
  68967. /** @hidden */
  68968. _generateStencilBuffer: boolean;
  68969. /** @hidden */
  68970. _generateDepthBuffer: boolean;
  68971. /** @hidden */
  68972. _comparisonFunction: number;
  68973. /** @hidden */
  68974. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  68975. /** @hidden */
  68976. _lodGenerationScale: number;
  68977. /** @hidden */
  68978. _lodGenerationOffset: number;
  68979. /** @hidden */
  68980. _colorTextureArray: Nullable<WebGLTexture>;
  68981. /** @hidden */
  68982. _depthStencilTextureArray: Nullable<WebGLTexture>;
  68983. /** @hidden */
  68984. _lodTextureHigh: Nullable<BaseTexture>;
  68985. /** @hidden */
  68986. _lodTextureMid: Nullable<BaseTexture>;
  68987. /** @hidden */
  68988. _lodTextureLow: Nullable<BaseTexture>;
  68989. /** @hidden */
  68990. _isRGBD: boolean;
  68991. /** @hidden */
  68992. _linearSpecularLOD: boolean;
  68993. /** @hidden */
  68994. _irradianceTexture: Nullable<BaseTexture>;
  68995. /** @hidden */
  68996. _webGLTexture: Nullable<WebGLTexture>;
  68997. /** @hidden */
  68998. _references: number;
  68999. private _engine;
  69000. /**
  69001. * Gets the Engine the texture belongs to.
  69002. * @returns The babylon engine
  69003. */
  69004. getEngine(): Engine;
  69005. /**
  69006. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69007. */
  69008. readonly dataSource: number;
  69009. /**
  69010. * Creates a new InternalTexture
  69011. * @param engine defines the engine to use
  69012. * @param dataSource defines the type of data that will be used
  69013. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69014. */
  69015. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69016. /**
  69017. * Increments the number of references (ie. the number of Texture that point to it)
  69018. */
  69019. incrementReferences(): void;
  69020. /**
  69021. * Change the size of the texture (not the size of the content)
  69022. * @param width defines the new width
  69023. * @param height defines the new height
  69024. * @param depth defines the new depth (1 by default)
  69025. */
  69026. updateSize(width: int, height: int, depth?: int): void;
  69027. /** @hidden */
  69028. _rebuild(): void;
  69029. /** @hidden */
  69030. _swapAndDie(target: InternalTexture): void;
  69031. /**
  69032. * Dispose the current allocated resources
  69033. */
  69034. dispose(): void;
  69035. }
  69036. }
  69037. declare module BABYLON {
  69038. /**
  69039. * This represents the main contract an easing function should follow.
  69040. * Easing functions are used throughout the animation system.
  69041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69042. */
  69043. export interface IEasingFunction {
  69044. /**
  69045. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69046. * of the easing function.
  69047. * The link below provides some of the most common examples of easing functions.
  69048. * @see https://easings.net/
  69049. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69050. * @returns the corresponding value on the curve defined by the easing function
  69051. */
  69052. ease(gradient: number): number;
  69053. }
  69054. /**
  69055. * Base class used for every default easing function.
  69056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69057. */
  69058. export class EasingFunction implements IEasingFunction {
  69059. /**
  69060. * Interpolation follows the mathematical formula associated with the easing function.
  69061. */
  69062. static readonly EASINGMODE_EASEIN: number;
  69063. /**
  69064. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69065. */
  69066. static readonly EASINGMODE_EASEOUT: number;
  69067. /**
  69068. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69069. */
  69070. static readonly EASINGMODE_EASEINOUT: number;
  69071. private _easingMode;
  69072. /**
  69073. * Sets the easing mode of the current function.
  69074. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69075. */
  69076. setEasingMode(easingMode: number): void;
  69077. /**
  69078. * Gets the current easing mode.
  69079. * @returns the easing mode
  69080. */
  69081. getEasingMode(): number;
  69082. /**
  69083. * @hidden
  69084. */
  69085. easeInCore(gradient: number): number;
  69086. /**
  69087. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69088. * of the easing function.
  69089. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69090. * @returns the corresponding value on the curve defined by the easing function
  69091. */
  69092. ease(gradient: number): number;
  69093. }
  69094. /**
  69095. * Easing function with a circle shape (see link below).
  69096. * @see https://easings.net/#easeInCirc
  69097. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69098. */
  69099. export class CircleEase extends EasingFunction implements IEasingFunction {
  69100. /** @hidden */
  69101. easeInCore(gradient: number): number;
  69102. }
  69103. /**
  69104. * Easing function with a ease back shape (see link below).
  69105. * @see https://easings.net/#easeInBack
  69106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69107. */
  69108. export class BackEase extends EasingFunction implements IEasingFunction {
  69109. /** Defines the amplitude of the function */
  69110. amplitude: number;
  69111. /**
  69112. * Instantiates a back ease easing
  69113. * @see https://easings.net/#easeInBack
  69114. * @param amplitude Defines the amplitude of the function
  69115. */
  69116. constructor(
  69117. /** Defines the amplitude of the function */
  69118. amplitude?: number);
  69119. /** @hidden */
  69120. easeInCore(gradient: number): number;
  69121. }
  69122. /**
  69123. * Easing function with a bouncing shape (see link below).
  69124. * @see https://easings.net/#easeInBounce
  69125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69126. */
  69127. export class BounceEase extends EasingFunction implements IEasingFunction {
  69128. /** Defines the number of bounces */
  69129. bounces: number;
  69130. /** Defines the amplitude of the bounce */
  69131. bounciness: number;
  69132. /**
  69133. * Instantiates a bounce easing
  69134. * @see https://easings.net/#easeInBounce
  69135. * @param bounces Defines the number of bounces
  69136. * @param bounciness Defines the amplitude of the bounce
  69137. */
  69138. constructor(
  69139. /** Defines the number of bounces */
  69140. bounces?: number,
  69141. /** Defines the amplitude of the bounce */
  69142. bounciness?: number);
  69143. /** @hidden */
  69144. easeInCore(gradient: number): number;
  69145. }
  69146. /**
  69147. * Easing function with a power of 3 shape (see link below).
  69148. * @see https://easings.net/#easeInCubic
  69149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69150. */
  69151. export class CubicEase extends EasingFunction implements IEasingFunction {
  69152. /** @hidden */
  69153. easeInCore(gradient: number): number;
  69154. }
  69155. /**
  69156. * Easing function with an elastic shape (see link below).
  69157. * @see https://easings.net/#easeInElastic
  69158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69159. */
  69160. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69161. /** Defines the number of oscillations*/
  69162. oscillations: number;
  69163. /** Defines the amplitude of the oscillations*/
  69164. springiness: number;
  69165. /**
  69166. * Instantiates an elastic easing function
  69167. * @see https://easings.net/#easeInElastic
  69168. * @param oscillations Defines the number of oscillations
  69169. * @param springiness Defines the amplitude of the oscillations
  69170. */
  69171. constructor(
  69172. /** Defines the number of oscillations*/
  69173. oscillations?: number,
  69174. /** Defines the amplitude of the oscillations*/
  69175. springiness?: number);
  69176. /** @hidden */
  69177. easeInCore(gradient: number): number;
  69178. }
  69179. /**
  69180. * Easing function with an exponential shape (see link below).
  69181. * @see https://easings.net/#easeInExpo
  69182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69183. */
  69184. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69185. /** Defines the exponent of the function */
  69186. exponent: number;
  69187. /**
  69188. * Instantiates an exponential easing function
  69189. * @see https://easings.net/#easeInExpo
  69190. * @param exponent Defines the exponent of the function
  69191. */
  69192. constructor(
  69193. /** Defines the exponent of the function */
  69194. exponent?: number);
  69195. /** @hidden */
  69196. easeInCore(gradient: number): number;
  69197. }
  69198. /**
  69199. * Easing function with a power shape (see link below).
  69200. * @see https://easings.net/#easeInQuad
  69201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69202. */
  69203. export class PowerEase extends EasingFunction implements IEasingFunction {
  69204. /** Defines the power of the function */
  69205. power: number;
  69206. /**
  69207. * Instantiates an power base easing function
  69208. * @see https://easings.net/#easeInQuad
  69209. * @param power Defines the power of the function
  69210. */
  69211. constructor(
  69212. /** Defines the power of the function */
  69213. power?: number);
  69214. /** @hidden */
  69215. easeInCore(gradient: number): number;
  69216. }
  69217. /**
  69218. * Easing function with a power of 2 shape (see link below).
  69219. * @see https://easings.net/#easeInQuad
  69220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69221. */
  69222. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69223. /** @hidden */
  69224. easeInCore(gradient: number): number;
  69225. }
  69226. /**
  69227. * Easing function with a power of 4 shape (see link below).
  69228. * @see https://easings.net/#easeInQuart
  69229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69230. */
  69231. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69232. /** @hidden */
  69233. easeInCore(gradient: number): number;
  69234. }
  69235. /**
  69236. * Easing function with a power of 5 shape (see link below).
  69237. * @see https://easings.net/#easeInQuint
  69238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69239. */
  69240. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69241. /** @hidden */
  69242. easeInCore(gradient: number): number;
  69243. }
  69244. /**
  69245. * Easing function with a sin shape (see link below).
  69246. * @see https://easings.net/#easeInSine
  69247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69248. */
  69249. export class SineEase extends EasingFunction implements IEasingFunction {
  69250. /** @hidden */
  69251. easeInCore(gradient: number): number;
  69252. }
  69253. /**
  69254. * Easing function with a bezier shape (see link below).
  69255. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69257. */
  69258. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69259. /** Defines the x component of the start tangent in the bezier curve */
  69260. x1: number;
  69261. /** Defines the y component of the start tangent in the bezier curve */
  69262. y1: number;
  69263. /** Defines the x component of the end tangent in the bezier curve */
  69264. x2: number;
  69265. /** Defines the y component of the end tangent in the bezier curve */
  69266. y2: number;
  69267. /**
  69268. * Instantiates a bezier function
  69269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69270. * @param x1 Defines the x component of the start tangent in the bezier curve
  69271. * @param y1 Defines the y component of the start tangent in the bezier curve
  69272. * @param x2 Defines the x component of the end tangent in the bezier curve
  69273. * @param y2 Defines the y component of the end tangent in the bezier curve
  69274. */
  69275. constructor(
  69276. /** Defines the x component of the start tangent in the bezier curve */
  69277. x1?: number,
  69278. /** Defines the y component of the start tangent in the bezier curve */
  69279. y1?: number,
  69280. /** Defines the x component of the end tangent in the bezier curve */
  69281. x2?: number,
  69282. /** Defines the y component of the end tangent in the bezier curve */
  69283. y2?: number);
  69284. /** @hidden */
  69285. easeInCore(gradient: number): number;
  69286. }
  69287. }
  69288. declare module BABYLON {
  69289. /**
  69290. * Defines an interface which represents an animation key frame
  69291. */
  69292. export interface IAnimationKey {
  69293. /**
  69294. * Frame of the key frame
  69295. */
  69296. frame: number;
  69297. /**
  69298. * Value at the specifies key frame
  69299. */
  69300. value: any;
  69301. /**
  69302. * The input tangent for the cubic hermite spline
  69303. */
  69304. inTangent?: any;
  69305. /**
  69306. * The output tangent for the cubic hermite spline
  69307. */
  69308. outTangent?: any;
  69309. /**
  69310. * The animation interpolation type
  69311. */
  69312. interpolation?: AnimationKeyInterpolation;
  69313. }
  69314. /**
  69315. * Enum for the animation key frame interpolation type
  69316. */
  69317. export enum AnimationKeyInterpolation {
  69318. /**
  69319. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69320. */
  69321. STEP = 1
  69322. }
  69323. }
  69324. declare module BABYLON {
  69325. /**
  69326. * Represents the range of an animation
  69327. */
  69328. export class AnimationRange {
  69329. /**The name of the animation range**/
  69330. name: string;
  69331. /**The starting frame of the animation */
  69332. from: number;
  69333. /**The ending frame of the animation*/
  69334. to: number;
  69335. /**
  69336. * Initializes the range of an animation
  69337. * @param name The name of the animation range
  69338. * @param from The starting frame of the animation
  69339. * @param to The ending frame of the animation
  69340. */
  69341. constructor(
  69342. /**The name of the animation range**/
  69343. name: string,
  69344. /**The starting frame of the animation */
  69345. from: number,
  69346. /**The ending frame of the animation*/
  69347. to: number);
  69348. /**
  69349. * Makes a copy of the animation range
  69350. * @returns A copy of the animation range
  69351. */
  69352. clone(): AnimationRange;
  69353. }
  69354. }
  69355. declare module BABYLON {
  69356. /**
  69357. * Composed of a frame, and an action function
  69358. */
  69359. export class AnimationEvent {
  69360. /** The frame for which the event is triggered **/
  69361. frame: number;
  69362. /** The event to perform when triggered **/
  69363. action: (currentFrame: number) => void;
  69364. /** Specifies if the event should be triggered only once**/
  69365. onlyOnce?: boolean | undefined;
  69366. /**
  69367. * Specifies if the animation event is done
  69368. */
  69369. isDone: boolean;
  69370. /**
  69371. * Initializes the animation event
  69372. * @param frame The frame for which the event is triggered
  69373. * @param action The event to perform when triggered
  69374. * @param onlyOnce Specifies if the event should be triggered only once
  69375. */
  69376. constructor(
  69377. /** The frame for which the event is triggered **/
  69378. frame: number,
  69379. /** The event to perform when triggered **/
  69380. action: (currentFrame: number) => void,
  69381. /** Specifies if the event should be triggered only once**/
  69382. onlyOnce?: boolean | undefined);
  69383. /** @hidden */
  69384. _clone(): AnimationEvent;
  69385. }
  69386. }
  69387. declare module BABYLON {
  69388. /**
  69389. * Interface used to define a behavior
  69390. */
  69391. export interface Behavior<T> {
  69392. /** gets or sets behavior's name */
  69393. name: string;
  69394. /**
  69395. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69396. */
  69397. init(): void;
  69398. /**
  69399. * Called when the behavior is attached to a target
  69400. * @param target defines the target where the behavior is attached to
  69401. */
  69402. attach(target: T): void;
  69403. /**
  69404. * Called when the behavior is detached from its target
  69405. */
  69406. detach(): void;
  69407. }
  69408. /**
  69409. * Interface implemented by classes supporting behaviors
  69410. */
  69411. export interface IBehaviorAware<T> {
  69412. /**
  69413. * Attach a behavior
  69414. * @param behavior defines the behavior to attach
  69415. * @returns the current host
  69416. */
  69417. addBehavior(behavior: Behavior<T>): T;
  69418. /**
  69419. * Remove a behavior from the current object
  69420. * @param behavior defines the behavior to detach
  69421. * @returns the current host
  69422. */
  69423. removeBehavior(behavior: Behavior<T>): T;
  69424. /**
  69425. * Gets a behavior using its name to search
  69426. * @param name defines the name to search
  69427. * @returns the behavior or null if not found
  69428. */
  69429. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69430. }
  69431. }
  69432. declare module BABYLON {
  69433. /**
  69434. * @hidden
  69435. */
  69436. export class IntersectionInfo {
  69437. bu: Nullable<number>;
  69438. bv: Nullable<number>;
  69439. distance: number;
  69440. faceId: number;
  69441. subMeshId: number;
  69442. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69443. }
  69444. }
  69445. declare module BABYLON {
  69446. /**
  69447. * Class used to store bounding sphere information
  69448. */
  69449. export class BoundingSphere {
  69450. /**
  69451. * Gets the center of the bounding sphere in local space
  69452. */
  69453. readonly center: Vector3;
  69454. /**
  69455. * Radius of the bounding sphere in local space
  69456. */
  69457. radius: number;
  69458. /**
  69459. * Gets the center of the bounding sphere in world space
  69460. */
  69461. readonly centerWorld: Vector3;
  69462. /**
  69463. * Radius of the bounding sphere in world space
  69464. */
  69465. radiusWorld: number;
  69466. /**
  69467. * Gets the minimum vector in local space
  69468. */
  69469. readonly minimum: Vector3;
  69470. /**
  69471. * Gets the maximum vector in local space
  69472. */
  69473. readonly maximum: Vector3;
  69474. private _worldMatrix;
  69475. private static readonly TmpVector3;
  69476. /**
  69477. * Creates a new bounding sphere
  69478. * @param min defines the minimum vector (in local space)
  69479. * @param max defines the maximum vector (in local space)
  69480. * @param worldMatrix defines the new world matrix
  69481. */
  69482. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69483. /**
  69484. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69485. * @param min defines the new minimum vector (in local space)
  69486. * @param max defines the new maximum vector (in local space)
  69487. * @param worldMatrix defines the new world matrix
  69488. */
  69489. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69490. /**
  69491. * Scale the current bounding sphere by applying a scale factor
  69492. * @param factor defines the scale factor to apply
  69493. * @returns the current bounding box
  69494. */
  69495. scale(factor: number): BoundingSphere;
  69496. /**
  69497. * Gets the world matrix of the bounding box
  69498. * @returns a matrix
  69499. */
  69500. getWorldMatrix(): DeepImmutable<Matrix>;
  69501. /** @hidden */
  69502. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69503. /**
  69504. * Tests if the bounding sphere is intersecting the frustum planes
  69505. * @param frustumPlanes defines the frustum planes to test
  69506. * @returns true if there is an intersection
  69507. */
  69508. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69509. /**
  69510. * Tests if the bounding sphere center is in between the frustum planes.
  69511. * Used for optimistic fast inclusion.
  69512. * @param frustumPlanes defines the frustum planes to test
  69513. * @returns true if the sphere center is in between the frustum planes
  69514. */
  69515. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69516. /**
  69517. * Tests if a point is inside the bounding sphere
  69518. * @param point defines the point to test
  69519. * @returns true if the point is inside the bounding sphere
  69520. */
  69521. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69522. /**
  69523. * Checks if two sphere intersct
  69524. * @param sphere0 sphere 0
  69525. * @param sphere1 sphere 1
  69526. * @returns true if the speres intersect
  69527. */
  69528. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69529. }
  69530. }
  69531. declare module BABYLON {
  69532. /**
  69533. * Class used to store bounding box information
  69534. */
  69535. export class BoundingBox implements ICullable {
  69536. /**
  69537. * Gets the 8 vectors representing the bounding box in local space
  69538. */
  69539. readonly vectors: Vector3[];
  69540. /**
  69541. * Gets the center of the bounding box in local space
  69542. */
  69543. readonly center: Vector3;
  69544. /**
  69545. * Gets the center of the bounding box in world space
  69546. */
  69547. readonly centerWorld: Vector3;
  69548. /**
  69549. * Gets the extend size in local space
  69550. */
  69551. readonly extendSize: Vector3;
  69552. /**
  69553. * Gets the extend size in world space
  69554. */
  69555. readonly extendSizeWorld: Vector3;
  69556. /**
  69557. * Gets the OBB (object bounding box) directions
  69558. */
  69559. readonly directions: Vector3[];
  69560. /**
  69561. * Gets the 8 vectors representing the bounding box in world space
  69562. */
  69563. readonly vectorsWorld: Vector3[];
  69564. /**
  69565. * Gets the minimum vector in world space
  69566. */
  69567. readonly minimumWorld: Vector3;
  69568. /**
  69569. * Gets the maximum vector in world space
  69570. */
  69571. readonly maximumWorld: Vector3;
  69572. /**
  69573. * Gets the minimum vector in local space
  69574. */
  69575. readonly minimum: Vector3;
  69576. /**
  69577. * Gets the maximum vector in local space
  69578. */
  69579. readonly maximum: Vector3;
  69580. private _worldMatrix;
  69581. private static readonly TmpVector3;
  69582. /**
  69583. * @hidden
  69584. */
  69585. _tag: number;
  69586. /**
  69587. * Creates a new bounding box
  69588. * @param min defines the minimum vector (in local space)
  69589. * @param max defines the maximum vector (in local space)
  69590. * @param worldMatrix defines the new world matrix
  69591. */
  69592. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69593. /**
  69594. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69595. * @param min defines the new minimum vector (in local space)
  69596. * @param max defines the new maximum vector (in local space)
  69597. * @param worldMatrix defines the new world matrix
  69598. */
  69599. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69600. /**
  69601. * Scale the current bounding box by applying a scale factor
  69602. * @param factor defines the scale factor to apply
  69603. * @returns the current bounding box
  69604. */
  69605. scale(factor: number): BoundingBox;
  69606. /**
  69607. * Gets the world matrix of the bounding box
  69608. * @returns a matrix
  69609. */
  69610. getWorldMatrix(): DeepImmutable<Matrix>;
  69611. /** @hidden */
  69612. _update(world: DeepImmutable<Matrix>): void;
  69613. /**
  69614. * Tests if the bounding box is intersecting the frustum planes
  69615. * @param frustumPlanes defines the frustum planes to test
  69616. * @returns true if there is an intersection
  69617. */
  69618. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69619. /**
  69620. * Tests if the bounding box is entirely inside the frustum planes
  69621. * @param frustumPlanes defines the frustum planes to test
  69622. * @returns true if there is an inclusion
  69623. */
  69624. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69625. /**
  69626. * Tests if a point is inside the bounding box
  69627. * @param point defines the point to test
  69628. * @returns true if the point is inside the bounding box
  69629. */
  69630. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69631. /**
  69632. * Tests if the bounding box intersects with a bounding sphere
  69633. * @param sphere defines the sphere to test
  69634. * @returns true if there is an intersection
  69635. */
  69636. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69637. /**
  69638. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69639. * @param min defines the min vector to use
  69640. * @param max defines the max vector to use
  69641. * @returns true if there is an intersection
  69642. */
  69643. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69644. /**
  69645. * Tests if two bounding boxes are intersections
  69646. * @param box0 defines the first box to test
  69647. * @param box1 defines the second box to test
  69648. * @returns true if there is an intersection
  69649. */
  69650. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69651. /**
  69652. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69653. * @param minPoint defines the minimum vector of the bounding box
  69654. * @param maxPoint defines the maximum vector of the bounding box
  69655. * @param sphereCenter defines the sphere center
  69656. * @param sphereRadius defines the sphere radius
  69657. * @returns true if there is an intersection
  69658. */
  69659. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69660. /**
  69661. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69662. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69663. * @param frustumPlanes defines the frustum planes to test
  69664. * @return true if there is an inclusion
  69665. */
  69666. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69667. /**
  69668. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69669. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69670. * @param frustumPlanes defines the frustum planes to test
  69671. * @return true if there is an intersection
  69672. */
  69673. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69674. }
  69675. }
  69676. declare module BABYLON {
  69677. /** @hidden */
  69678. export class Collider {
  69679. /** Define if a collision was found */
  69680. collisionFound: boolean;
  69681. /**
  69682. * Define last intersection point in local space
  69683. */
  69684. intersectionPoint: Vector3;
  69685. /**
  69686. * Define last collided mesh
  69687. */
  69688. collidedMesh: Nullable<AbstractMesh>;
  69689. private _collisionPoint;
  69690. private _planeIntersectionPoint;
  69691. private _tempVector;
  69692. private _tempVector2;
  69693. private _tempVector3;
  69694. private _tempVector4;
  69695. private _edge;
  69696. private _baseToVertex;
  69697. private _destinationPoint;
  69698. private _slidePlaneNormal;
  69699. private _displacementVector;
  69700. /** @hidden */
  69701. _radius: Vector3;
  69702. /** @hidden */
  69703. _retry: number;
  69704. private _velocity;
  69705. private _basePoint;
  69706. private _epsilon;
  69707. /** @hidden */
  69708. _velocityWorldLength: number;
  69709. /** @hidden */
  69710. _basePointWorld: Vector3;
  69711. private _velocityWorld;
  69712. private _normalizedVelocity;
  69713. /** @hidden */
  69714. _initialVelocity: Vector3;
  69715. /** @hidden */
  69716. _initialPosition: Vector3;
  69717. private _nearestDistance;
  69718. private _collisionMask;
  69719. collisionMask: number;
  69720. /**
  69721. * Gets the plane normal used to compute the sliding response (in local space)
  69722. */
  69723. readonly slidePlaneNormal: Vector3;
  69724. /** @hidden */
  69725. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69726. /** @hidden */
  69727. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69728. /** @hidden */
  69729. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69730. /** @hidden */
  69731. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69732. /** @hidden */
  69733. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69734. /** @hidden */
  69735. _getResponse(pos: Vector3, vel: Vector3): void;
  69736. }
  69737. }
  69738. declare module BABYLON {
  69739. /**
  69740. * Interface for cullable objects
  69741. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69742. */
  69743. export interface ICullable {
  69744. /**
  69745. * Checks if the object or part of the object is in the frustum
  69746. * @param frustumPlanes Camera near/planes
  69747. * @returns true if the object is in frustum otherwise false
  69748. */
  69749. isInFrustum(frustumPlanes: Plane[]): boolean;
  69750. /**
  69751. * Checks if a cullable object (mesh...) is in the camera frustum
  69752. * Unlike isInFrustum this cheks the full bounding box
  69753. * @param frustumPlanes Camera near/planes
  69754. * @returns true if the object is in frustum otherwise false
  69755. */
  69756. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69757. }
  69758. /**
  69759. * Info for a bounding data of a mesh
  69760. */
  69761. export class BoundingInfo implements ICullable {
  69762. /**
  69763. * Bounding box for the mesh
  69764. */
  69765. readonly boundingBox: BoundingBox;
  69766. /**
  69767. * Bounding sphere for the mesh
  69768. */
  69769. readonly boundingSphere: BoundingSphere;
  69770. private _isLocked;
  69771. private static readonly TmpVector3;
  69772. /**
  69773. * Constructs bounding info
  69774. * @param minimum min vector of the bounding box/sphere
  69775. * @param maximum max vector of the bounding box/sphere
  69776. * @param worldMatrix defines the new world matrix
  69777. */
  69778. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69779. /**
  69780. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69781. * @param min defines the new minimum vector (in local space)
  69782. * @param max defines the new maximum vector (in local space)
  69783. * @param worldMatrix defines the new world matrix
  69784. */
  69785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69786. /**
  69787. * min vector of the bounding box/sphere
  69788. */
  69789. readonly minimum: Vector3;
  69790. /**
  69791. * max vector of the bounding box/sphere
  69792. */
  69793. readonly maximum: Vector3;
  69794. /**
  69795. * If the info is locked and won't be updated to avoid perf overhead
  69796. */
  69797. isLocked: boolean;
  69798. /**
  69799. * Updates the bounding sphere and box
  69800. * @param world world matrix to be used to update
  69801. */
  69802. update(world: DeepImmutable<Matrix>): void;
  69803. /**
  69804. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69805. * @param center New center of the bounding info
  69806. * @param extend New extend of the bounding info
  69807. * @returns the current bounding info
  69808. */
  69809. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69810. /**
  69811. * Scale the current bounding info by applying a scale factor
  69812. * @param factor defines the scale factor to apply
  69813. * @returns the current bounding info
  69814. */
  69815. scale(factor: number): BoundingInfo;
  69816. /**
  69817. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69818. * @param frustumPlanes defines the frustum to test
  69819. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69820. * @returns true if the bounding info is in the frustum planes
  69821. */
  69822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69823. /**
  69824. * Gets the world distance between the min and max points of the bounding box
  69825. */
  69826. readonly diagonalLength: number;
  69827. /**
  69828. * Checks if a cullable object (mesh...) is in the camera frustum
  69829. * Unlike isInFrustum this cheks the full bounding box
  69830. * @param frustumPlanes Camera near/planes
  69831. * @returns true if the object is in frustum otherwise false
  69832. */
  69833. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69834. /** @hidden */
  69835. _checkCollision(collider: Collider): boolean;
  69836. /**
  69837. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69838. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69839. * @param point the point to check intersection with
  69840. * @returns if the point intersects
  69841. */
  69842. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69843. /**
  69844. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  69845. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69846. * @param boundingInfo the bounding info to check intersection with
  69847. * @param precise if the intersection should be done using OBB
  69848. * @returns if the bounding info intersects
  69849. */
  69850. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  69851. }
  69852. }
  69853. declare module BABYLON {
  69854. /**
  69855. * Defines an array and its length.
  69856. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  69857. */
  69858. export interface ISmartArrayLike<T> {
  69859. /**
  69860. * The data of the array.
  69861. */
  69862. data: Array<T>;
  69863. /**
  69864. * The active length of the array.
  69865. */
  69866. length: number;
  69867. }
  69868. /**
  69869. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69870. */
  69871. export class SmartArray<T> implements ISmartArrayLike<T> {
  69872. /**
  69873. * The full set of data from the array.
  69874. */
  69875. data: Array<T>;
  69876. /**
  69877. * The active length of the array.
  69878. */
  69879. length: number;
  69880. protected _id: number;
  69881. /**
  69882. * Instantiates a Smart Array.
  69883. * @param capacity defines the default capacity of the array.
  69884. */
  69885. constructor(capacity: number);
  69886. /**
  69887. * Pushes a value at the end of the active data.
  69888. * @param value defines the object to push in the array.
  69889. */
  69890. push(value: T): void;
  69891. /**
  69892. * Iterates over the active data and apply the lambda to them.
  69893. * @param func defines the action to apply on each value.
  69894. */
  69895. forEach(func: (content: T) => void): void;
  69896. /**
  69897. * Sorts the full sets of data.
  69898. * @param compareFn defines the comparison function to apply.
  69899. */
  69900. sort(compareFn: (a: T, b: T) => number): void;
  69901. /**
  69902. * Resets the active data to an empty array.
  69903. */
  69904. reset(): void;
  69905. /**
  69906. * Releases all the data from the array as well as the array.
  69907. */
  69908. dispose(): void;
  69909. /**
  69910. * Concats the active data with a given array.
  69911. * @param array defines the data to concatenate with.
  69912. */
  69913. concat(array: any): void;
  69914. /**
  69915. * Returns the position of a value in the active data.
  69916. * @param value defines the value to find the index for
  69917. * @returns the index if found in the active data otherwise -1
  69918. */
  69919. indexOf(value: T): number;
  69920. /**
  69921. * Returns whether an element is part of the active data.
  69922. * @param value defines the value to look for
  69923. * @returns true if found in the active data otherwise false
  69924. */
  69925. contains(value: T): boolean;
  69926. private static _GlobalId;
  69927. }
  69928. /**
  69929. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69930. * The data in this array can only be present once
  69931. */
  69932. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  69933. private _duplicateId;
  69934. /**
  69935. * Pushes a value at the end of the active data.
  69936. * THIS DOES NOT PREVENT DUPPLICATE DATA
  69937. * @param value defines the object to push in the array.
  69938. */
  69939. push(value: T): void;
  69940. /**
  69941. * Pushes a value at the end of the active data.
  69942. * If the data is already present, it won t be added again
  69943. * @param value defines the object to push in the array.
  69944. * @returns true if added false if it was already present
  69945. */
  69946. pushNoDuplicate(value: T): boolean;
  69947. /**
  69948. * Resets the active data to an empty array.
  69949. */
  69950. reset(): void;
  69951. /**
  69952. * Concats the active data with a given array.
  69953. * This ensures no dupplicate will be present in the result.
  69954. * @param array defines the data to concatenate with.
  69955. */
  69956. concatWithNoDuplicate(array: any): void;
  69957. }
  69958. }
  69959. declare module BABYLON {
  69960. /**
  69961. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69962. * separate meshes. This can be use to improve performances.
  69963. * @see http://doc.babylonjs.com/how_to/multi_materials
  69964. */
  69965. export class MultiMaterial extends Material {
  69966. private _subMaterials;
  69967. /**
  69968. * Gets or Sets the list of Materials used within the multi material.
  69969. * They need to be ordered according to the submeshes order in the associated mesh
  69970. */
  69971. subMaterials: Nullable<Material>[];
  69972. /**
  69973. * Function used to align with Node.getChildren()
  69974. * @returns the list of Materials used within the multi material
  69975. */
  69976. getChildren(): Nullable<Material>[];
  69977. /**
  69978. * Instantiates a new Multi Material
  69979. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69980. * separate meshes. This can be use to improve performances.
  69981. * @see http://doc.babylonjs.com/how_to/multi_materials
  69982. * @param name Define the name in the scene
  69983. * @param scene Define the scene the material belongs to
  69984. */
  69985. constructor(name: string, scene: Scene);
  69986. private _hookArray;
  69987. /**
  69988. * Get one of the submaterial by its index in the submaterials array
  69989. * @param index The index to look the sub material at
  69990. * @returns The Material if the index has been defined
  69991. */
  69992. getSubMaterial(index: number): Nullable<Material>;
  69993. /**
  69994. * Get the list of active textures for the whole sub materials list.
  69995. * @returns All the textures that will be used during the rendering
  69996. */
  69997. getActiveTextures(): BaseTexture[];
  69998. /**
  69999. * Gets the current class name of the material e.g. "MultiMaterial"
  70000. * Mainly use in serialization.
  70001. * @returns the class name
  70002. */
  70003. getClassName(): string;
  70004. /**
  70005. * Checks if the material is ready to render the requested sub mesh
  70006. * @param mesh Define the mesh the submesh belongs to
  70007. * @param subMesh Define the sub mesh to look readyness for
  70008. * @param useInstances Define whether or not the material is used with instances
  70009. * @returns true if ready, otherwise false
  70010. */
  70011. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70012. /**
  70013. * Clones the current material and its related sub materials
  70014. * @param name Define the name of the newly cloned material
  70015. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70016. * @returns the cloned material
  70017. */
  70018. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70019. /**
  70020. * Serializes the materials into a JSON representation.
  70021. * @returns the JSON representation
  70022. */
  70023. serialize(): any;
  70024. /**
  70025. * Dispose the material and release its associated resources
  70026. * @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)
  70027. * @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)
  70028. * @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)
  70029. */
  70030. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  70031. /**
  70032. * Creates a MultiMaterial from parsed MultiMaterial data.
  70033. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  70034. * @param scene defines the hosting scene
  70035. * @returns a new MultiMaterial
  70036. */
  70037. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  70038. }
  70039. }
  70040. declare module BABYLON {
  70041. /**
  70042. * Class used to represent data loading progression
  70043. */
  70044. export class SceneLoaderFlags {
  70045. private static _ForceFullSceneLoadingForIncremental;
  70046. private static _ShowLoadingScreen;
  70047. private static _CleanBoneMatrixWeights;
  70048. private static _loggingLevel;
  70049. /**
  70050. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  70051. */
  70052. static ForceFullSceneLoadingForIncremental: boolean;
  70053. /**
  70054. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  70055. */
  70056. static ShowLoadingScreen: boolean;
  70057. /**
  70058. * Defines the current logging level (while loading the scene)
  70059. * @ignorenaming
  70060. */
  70061. static loggingLevel: number;
  70062. /**
  70063. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  70064. */
  70065. static CleanBoneMatrixWeights: boolean;
  70066. }
  70067. }
  70068. declare module BABYLON {
  70069. /**
  70070. * 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.
  70071. * @see https://doc.babylonjs.com/how_to/transformnode
  70072. */
  70073. export class TransformNode extends Node {
  70074. /**
  70075. * Object will not rotate to face the camera
  70076. */
  70077. static BILLBOARDMODE_NONE: number;
  70078. /**
  70079. * Object will rotate to face the camera but only on the x axis
  70080. */
  70081. static BILLBOARDMODE_X: number;
  70082. /**
  70083. * Object will rotate to face the camera but only on the y axis
  70084. */
  70085. static BILLBOARDMODE_Y: number;
  70086. /**
  70087. * Object will rotate to face the camera but only on the z axis
  70088. */
  70089. static BILLBOARDMODE_Z: number;
  70090. /**
  70091. * Object will rotate to face the camera
  70092. */
  70093. static BILLBOARDMODE_ALL: number;
  70094. private _forward;
  70095. private _forwardInverted;
  70096. private _up;
  70097. private _right;
  70098. private _rightInverted;
  70099. private _position;
  70100. private _rotation;
  70101. private _rotationQuaternion;
  70102. protected _scaling: Vector3;
  70103. protected _isDirty: boolean;
  70104. private _transformToBoneReferal;
  70105. private _billboardMode;
  70106. /**
  70107. * Gets or sets the billboard mode. Default is 0.
  70108. *
  70109. * | Value | Type | Description |
  70110. * | --- | --- | --- |
  70111. * | 0 | BILLBOARDMODE_NONE | |
  70112. * | 1 | BILLBOARDMODE_X | |
  70113. * | 2 | BILLBOARDMODE_Y | |
  70114. * | 4 | BILLBOARDMODE_Z | |
  70115. * | 7 | BILLBOARDMODE_ALL | |
  70116. *
  70117. */
  70118. billboardMode: number;
  70119. private _preserveParentRotationForBillboard;
  70120. /**
  70121. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  70122. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  70123. */
  70124. preserveParentRotationForBillboard: boolean;
  70125. /**
  70126. * 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
  70127. */
  70128. scalingDeterminant: number;
  70129. private _infiniteDistance;
  70130. /**
  70131. * Gets or sets the distance of the object to max, often used by skybox
  70132. */
  70133. infiniteDistance: boolean;
  70134. /**
  70135. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  70136. * By default the system will update normals to compensate
  70137. */
  70138. ignoreNonUniformScaling: boolean;
  70139. /**
  70140. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  70141. */
  70142. reIntegrateRotationIntoRotationQuaternion: boolean;
  70143. /** @hidden */
  70144. _poseMatrix: Nullable<Matrix>;
  70145. /** @hidden */
  70146. _localMatrix: Matrix;
  70147. private _usePivotMatrix;
  70148. private _absolutePosition;
  70149. private _pivotMatrix;
  70150. private _pivotMatrixInverse;
  70151. protected _postMultiplyPivotMatrix: boolean;
  70152. protected _isWorldMatrixFrozen: boolean;
  70153. /** @hidden */
  70154. _indexInSceneTransformNodesArray: number;
  70155. /**
  70156. * An event triggered after the world matrix is updated
  70157. */
  70158. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  70159. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  70160. /**
  70161. * Gets a string identifying the name of the class
  70162. * @returns "TransformNode" string
  70163. */
  70164. getClassName(): string;
  70165. /**
  70166. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  70167. */
  70168. position: Vector3;
  70169. /**
  70170. * 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)).
  70171. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  70172. */
  70173. rotation: Vector3;
  70174. /**
  70175. * 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)).
  70176. */
  70177. scaling: Vector3;
  70178. /**
  70179. * 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).
  70180. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  70181. */
  70182. rotationQuaternion: Nullable<Quaternion>;
  70183. /**
  70184. * The forward direction of that transform in world space.
  70185. */
  70186. readonly forward: Vector3;
  70187. /**
  70188. * The up direction of that transform in world space.
  70189. */
  70190. readonly up: Vector3;
  70191. /**
  70192. * The right direction of that transform in world space.
  70193. */
  70194. readonly right: Vector3;
  70195. /**
  70196. * Copies the parameter passed Matrix into the mesh Pose matrix.
  70197. * @param matrix the matrix to copy the pose from
  70198. * @returns this TransformNode.
  70199. */
  70200. updatePoseMatrix(matrix: Matrix): TransformNode;
  70201. /**
  70202. * Returns the mesh Pose matrix.
  70203. * @returns the pose matrix
  70204. */
  70205. getPoseMatrix(): Matrix;
  70206. /** @hidden */
  70207. _isSynchronized(): boolean;
  70208. /** @hidden */
  70209. _initCache(): void;
  70210. /**
  70211. * Flag the transform node as dirty (Forcing it to update everything)
  70212. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  70213. * @returns this transform node
  70214. */
  70215. markAsDirty(property: string): TransformNode;
  70216. /**
  70217. * Returns the current mesh absolute position.
  70218. * Returns a Vector3.
  70219. */
  70220. readonly absolutePosition: Vector3;
  70221. /**
  70222. * Sets a new matrix to apply before all other transformation
  70223. * @param matrix defines the transform matrix
  70224. * @returns the current TransformNode
  70225. */
  70226. setPreTransformMatrix(matrix: Matrix): TransformNode;
  70227. /**
  70228. * Sets a new pivot matrix to the current node
  70229. * @param matrix defines the new pivot matrix to use
  70230. * @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
  70231. * @returns the current TransformNode
  70232. */
  70233. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  70234. /**
  70235. * Returns the mesh pivot matrix.
  70236. * Default : Identity.
  70237. * @returns the matrix
  70238. */
  70239. getPivotMatrix(): Matrix;
  70240. /**
  70241. * Prevents the World matrix to be computed any longer.
  70242. * @returns the TransformNode.
  70243. */
  70244. freezeWorldMatrix(): TransformNode;
  70245. /**
  70246. * Allows back the World matrix computation.
  70247. * @returns the TransformNode.
  70248. */
  70249. unfreezeWorldMatrix(): this;
  70250. /**
  70251. * True if the World matrix has been frozen.
  70252. */
  70253. readonly isWorldMatrixFrozen: boolean;
  70254. /**
  70255. * Retuns the mesh absolute position in the World.
  70256. * @returns a Vector3.
  70257. */
  70258. getAbsolutePosition(): Vector3;
  70259. /**
  70260. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  70261. * @param absolutePosition the absolute position to set
  70262. * @returns the TransformNode.
  70263. */
  70264. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  70265. /**
  70266. * Sets the mesh position in its local space.
  70267. * @param vector3 the position to set in localspace
  70268. * @returns the TransformNode.
  70269. */
  70270. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  70271. /**
  70272. * Returns the mesh position in the local space from the current World matrix values.
  70273. * @returns a new Vector3.
  70274. */
  70275. getPositionExpressedInLocalSpace(): Vector3;
  70276. /**
  70277. * Translates the mesh along the passed Vector3 in its local space.
  70278. * @param vector3 the distance to translate in localspace
  70279. * @returns the TransformNode.
  70280. */
  70281. locallyTranslate(vector3: Vector3): TransformNode;
  70282. private static _lookAtVectorCache;
  70283. /**
  70284. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  70285. * @param targetPoint the position (must be in same space as current mesh) to look at
  70286. * @param yawCor optional yaw (y-axis) correction in radians
  70287. * @param pitchCor optional pitch (x-axis) correction in radians
  70288. * @param rollCor optional roll (z-axis) correction in radians
  70289. * @param space the choosen space of the target
  70290. * @returns the TransformNode.
  70291. */
  70292. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  70293. /**
  70294. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  70295. * This Vector3 is expressed in the World space.
  70296. * @param localAxis axis to rotate
  70297. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  70298. */
  70299. getDirection(localAxis: Vector3): Vector3;
  70300. /**
  70301. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  70302. * localAxis is expressed in the mesh local space.
  70303. * result is computed in the Wordl space from the mesh World matrix.
  70304. * @param localAxis axis to rotate
  70305. * @param result the resulting transformnode
  70306. * @returns this TransformNode.
  70307. */
  70308. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  70309. /**
  70310. * Sets this transform node rotation to the given local axis.
  70311. * @param localAxis the axis in local space
  70312. * @param yawCor optional yaw (y-axis) correction in radians
  70313. * @param pitchCor optional pitch (x-axis) correction in radians
  70314. * @param rollCor optional roll (z-axis) correction in radians
  70315. * @returns this TransformNode
  70316. */
  70317. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  70318. /**
  70319. * Sets a new pivot point to the current node
  70320. * @param point defines the new pivot point to use
  70321. * @param space defines if the point is in world or local space (local by default)
  70322. * @returns the current TransformNode
  70323. */
  70324. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  70325. /**
  70326. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  70327. * @returns the pivot point
  70328. */
  70329. getPivotPoint(): Vector3;
  70330. /**
  70331. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  70332. * @param result the vector3 to store the result
  70333. * @returns this TransformNode.
  70334. */
  70335. getPivotPointToRef(result: Vector3): TransformNode;
  70336. /**
  70337. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  70338. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  70339. */
  70340. getAbsolutePivotPoint(): Vector3;
  70341. /**
  70342. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  70343. * @param result vector3 to store the result
  70344. * @returns this TransformNode.
  70345. */
  70346. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  70347. /**
  70348. * Defines the passed node as the parent of the current node.
  70349. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  70350. * @see https://doc.babylonjs.com/how_to/parenting
  70351. * @param node the node ot set as the parent
  70352. * @returns this TransformNode.
  70353. */
  70354. setParent(node: Nullable<Node>): TransformNode;
  70355. private _nonUniformScaling;
  70356. /**
  70357. * True if the scaling property of this object is non uniform eg. (1,2,1)
  70358. */
  70359. readonly nonUniformScaling: boolean;
  70360. /** @hidden */
  70361. _updateNonUniformScalingState(value: boolean): boolean;
  70362. /**
  70363. * Attach the current TransformNode to another TransformNode associated with a bone
  70364. * @param bone Bone affecting the TransformNode
  70365. * @param affectedTransformNode TransformNode associated with the bone
  70366. * @returns this object
  70367. */
  70368. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  70369. /**
  70370. * Detach the transform node if its associated with a bone
  70371. * @returns this object
  70372. */
  70373. detachFromBone(): TransformNode;
  70374. private static _rotationAxisCache;
  70375. /**
  70376. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  70377. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  70378. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  70379. * The passed axis is also normalized.
  70380. * @param axis the axis to rotate around
  70381. * @param amount the amount to rotate in radians
  70382. * @param space Space to rotate in (Default: local)
  70383. * @returns the TransformNode.
  70384. */
  70385. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  70386. /**
  70387. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  70388. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  70389. * The passed axis is also normalized. .
  70390. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  70391. * @param point the point to rotate around
  70392. * @param axis the axis to rotate around
  70393. * @param amount the amount to rotate in radians
  70394. * @returns the TransformNode
  70395. */
  70396. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  70397. /**
  70398. * Translates the mesh along the axis vector for the passed distance in the given space.
  70399. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  70400. * @param axis the axis to translate in
  70401. * @param distance the distance to translate
  70402. * @param space Space to rotate in (Default: local)
  70403. * @returns the TransformNode.
  70404. */
  70405. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  70406. /**
  70407. * Adds a rotation step to the mesh current rotation.
  70408. * x, y, z are Euler angles expressed in radians.
  70409. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  70410. * This means this rotation is made in the mesh local space only.
  70411. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  70412. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  70413. * ```javascript
  70414. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  70415. * ```
  70416. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  70417. * 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.
  70418. * @param x Rotation to add
  70419. * @param y Rotation to add
  70420. * @param z Rotation to add
  70421. * @returns the TransformNode.
  70422. */
  70423. addRotation(x: number, y: number, z: number): TransformNode;
  70424. /**
  70425. * @hidden
  70426. */
  70427. protected _getEffectiveParent(): Nullable<Node>;
  70428. /**
  70429. * Computes the world matrix of the node
  70430. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  70431. * @returns the world matrix
  70432. */
  70433. computeWorldMatrix(force?: boolean): Matrix;
  70434. protected _afterComputeWorldMatrix(): void;
  70435. /**
  70436. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  70437. * @param func callback function to add
  70438. *
  70439. * @returns the TransformNode.
  70440. */
  70441. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70442. /**
  70443. * Removes a registered callback function.
  70444. * @param func callback function to remove
  70445. * @returns the TransformNode.
  70446. */
  70447. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70448. /**
  70449. * Gets the position of the current mesh in camera space
  70450. * @param camera defines the camera to use
  70451. * @returns a position
  70452. */
  70453. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  70454. /**
  70455. * Returns the distance from the mesh to the active camera
  70456. * @param camera defines the camera to use
  70457. * @returns the distance
  70458. */
  70459. getDistanceToCamera(camera?: Nullable<Camera>): number;
  70460. /**
  70461. * Clone the current transform node
  70462. * @param name Name of the new clone
  70463. * @param newParent New parent for the clone
  70464. * @param doNotCloneChildren Do not clone children hierarchy
  70465. * @returns the new transform node
  70466. */
  70467. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  70468. /**
  70469. * Serializes the objects information.
  70470. * @param currentSerializationObject defines the object to serialize in
  70471. * @returns the serialized object
  70472. */
  70473. serialize(currentSerializationObject?: any): any;
  70474. /**
  70475. * Returns a new TransformNode object parsed from the source provided.
  70476. * @param parsedTransformNode is the source.
  70477. * @param scene the scne the object belongs to
  70478. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  70479. * @returns a new TransformNode object parsed from the source provided.
  70480. */
  70481. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  70482. /**
  70483. * Get all child-transformNodes of this node
  70484. * @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
  70485. * @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
  70486. * @returns an array of TransformNode
  70487. */
  70488. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  70489. /**
  70490. * Releases resources associated with this transform node.
  70491. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70492. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70493. */
  70494. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70495. }
  70496. }
  70497. declare module BABYLON {
  70498. /**
  70499. * Class used to override all child animations of a given target
  70500. */
  70501. export class AnimationPropertiesOverride {
  70502. /**
  70503. * Gets or sets a value indicating if animation blending must be used
  70504. */
  70505. enableBlending: boolean;
  70506. /**
  70507. * Gets or sets the blending speed to use when enableBlending is true
  70508. */
  70509. blendingSpeed: number;
  70510. /**
  70511. * Gets or sets the default loop mode to use
  70512. */
  70513. loopMode: number;
  70514. }
  70515. }
  70516. declare module BABYLON {
  70517. /**
  70518. * Class used to store bone information
  70519. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  70520. */
  70521. export class Bone extends Node {
  70522. /**
  70523. * defines the bone name
  70524. */
  70525. name: string;
  70526. private static _tmpVecs;
  70527. private static _tmpQuat;
  70528. private static _tmpMats;
  70529. /**
  70530. * Gets the list of child bones
  70531. */
  70532. children: Bone[];
  70533. /** Gets the animations associated with this bone */
  70534. animations: Animation[];
  70535. /**
  70536. * Gets or sets bone length
  70537. */
  70538. length: number;
  70539. /**
  70540. * @hidden Internal only
  70541. * Set this value to map this bone to a different index in the transform matrices
  70542. * Set this value to -1 to exclude the bone from the transform matrices
  70543. */
  70544. _index: Nullable<number>;
  70545. private _skeleton;
  70546. private _localMatrix;
  70547. private _restPose;
  70548. private _baseMatrix;
  70549. private _absoluteTransform;
  70550. private _invertedAbsoluteTransform;
  70551. private _parent;
  70552. private _scalingDeterminant;
  70553. private _worldTransform;
  70554. private _localScaling;
  70555. private _localRotation;
  70556. private _localPosition;
  70557. private _needToDecompose;
  70558. private _needToCompose;
  70559. /** @hidden */
  70560. _linkedTransformNode: Nullable<TransformNode>;
  70561. /** @hidden */
  70562. _waitingTransformNodeId: Nullable<string>;
  70563. /** @hidden */
  70564. /** @hidden */
  70565. _matrix: Matrix;
  70566. /**
  70567. * Create a new bone
  70568. * @param name defines the bone name
  70569. * @param skeleton defines the parent skeleton
  70570. * @param parentBone defines the parent (can be null if the bone is the root)
  70571. * @param localMatrix defines the local matrix
  70572. * @param restPose defines the rest pose matrix
  70573. * @param baseMatrix defines the base matrix
  70574. * @param index defines index of the bone in the hiearchy
  70575. */
  70576. constructor(
  70577. /**
  70578. * defines the bone name
  70579. */
  70580. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  70581. /**
  70582. * Gets the current object class name.
  70583. * @return the class name
  70584. */
  70585. getClassName(): string;
  70586. /**
  70587. * Gets the parent skeleton
  70588. * @returns a skeleton
  70589. */
  70590. getSkeleton(): Skeleton;
  70591. /**
  70592. * Gets parent bone
  70593. * @returns a bone or null if the bone is the root of the bone hierarchy
  70594. */
  70595. getParent(): Nullable<Bone>;
  70596. /**
  70597. * Returns an array containing the root bones
  70598. * @returns an array containing the root bones
  70599. */
  70600. getChildren(): Array<Bone>;
  70601. /**
  70602. * Sets the parent bone
  70603. * @param parent defines the parent (can be null if the bone is the root)
  70604. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70605. */
  70606. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  70607. /**
  70608. * Gets the local matrix
  70609. * @returns a matrix
  70610. */
  70611. getLocalMatrix(): Matrix;
  70612. /**
  70613. * Gets the base matrix (initial matrix which remains unchanged)
  70614. * @returns a matrix
  70615. */
  70616. getBaseMatrix(): Matrix;
  70617. /**
  70618. * Gets the rest pose matrix
  70619. * @returns a matrix
  70620. */
  70621. getRestPose(): Matrix;
  70622. /**
  70623. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  70624. */
  70625. getWorldMatrix(): Matrix;
  70626. /**
  70627. * Sets the local matrix to rest pose matrix
  70628. */
  70629. returnToRest(): void;
  70630. /**
  70631. * Gets the inverse of the absolute transform matrix.
  70632. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  70633. * @returns a matrix
  70634. */
  70635. getInvertedAbsoluteTransform(): Matrix;
  70636. /**
  70637. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  70638. * @returns a matrix
  70639. */
  70640. getAbsoluteTransform(): Matrix;
  70641. /**
  70642. * Links with the given transform node.
  70643. * The local matrix of this bone is copied from the transform node every frame.
  70644. * @param transformNode defines the transform node to link to
  70645. */
  70646. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  70647. /** Gets or sets current position (in local space) */
  70648. position: Vector3;
  70649. /** Gets or sets current rotation (in local space) */
  70650. rotation: Vector3;
  70651. /** Gets or sets current rotation quaternion (in local space) */
  70652. rotationQuaternion: Quaternion;
  70653. /** Gets or sets current scaling (in local space) */
  70654. scaling: Vector3;
  70655. /**
  70656. * Gets the animation properties override
  70657. */
  70658. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  70659. private _decompose;
  70660. private _compose;
  70661. /**
  70662. * Update the base and local matrices
  70663. * @param matrix defines the new base or local matrix
  70664. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70665. * @param updateLocalMatrix defines if the local matrix should be updated
  70666. */
  70667. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  70668. /** @hidden */
  70669. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  70670. /**
  70671. * Flag the bone as dirty (Forcing it to update everything)
  70672. */
  70673. markAsDirty(): void;
  70674. /** @hidden */
  70675. _markAsDirtyAndCompose(): void;
  70676. private _markAsDirtyAndDecompose;
  70677. /**
  70678. * Translate the bone in local or world space
  70679. * @param vec The amount to translate the bone
  70680. * @param space The space that the translation is in
  70681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70682. */
  70683. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70684. /**
  70685. * Set the postion of the bone in local or world space
  70686. * @param position The position to set the bone
  70687. * @param space The space that the position is in
  70688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70689. */
  70690. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70691. /**
  70692. * Set the absolute position of the bone (world space)
  70693. * @param position The position to set the bone
  70694. * @param mesh The mesh that this bone is attached to
  70695. */
  70696. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  70697. /**
  70698. * Scale the bone on the x, y and z axes (in local space)
  70699. * @param x The amount to scale the bone on the x axis
  70700. * @param y The amount to scale the bone on the y axis
  70701. * @param z The amount to scale the bone on the z axis
  70702. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  70703. */
  70704. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  70705. /**
  70706. * Set the bone scaling in local space
  70707. * @param scale defines the scaling vector
  70708. */
  70709. setScale(scale: Vector3): void;
  70710. /**
  70711. * Gets the current scaling in local space
  70712. * @returns the current scaling vector
  70713. */
  70714. getScale(): Vector3;
  70715. /**
  70716. * Gets the current scaling in local space and stores it in a target vector
  70717. * @param result defines the target vector
  70718. */
  70719. getScaleToRef(result: Vector3): void;
  70720. /**
  70721. * Set the yaw, pitch, and roll of the bone in local or world space
  70722. * @param yaw The rotation of the bone on the y axis
  70723. * @param pitch The rotation of the bone on the x axis
  70724. * @param roll The rotation of the bone on the z axis
  70725. * @param space The space that the axes of rotation are in
  70726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70727. */
  70728. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  70729. /**
  70730. * Add a rotation to the bone on an axis in local or world space
  70731. * @param axis The axis to rotate the bone on
  70732. * @param amount The amount to rotate the bone
  70733. * @param space The space that the axis is in
  70734. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70735. */
  70736. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  70737. /**
  70738. * Set the rotation of the bone to a particular axis angle in local or world space
  70739. * @param axis The axis to rotate the bone on
  70740. * @param angle The angle that the bone should be rotated to
  70741. * @param space The space that the axis is in
  70742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70743. */
  70744. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  70745. /**
  70746. * Set the euler rotation of the bone in local of world space
  70747. * @param rotation The euler rotation that the bone should be set to
  70748. * @param space The space that the rotation is in
  70749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70750. */
  70751. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70752. /**
  70753. * Set the quaternion rotation of the bone in local of world space
  70754. * @param quat The quaternion rotation that the bone should be set to
  70755. * @param space The space that the rotation is in
  70756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70757. */
  70758. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  70759. /**
  70760. * Set the rotation matrix of the bone in local of world space
  70761. * @param rotMat The rotation matrix that the bone should be set to
  70762. * @param space The space that the rotation is in
  70763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70764. */
  70765. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  70766. private _rotateWithMatrix;
  70767. private _getNegativeRotationToRef;
  70768. /**
  70769. * Get the position of the bone in local or world space
  70770. * @param space The space that the returned position is in
  70771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70772. * @returns The position of the bone
  70773. */
  70774. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70775. /**
  70776. * Copy the position of the bone to a vector3 in local or world space
  70777. * @param space The space that the returned position is in
  70778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70779. * @param result The vector3 to copy the position to
  70780. */
  70781. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  70782. /**
  70783. * Get the absolute position of the bone (world space)
  70784. * @param mesh The mesh that this bone is attached to
  70785. * @returns The absolute position of the bone
  70786. */
  70787. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  70788. /**
  70789. * Copy the absolute position of the bone (world space) to the result param
  70790. * @param mesh The mesh that this bone is attached to
  70791. * @param result The vector3 to copy the absolute position to
  70792. */
  70793. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  70794. /**
  70795. * Compute the absolute transforms of this bone and its children
  70796. */
  70797. computeAbsoluteTransforms(): void;
  70798. /**
  70799. * Get the world direction from an axis that is in the local space of the bone
  70800. * @param localAxis The local direction that is used to compute the world direction
  70801. * @param mesh The mesh that this bone is attached to
  70802. * @returns The world direction
  70803. */
  70804. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70805. /**
  70806. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  70807. * @param localAxis The local direction that is used to compute the world direction
  70808. * @param mesh The mesh that this bone is attached to
  70809. * @param result The vector3 that the world direction will be copied to
  70810. */
  70811. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70812. /**
  70813. * Get the euler rotation of the bone in local or world space
  70814. * @param space The space that the rotation should be in
  70815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70816. * @returns The euler rotation
  70817. */
  70818. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70819. /**
  70820. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  70821. * @param space The space that the rotation should be in
  70822. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70823. * @param result The vector3 that the rotation should be copied to
  70824. */
  70825. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70826. /**
  70827. * Get the quaternion rotation of the bone in either local or world space
  70828. * @param space The space that the rotation should be in
  70829. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70830. * @returns The quaternion rotation
  70831. */
  70832. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  70833. /**
  70834. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  70835. * @param space The space that the rotation should be in
  70836. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70837. * @param result The quaternion that the rotation should be copied to
  70838. */
  70839. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  70840. /**
  70841. * Get the rotation matrix of the bone in local or world space
  70842. * @param space The space that the rotation should be in
  70843. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70844. * @returns The rotation matrix
  70845. */
  70846. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  70847. /**
  70848. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  70849. * @param space The space that the rotation should be in
  70850. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70851. * @param result The quaternion that the rotation should be copied to
  70852. */
  70853. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  70854. /**
  70855. * Get the world position of a point that is in the local space of the bone
  70856. * @param position The local position
  70857. * @param mesh The mesh that this bone is attached to
  70858. * @returns The world position
  70859. */
  70860. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70861. /**
  70862. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  70863. * @param position The local position
  70864. * @param mesh The mesh that this bone is attached to
  70865. * @param result The vector3 that the world position should be copied to
  70866. */
  70867. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70868. /**
  70869. * Get the local position of a point that is in world space
  70870. * @param position The world position
  70871. * @param mesh The mesh that this bone is attached to
  70872. * @returns The local position
  70873. */
  70874. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70875. /**
  70876. * Get the local position of a point that is in world space and copy it to the result param
  70877. * @param position The world position
  70878. * @param mesh The mesh that this bone is attached to
  70879. * @param result The vector3 that the local position should be copied to
  70880. */
  70881. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70882. }
  70883. }
  70884. declare module BABYLON {
  70885. /**
  70886. * Enum that determines the text-wrapping mode to use.
  70887. */
  70888. export enum InspectableType {
  70889. /**
  70890. * Checkbox for booleans
  70891. */
  70892. Checkbox = 0,
  70893. /**
  70894. * Sliders for numbers
  70895. */
  70896. Slider = 1,
  70897. /**
  70898. * Vector3
  70899. */
  70900. Vector3 = 2,
  70901. /**
  70902. * Quaternions
  70903. */
  70904. Quaternion = 3,
  70905. /**
  70906. * Color3
  70907. */
  70908. Color3 = 4
  70909. }
  70910. /**
  70911. * Interface used to define custom inspectable properties.
  70912. * This interface is used by the inspector to display custom property grids
  70913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70914. */
  70915. export interface IInspectable {
  70916. /**
  70917. * Gets the label to display
  70918. */
  70919. label: string;
  70920. /**
  70921. * Gets the name of the property to edit
  70922. */
  70923. propertyName: string;
  70924. /**
  70925. * Gets the type of the editor to use
  70926. */
  70927. type: InspectableType;
  70928. /**
  70929. * Gets the minimum value of the property when using in "slider" mode
  70930. */
  70931. min?: number;
  70932. /**
  70933. * Gets the maximum value of the property when using in "slider" mode
  70934. */
  70935. max?: number;
  70936. /**
  70937. * Gets the setp to use when using in "slider" mode
  70938. */
  70939. step?: number;
  70940. }
  70941. }
  70942. declare module BABYLON {
  70943. /**
  70944. * This represents the required contract to create a new type of texture loader.
  70945. */
  70946. export interface IInternalTextureLoader {
  70947. /**
  70948. * Defines wether the loader supports cascade loading the different faces.
  70949. */
  70950. supportCascades: boolean;
  70951. /**
  70952. * This returns if the loader support the current file information.
  70953. * @param extension defines the file extension of the file being loaded
  70954. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70955. * @param fallback defines the fallback internal texture if any
  70956. * @param isBase64 defines whether the texture is encoded as a base64
  70957. * @param isBuffer defines whether the texture data are stored as a buffer
  70958. * @returns true if the loader can load the specified file
  70959. */
  70960. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70961. /**
  70962. * Transform the url before loading if required.
  70963. * @param rootUrl the url of the texture
  70964. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70965. * @returns the transformed texture
  70966. */
  70967. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70968. /**
  70969. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70970. * @param rootUrl the url of the texture
  70971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70972. * @returns the fallback texture
  70973. */
  70974. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70975. /**
  70976. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70977. * @param data contains the texture data
  70978. * @param texture defines the BabylonJS internal texture
  70979. * @param createPolynomials will be true if polynomials have been requested
  70980. * @param onLoad defines the callback to trigger once the texture is ready
  70981. * @param onError defines the callback to trigger in case of error
  70982. */
  70983. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70984. /**
  70985. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70986. * @param data contains the texture data
  70987. * @param texture defines the BabylonJS internal texture
  70988. * @param callback defines the method to call once ready to upload
  70989. */
  70990. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70991. }
  70992. }
  70993. declare module BABYLON {
  70994. interface Engine {
  70995. /**
  70996. * Creates a depth stencil cube texture.
  70997. * This is only available in WebGL 2.
  70998. * @param size The size of face edge in the cube texture.
  70999. * @param options The options defining the cube texture.
  71000. * @returns The cube texture
  71001. */
  71002. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71003. /**
  71004. * Creates a cube texture
  71005. * @param rootUrl defines the url where the files to load is located
  71006. * @param scene defines the current scene
  71007. * @param files defines the list of files to load (1 per face)
  71008. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71009. * @param onLoad defines an optional callback raised when the texture is loaded
  71010. * @param onError defines an optional callback raised if there is an issue to load the texture
  71011. * @param format defines the format of the data
  71012. * @param forcedExtension defines the extension to use to pick the right loader
  71013. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71014. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71015. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71016. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71017. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71018. * @returns the cube texture as an InternalTexture
  71019. */
  71020. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  71021. /**
  71022. * Creates a cube texture
  71023. * @param rootUrl defines the url where the files to load is located
  71024. * @param scene defines the current scene
  71025. * @param files defines the list of files to load (1 per face)
  71026. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71027. * @param onLoad defines an optional callback raised when the texture is loaded
  71028. * @param onError defines an optional callback raised if there is an issue to load the texture
  71029. * @param format defines the format of the data
  71030. * @param forcedExtension defines the extension to use to pick the right loader
  71031. * @returns the cube texture as an InternalTexture
  71032. */
  71033. 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 | undefined, forcedExtension: any): InternalTexture;
  71034. /**
  71035. * Creates a cube texture
  71036. * @param rootUrl defines the url where the files to load is located
  71037. * @param scene defines the current scene
  71038. * @param files defines the list of files to load (1 per face)
  71039. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71040. * @param onLoad defines an optional callback raised when the texture is loaded
  71041. * @param onError defines an optional callback raised if there is an issue to load the texture
  71042. * @param format defines the format of the data
  71043. * @param forcedExtension defines the extension to use to pick the right loader
  71044. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71045. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71046. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71047. * @returns the cube texture as an InternalTexture
  71048. */
  71049. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  71050. /** @hidden */
  71051. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71052. /** @hidden */
  71053. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71054. /** @hidden */
  71055. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71056. /** @hidden */
  71057. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71058. }
  71059. }
  71060. declare module BABYLON {
  71061. /**
  71062. * Class for creating a cube texture
  71063. */
  71064. export class CubeTexture extends BaseTexture {
  71065. private _delayedOnLoad;
  71066. /**
  71067. * The url of the texture
  71068. */
  71069. url: string;
  71070. /**
  71071. * Gets or sets the center of the bounding box associated with the cube texture.
  71072. * It must define where the camera used to render the texture was set
  71073. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71074. */
  71075. boundingBoxPosition: Vector3;
  71076. private _boundingBoxSize;
  71077. /**
  71078. * Gets or sets the size of the bounding box associated with the cube texture
  71079. * When defined, the cubemap will switch to local mode
  71080. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71081. * @example https://www.babylonjs-playground.com/#RNASML
  71082. */
  71083. /**
  71084. * Returns the bounding box size
  71085. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71086. */
  71087. boundingBoxSize: Vector3;
  71088. protected _rotationY: number;
  71089. /**
  71090. * Sets texture matrix rotation angle around Y axis in radians.
  71091. */
  71092. /**
  71093. * Gets texture matrix rotation angle around Y axis radians.
  71094. */
  71095. rotationY: number;
  71096. /**
  71097. * Are mip maps generated for this texture or not.
  71098. */
  71099. readonly noMipmap: boolean;
  71100. private _noMipmap;
  71101. private _files;
  71102. private _extensions;
  71103. private _textureMatrix;
  71104. private _format;
  71105. private _createPolynomials;
  71106. /** @hidden */
  71107. _prefiltered: boolean;
  71108. /**
  71109. * Creates a cube texture from an array of image urls
  71110. * @param files defines an array of image urls
  71111. * @param scene defines the hosting scene
  71112. * @param noMipmap specifies if mip maps are not used
  71113. * @returns a cube texture
  71114. */
  71115. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71116. /**
  71117. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71118. * @param url defines the url of the prefiltered texture
  71119. * @param scene defines the scene the texture is attached to
  71120. * @param forcedExtension defines the extension of the file if different from the url
  71121. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71122. * @return the prefiltered texture
  71123. */
  71124. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71125. /**
  71126. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71127. * as prefiltered data.
  71128. * @param rootUrl defines the url of the texture or the root name of the six images
  71129. * @param scene defines the scene the texture is attached to
  71130. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71131. * @param noMipmap defines if mipmaps should be created or not
  71132. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71133. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71134. * @param onError defines a callback triggered in case of error during load
  71135. * @param format defines the internal format to use for the texture once loaded
  71136. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71137. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71138. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71141. * @return the cube texture
  71142. */
  71143. 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);
  71144. /**
  71145. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71146. */
  71147. readonly isPrefiltered: boolean;
  71148. /**
  71149. * Get the current class name of the texture useful for serialization or dynamic coding.
  71150. * @returns "CubeTexture"
  71151. */
  71152. getClassName(): string;
  71153. /**
  71154. * Update the url (and optional buffer) of this texture if url was null during construction.
  71155. * @param url the url of the texture
  71156. * @param forcedExtension defines the extension to use
  71157. * @param onLoad callback called when the texture is loaded (defaults to null)
  71158. */
  71159. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71160. /**
  71161. * Delays loading of the cube texture
  71162. * @param forcedExtension defines the extension to use
  71163. */
  71164. delayLoad(forcedExtension?: string): void;
  71165. /**
  71166. * Returns the reflection texture matrix
  71167. * @returns the reflection texture matrix
  71168. */
  71169. getReflectionTextureMatrix(): Matrix;
  71170. /**
  71171. * Sets the reflection texture matrix
  71172. * @param value Reflection texture matrix
  71173. */
  71174. setReflectionTextureMatrix(value: Matrix): void;
  71175. /**
  71176. * Parses text to create a cube texture
  71177. * @param parsedTexture define the serialized text to read from
  71178. * @param scene defines the hosting scene
  71179. * @param rootUrl defines the root url of the cube texture
  71180. * @returns a cube texture
  71181. */
  71182. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71183. /**
  71184. * Makes a clone, or deep copy, of the cube texture
  71185. * @returns a new cube texture
  71186. */
  71187. clone(): CubeTexture;
  71188. }
  71189. }
  71190. declare module BABYLON {
  71191. /** @hidden */
  71192. export var postprocessVertexShader: {
  71193. name: string;
  71194. shader: string;
  71195. };
  71196. }
  71197. declare module BABYLON {
  71198. /**
  71199. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  71200. * This is the base of the follow, arc rotate cameras and Free camera
  71201. * @see http://doc.babylonjs.com/features/cameras
  71202. */
  71203. export class TargetCamera extends Camera {
  71204. private static _RigCamTransformMatrix;
  71205. private static _TargetTransformMatrix;
  71206. private static _TargetFocalPoint;
  71207. /**
  71208. * Define the current direction the camera is moving to
  71209. */
  71210. cameraDirection: Vector3;
  71211. /**
  71212. * Define the current rotation the camera is rotating to
  71213. */
  71214. cameraRotation: Vector2;
  71215. /**
  71216. * When set, the up vector of the camera will be updated by the rotation of the camera
  71217. */
  71218. updateUpVectorFromRotation: boolean;
  71219. private _tmpQuaternion;
  71220. /**
  71221. * Define the current rotation of the camera
  71222. */
  71223. rotation: Vector3;
  71224. /**
  71225. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  71226. */
  71227. rotationQuaternion: Quaternion;
  71228. /**
  71229. * Define the current speed of the camera
  71230. */
  71231. speed: number;
  71232. /**
  71233. * Add cconstraint to the camera to prevent it to move freely in all directions and
  71234. * around all axis.
  71235. */
  71236. noRotationConstraint: boolean;
  71237. /**
  71238. * Define the current target of the camera as an object or a position.
  71239. */
  71240. lockedTarget: any;
  71241. /** @hidden */
  71242. _currentTarget: Vector3;
  71243. /** @hidden */
  71244. _initialFocalDistance: number;
  71245. /** @hidden */
  71246. _viewMatrix: Matrix;
  71247. /** @hidden */
  71248. _camMatrix: Matrix;
  71249. /** @hidden */
  71250. _cameraTransformMatrix: Matrix;
  71251. /** @hidden */
  71252. _cameraRotationMatrix: Matrix;
  71253. /** @hidden */
  71254. _referencePoint: Vector3;
  71255. /** @hidden */
  71256. _transformedReferencePoint: Vector3;
  71257. protected _globalCurrentTarget: Vector3;
  71258. protected _globalCurrentUpVector: Vector3;
  71259. /** @hidden */
  71260. _reset: () => void;
  71261. private _defaultUp;
  71262. /**
  71263. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  71264. * This is the base of the follow, arc rotate cameras and Free camera
  71265. * @see http://doc.babylonjs.com/features/cameras
  71266. * @param name Defines the name of the camera in the scene
  71267. * @param position Defines the start position of the camera in the scene
  71268. * @param scene Defines the scene the camera belongs to
  71269. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71270. */
  71271. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71272. /**
  71273. * Gets the position in front of the camera at a given distance.
  71274. * @param distance The distance from the camera we want the position to be
  71275. * @returns the position
  71276. */
  71277. getFrontPosition(distance: number): Vector3;
  71278. /** @hidden */
  71279. _getLockedTargetPosition(): Nullable<Vector3>;
  71280. private _storedPosition;
  71281. private _storedRotation;
  71282. private _storedRotationQuaternion;
  71283. /**
  71284. * Store current camera state of the camera (fov, position, rotation, etc..)
  71285. * @returns the camera
  71286. */
  71287. storeState(): Camera;
  71288. /**
  71289. * Restored camera state. You must call storeState() first
  71290. * @returns whether it was successful or not
  71291. * @hidden
  71292. */
  71293. _restoreStateValues(): boolean;
  71294. /** @hidden */
  71295. _initCache(): void;
  71296. /** @hidden */
  71297. _updateCache(ignoreParentClass?: boolean): void;
  71298. /** @hidden */
  71299. _isSynchronizedViewMatrix(): boolean;
  71300. /** @hidden */
  71301. _computeLocalCameraSpeed(): number;
  71302. /**
  71303. * Defines the target the camera should look at.
  71304. * This will automatically adapt alpha beta and radius to fit within the new target.
  71305. * @param target Defines the new target as a Vector or a mesh
  71306. */
  71307. setTarget(target: Vector3): void;
  71308. /**
  71309. * Return the current target position of the camera. This value is expressed in local space.
  71310. * @returns the target position
  71311. */
  71312. getTarget(): Vector3;
  71313. /** @hidden */
  71314. _decideIfNeedsToMove(): boolean;
  71315. /** @hidden */
  71316. _updatePosition(): void;
  71317. /** @hidden */
  71318. _checkInputs(): void;
  71319. protected _updateCameraRotationMatrix(): void;
  71320. /**
  71321. * 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)
  71322. * @returns the current camera
  71323. */
  71324. private _rotateUpVectorWithCameraRotationMatrix;
  71325. private _cachedRotationZ;
  71326. private _cachedQuaternionRotationZ;
  71327. /** @hidden */
  71328. _getViewMatrix(): Matrix;
  71329. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  71330. /**
  71331. * @hidden
  71332. */
  71333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  71334. /**
  71335. * @hidden
  71336. */
  71337. _updateRigCameras(): void;
  71338. private _getRigCamPositionAndTarget;
  71339. /**
  71340. * Gets the current object class name.
  71341. * @return the class name
  71342. */
  71343. getClassName(): string;
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /**
  71348. * @ignore
  71349. * This is a list of all the different input types that are available in the application.
  71350. * Fo instance: ArcRotateCameraGamepadInput...
  71351. */
  71352. export var CameraInputTypes: {};
  71353. /**
  71354. * This is the contract to implement in order to create a new input class.
  71355. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  71356. */
  71357. export interface ICameraInput<TCamera extends Camera> {
  71358. /**
  71359. * Defines the camera the input is attached to.
  71360. */
  71361. camera: Nullable<TCamera>;
  71362. /**
  71363. * Gets the class name of the current intput.
  71364. * @returns the class name
  71365. */
  71366. getClassName(): string;
  71367. /**
  71368. * Get the friendly name associated with the input class.
  71369. * @returns the input friendly name
  71370. */
  71371. getSimpleName(): string;
  71372. /**
  71373. * Attach the input controls to a specific dom element to get the input from.
  71374. * @param element Defines the element the controls should be listened from
  71375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71376. */
  71377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71378. /**
  71379. * Detach the current controls from the specified dom element.
  71380. * @param element Defines the element to stop listening the inputs from
  71381. */
  71382. detachControl(element: Nullable<HTMLElement>): void;
  71383. /**
  71384. * Update the current camera state depending on the inputs that have been used this frame.
  71385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71386. */
  71387. checkInputs?: () => void;
  71388. }
  71389. /**
  71390. * Represents a map of input types to input instance or input index to input instance.
  71391. */
  71392. export interface CameraInputsMap<TCamera extends Camera> {
  71393. /**
  71394. * Accessor to the input by input type.
  71395. */
  71396. [name: string]: ICameraInput<TCamera>;
  71397. /**
  71398. * Accessor to the input by input index.
  71399. */
  71400. [idx: number]: ICameraInput<TCamera>;
  71401. }
  71402. /**
  71403. * This represents the input manager used within a camera.
  71404. * It helps dealing with all the different kind of input attached to a camera.
  71405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71406. */
  71407. export class CameraInputsManager<TCamera extends Camera> {
  71408. /**
  71409. * Defines the list of inputs attahed to the camera.
  71410. */
  71411. attached: CameraInputsMap<TCamera>;
  71412. /**
  71413. * Defines the dom element the camera is collecting inputs from.
  71414. * This is null if the controls have not been attached.
  71415. */
  71416. attachedElement: Nullable<HTMLElement>;
  71417. /**
  71418. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71419. */
  71420. noPreventDefault: boolean;
  71421. /**
  71422. * Defined the camera the input manager belongs to.
  71423. */
  71424. camera: TCamera;
  71425. /**
  71426. * Update the current camera state depending on the inputs that have been used this frame.
  71427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71428. */
  71429. checkInputs: () => void;
  71430. /**
  71431. * Instantiate a new Camera Input Manager.
  71432. * @param camera Defines the camera the input manager blongs to
  71433. */
  71434. constructor(camera: TCamera);
  71435. /**
  71436. * Add an input method to a camera
  71437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71438. * @param input camera input method
  71439. */
  71440. add(input: ICameraInput<TCamera>): void;
  71441. /**
  71442. * Remove a specific input method from a camera
  71443. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71444. * @param inputToRemove camera input method
  71445. */
  71446. remove(inputToRemove: ICameraInput<TCamera>): void;
  71447. /**
  71448. * Remove a specific input type from a camera
  71449. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71450. * @param inputType the type of the input to remove
  71451. */
  71452. removeByType(inputType: string): void;
  71453. private _addCheckInputs;
  71454. /**
  71455. * Attach the input controls to the currently attached dom element to listen the events from.
  71456. * @param input Defines the input to attach
  71457. */
  71458. attachInput(input: ICameraInput<TCamera>): void;
  71459. /**
  71460. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71461. * @param element Defines the dom element to collect the events from
  71462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71463. */
  71464. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71465. /**
  71466. * Detach the current manager inputs controls from a specific dom element.
  71467. * @param element Defines the dom element to collect the events from
  71468. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71469. */
  71470. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71471. /**
  71472. * Rebuild the dynamic inputCheck function from the current list of
  71473. * defined inputs in the manager.
  71474. */
  71475. rebuildInputCheck(): void;
  71476. /**
  71477. * Remove all attached input methods from a camera
  71478. */
  71479. clear(): void;
  71480. /**
  71481. * Serialize the current input manager attached to a camera.
  71482. * This ensures than once parsed,
  71483. * the input associated to the camera will be identical to the current ones
  71484. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71485. */
  71486. serialize(serializedCamera: any): void;
  71487. /**
  71488. * Parses an input manager serialized JSON to restore the previous list of inputs
  71489. * and states associated to a camera.
  71490. * @param parsedCamera Defines the JSON to parse
  71491. */
  71492. parse(parsedCamera: any): void;
  71493. }
  71494. }
  71495. declare module BABYLON {
  71496. /**
  71497. * Gather the list of keyboard event types as constants.
  71498. */
  71499. export class KeyboardEventTypes {
  71500. /**
  71501. * The keydown event is fired when a key becomes active (pressed).
  71502. */
  71503. static readonly KEYDOWN: number;
  71504. /**
  71505. * The keyup event is fired when a key has been released.
  71506. */
  71507. static readonly KEYUP: number;
  71508. }
  71509. /**
  71510. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71511. */
  71512. export class KeyboardInfo {
  71513. /**
  71514. * Defines the type of event (KeyboardEventTypes)
  71515. */
  71516. type: number;
  71517. /**
  71518. * Defines the related dom event
  71519. */
  71520. event: KeyboardEvent;
  71521. /**
  71522. * Instantiates a new keyboard info.
  71523. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71524. * @param type Defines the type of event (KeyboardEventTypes)
  71525. * @param event Defines the related dom event
  71526. */
  71527. constructor(
  71528. /**
  71529. * Defines the type of event (KeyboardEventTypes)
  71530. */
  71531. type: number,
  71532. /**
  71533. * Defines the related dom event
  71534. */
  71535. event: KeyboardEvent);
  71536. }
  71537. /**
  71538. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71539. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71540. */
  71541. export class KeyboardInfoPre extends KeyboardInfo {
  71542. /**
  71543. * Defines the type of event (KeyboardEventTypes)
  71544. */
  71545. type: number;
  71546. /**
  71547. * Defines the related dom event
  71548. */
  71549. event: KeyboardEvent;
  71550. /**
  71551. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71552. */
  71553. skipOnPointerObservable: boolean;
  71554. /**
  71555. * Instantiates a new keyboard pre info.
  71556. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71557. * @param type Defines the type of event (KeyboardEventTypes)
  71558. * @param event Defines the related dom event
  71559. */
  71560. constructor(
  71561. /**
  71562. * Defines the type of event (KeyboardEventTypes)
  71563. */
  71564. type: number,
  71565. /**
  71566. * Defines the related dom event
  71567. */
  71568. event: KeyboardEvent);
  71569. }
  71570. }
  71571. declare module BABYLON {
  71572. /**
  71573. * Manage the keyboard inputs to control the movement of a free camera.
  71574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71575. */
  71576. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71577. /**
  71578. * Defines the camera the input is attached to.
  71579. */
  71580. camera: FreeCamera;
  71581. /**
  71582. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71583. */
  71584. keysUp: number[];
  71585. /**
  71586. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71587. */
  71588. keysDown: number[];
  71589. /**
  71590. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71591. */
  71592. keysLeft: number[];
  71593. /**
  71594. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71595. */
  71596. keysRight: number[];
  71597. private _keys;
  71598. private _onCanvasBlurObserver;
  71599. private _onKeyboardObserver;
  71600. private _engine;
  71601. private _scene;
  71602. /**
  71603. * Attach the input controls to a specific dom element to get the input from.
  71604. * @param element Defines the element the controls should be listened from
  71605. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71606. */
  71607. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71608. /**
  71609. * Detach the current controls from the specified dom element.
  71610. * @param element Defines the element to stop listening the inputs from
  71611. */
  71612. detachControl(element: Nullable<HTMLElement>): void;
  71613. /**
  71614. * Update the current camera state depending on the inputs that have been used this frame.
  71615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71616. */
  71617. checkInputs(): void;
  71618. /**
  71619. * Gets the class name of the current intput.
  71620. * @returns the class name
  71621. */
  71622. getClassName(): string;
  71623. /** @hidden */
  71624. _onLostFocus(): void;
  71625. /**
  71626. * Get the friendly name associated with the input class.
  71627. * @returns the input friendly name
  71628. */
  71629. getSimpleName(): string;
  71630. }
  71631. }
  71632. declare module BABYLON {
  71633. /**
  71634. * Interface describing all the common properties and methods a shadow light needs to implement.
  71635. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  71636. * as well as binding the different shadow properties to the effects.
  71637. */
  71638. export interface IShadowLight extends Light {
  71639. /**
  71640. * The light id in the scene (used in scene.findLighById for instance)
  71641. */
  71642. id: string;
  71643. /**
  71644. * The position the shdow will be casted from.
  71645. */
  71646. position: Vector3;
  71647. /**
  71648. * In 2d mode (needCube being false), the direction used to cast the shadow.
  71649. */
  71650. direction: Vector3;
  71651. /**
  71652. * The transformed position. Position of the light in world space taking parenting in account.
  71653. */
  71654. transformedPosition: Vector3;
  71655. /**
  71656. * The transformed direction. Direction of the light in world space taking parenting in account.
  71657. */
  71658. transformedDirection: Vector3;
  71659. /**
  71660. * The friendly name of the light in the scene.
  71661. */
  71662. name: string;
  71663. /**
  71664. * Defines the shadow projection clipping minimum z value.
  71665. */
  71666. shadowMinZ: number;
  71667. /**
  71668. * Defines the shadow projection clipping maximum z value.
  71669. */
  71670. shadowMaxZ: number;
  71671. /**
  71672. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71673. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71674. */
  71675. computeTransformedInformation(): boolean;
  71676. /**
  71677. * Gets the scene the light belongs to.
  71678. * @returns The scene
  71679. */
  71680. getScene(): Scene;
  71681. /**
  71682. * Callback defining a custom Projection Matrix Builder.
  71683. * This can be used to override the default projection matrix computation.
  71684. */
  71685. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71686. /**
  71687. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71688. * @param matrix The materix to updated with the projection information
  71689. * @param viewMatrix The transform matrix of the light
  71690. * @param renderList The list of mesh to render in the map
  71691. * @returns The current light
  71692. */
  71693. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71694. /**
  71695. * Gets the current depth scale used in ESM.
  71696. * @returns The scale
  71697. */
  71698. getDepthScale(): number;
  71699. /**
  71700. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71701. * @returns true if a cube texture needs to be use
  71702. */
  71703. needCube(): boolean;
  71704. /**
  71705. * Detects if the projection matrix requires to be recomputed this frame.
  71706. * @returns true if it requires to be recomputed otherwise, false.
  71707. */
  71708. needProjectionMatrixCompute(): boolean;
  71709. /**
  71710. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71711. */
  71712. forceProjectionMatrixCompute(): void;
  71713. /**
  71714. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71715. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71716. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71717. */
  71718. getShadowDirection(faceIndex?: number): Vector3;
  71719. /**
  71720. * Gets the minZ used for shadow according to both the scene and the light.
  71721. * @param activeCamera The camera we are returning the min for
  71722. * @returns the depth min z
  71723. */
  71724. getDepthMinZ(activeCamera: Camera): number;
  71725. /**
  71726. * Gets the maxZ used for shadow according to both the scene and the light.
  71727. * @param activeCamera The camera we are returning the max for
  71728. * @returns the depth max z
  71729. */
  71730. getDepthMaxZ(activeCamera: Camera): number;
  71731. }
  71732. /**
  71733. * Base implementation IShadowLight
  71734. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  71735. */
  71736. export abstract class ShadowLight extends Light implements IShadowLight {
  71737. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  71738. protected _position: Vector3;
  71739. protected _setPosition(value: Vector3): void;
  71740. /**
  71741. * Sets the position the shadow will be casted from. Also use as the light position for both
  71742. * point and spot lights.
  71743. */
  71744. /**
  71745. * Sets the position the shadow will be casted from. Also use as the light position for both
  71746. * point and spot lights.
  71747. */
  71748. position: Vector3;
  71749. protected _direction: Vector3;
  71750. protected _setDirection(value: Vector3): void;
  71751. /**
  71752. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  71753. * Also use as the light direction on spot and directional lights.
  71754. */
  71755. /**
  71756. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  71757. * Also use as the light direction on spot and directional lights.
  71758. */
  71759. direction: Vector3;
  71760. private _shadowMinZ;
  71761. /**
  71762. * Gets the shadow projection clipping minimum z value.
  71763. */
  71764. /**
  71765. * Sets the shadow projection clipping minimum z value.
  71766. */
  71767. shadowMinZ: number;
  71768. private _shadowMaxZ;
  71769. /**
  71770. * Sets the shadow projection clipping maximum z value.
  71771. */
  71772. /**
  71773. * Gets the shadow projection clipping maximum z value.
  71774. */
  71775. shadowMaxZ: number;
  71776. /**
  71777. * Callback defining a custom Projection Matrix Builder.
  71778. * This can be used to override the default projection matrix computation.
  71779. */
  71780. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71781. /**
  71782. * The transformed position. Position of the light in world space taking parenting in account.
  71783. */
  71784. transformedPosition: Vector3;
  71785. /**
  71786. * The transformed direction. Direction of the light in world space taking parenting in account.
  71787. */
  71788. transformedDirection: Vector3;
  71789. private _needProjectionMatrixCompute;
  71790. /**
  71791. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71792. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71793. */
  71794. computeTransformedInformation(): boolean;
  71795. /**
  71796. * Return the depth scale used for the shadow map.
  71797. * @returns the depth scale.
  71798. */
  71799. getDepthScale(): number;
  71800. /**
  71801. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71802. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71803. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71804. */
  71805. getShadowDirection(faceIndex?: number): Vector3;
  71806. /**
  71807. * Returns the ShadowLight absolute position in the World.
  71808. * @returns the position vector in world space
  71809. */
  71810. getAbsolutePosition(): Vector3;
  71811. /**
  71812. * Sets the ShadowLight direction toward the passed target.
  71813. * @param target The point to target in local space
  71814. * @returns the updated ShadowLight direction
  71815. */
  71816. setDirectionToTarget(target: Vector3): Vector3;
  71817. /**
  71818. * Returns the light rotation in euler definition.
  71819. * @returns the x y z rotation in local space.
  71820. */
  71821. getRotation(): Vector3;
  71822. /**
  71823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71824. * @returns true if a cube texture needs to be use
  71825. */
  71826. needCube(): boolean;
  71827. /**
  71828. * Detects if the projection matrix requires to be recomputed this frame.
  71829. * @returns true if it requires to be recomputed otherwise, false.
  71830. */
  71831. needProjectionMatrixCompute(): boolean;
  71832. /**
  71833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71834. */
  71835. forceProjectionMatrixCompute(): void;
  71836. /** @hidden */
  71837. _initCache(): void;
  71838. /** @hidden */
  71839. _isSynchronized(): boolean;
  71840. /**
  71841. * Computes the world matrix of the node
  71842. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71843. * @returns the world matrix
  71844. */
  71845. computeWorldMatrix(force?: boolean): Matrix;
  71846. /**
  71847. * Gets the minZ used for shadow according to both the scene and the light.
  71848. * @param activeCamera The camera we are returning the min for
  71849. * @returns the depth min z
  71850. */
  71851. getDepthMinZ(activeCamera: Camera): number;
  71852. /**
  71853. * Gets the maxZ used for shadow according to both the scene and the light.
  71854. * @param activeCamera The camera we are returning the max for
  71855. * @returns the depth max z
  71856. */
  71857. getDepthMaxZ(activeCamera: Camera): number;
  71858. /**
  71859. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71860. * @param matrix The materix to updated with the projection information
  71861. * @param viewMatrix The transform matrix of the light
  71862. * @param renderList The list of mesh to render in the map
  71863. * @returns The current light
  71864. */
  71865. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71866. }
  71867. }
  71868. declare module BABYLON {
  71869. /**
  71870. * "Static Class" containing the most commonly used helper while dealing with material for
  71871. * rendering purpose.
  71872. *
  71873. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  71874. *
  71875. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  71876. */
  71877. export class MaterialHelper {
  71878. /**
  71879. * Bind the current view position to an effect.
  71880. * @param effect The effect to be bound
  71881. * @param scene The scene the eyes position is used from
  71882. */
  71883. static BindEyePosition(effect: Effect, scene: Scene): void;
  71884. /**
  71885. * Helps preparing the defines values about the UVs in used in the effect.
  71886. * UVs are shared as much as we can accross channels in the shaders.
  71887. * @param texture The texture we are preparing the UVs for
  71888. * @param defines The defines to update
  71889. * @param key The channel key "diffuse", "specular"... used in the shader
  71890. */
  71891. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  71892. /**
  71893. * Binds a texture matrix value to its corrsponding uniform
  71894. * @param texture The texture to bind the matrix for
  71895. * @param uniformBuffer The uniform buffer receivin the data
  71896. * @param key The channel key "diffuse", "specular"... used in the shader
  71897. */
  71898. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  71899. /**
  71900. * Gets the current status of the fog (should it be enabled?)
  71901. * @param mesh defines the mesh to evaluate for fog support
  71902. * @param scene defines the hosting scene
  71903. * @returns true if fog must be enabled
  71904. */
  71905. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  71906. /**
  71907. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  71908. * @param mesh defines the current mesh
  71909. * @param scene defines the current scene
  71910. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  71911. * @param pointsCloud defines if point cloud rendering has to be turned on
  71912. * @param fogEnabled defines if fog has to be turned on
  71913. * @param alphaTest defines if alpha testing has to be turned on
  71914. * @param defines defines the current list of defines
  71915. */
  71916. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  71917. /**
  71918. * Helper used to prepare the list of defines associated with frame values for shader compilation
  71919. * @param scene defines the current scene
  71920. * @param engine defines the current engine
  71921. * @param defines specifies the list of active defines
  71922. * @param useInstances defines if instances have to be turned on
  71923. * @param useClipPlane defines if clip plane have to be turned on
  71924. */
  71925. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  71926. /**
  71927. * Prepares the defines for bones
  71928. * @param mesh The mesh containing the geometry data we will draw
  71929. * @param defines The defines to update
  71930. */
  71931. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  71932. /**
  71933. * Prepares the defines for morph targets
  71934. * @param mesh The mesh containing the geometry data we will draw
  71935. * @param defines The defines to update
  71936. */
  71937. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  71938. /**
  71939. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  71940. * @param mesh The mesh containing the geometry data we will draw
  71941. * @param defines The defines to update
  71942. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  71943. * @param useBones Precise whether bones should be used or not (override mesh info)
  71944. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  71945. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  71946. * @returns false if defines are considered not dirty and have not been checked
  71947. */
  71948. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  71949. /**
  71950. * Prepares the defines related to multiview
  71951. * @param scene The scene we are intending to draw
  71952. * @param defines The defines to update
  71953. */
  71954. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  71955. /**
  71956. * Prepares the defines related to the light information passed in parameter
  71957. * @param scene The scene we are intending to draw
  71958. * @param mesh The mesh the effect is compiling for
  71959. * @param defines The defines to update
  71960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  71961. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  71962. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  71963. * @returns true if normals will be required for the rest of the effect
  71964. */
  71965. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  71966. /**
  71967. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  71968. * that won t be acctive due to defines being turned off.
  71969. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  71970. * @param samplersList The samplers list
  71971. * @param defines The defines helping in the list generation
  71972. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  71973. */
  71974. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  71975. /**
  71976. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  71977. * @param defines The defines to update while falling back
  71978. * @param fallbacks The authorized effect fallbacks
  71979. * @param maxSimultaneousLights The maximum number of lights allowed
  71980. * @param rank the current rank of the Effect
  71981. * @returns The newly affected rank
  71982. */
  71983. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  71984. /**
  71985. * Prepares the list of attributes required for morph targets according to the effect defines.
  71986. * @param attribs The current list of supported attribs
  71987. * @param mesh The mesh to prepare the morph targets attributes for
  71988. * @param defines The current Defines of the effect
  71989. */
  71990. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  71991. /**
  71992. * Prepares the list of attributes required for bones according to the effect defines.
  71993. * @param attribs The current list of supported attribs
  71994. * @param mesh The mesh to prepare the bones attributes for
  71995. * @param defines The current Defines of the effect
  71996. * @param fallbacks The current efffect fallback strategy
  71997. */
  71998. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  71999. /**
  72000. * Check and prepare the list of attributes required for instances according to the effect defines.
  72001. * @param attribs The current list of supported attribs
  72002. * @param defines The current MaterialDefines of the effect
  72003. */
  72004. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72005. /**
  72006. * Add the list of attributes required for instances to the attribs array.
  72007. * @param attribs The current list of supported attribs
  72008. */
  72009. static PushAttributesForInstances(attribs: string[]): void;
  72010. /**
  72011. * Binds the light shadow information to the effect for the given mesh.
  72012. * @param light The light containing the generator
  72013. * @param scene The scene the lights belongs to
  72014. * @param mesh The mesh we are binding the information to render
  72015. * @param lightIndex The light index in the effect used to render the mesh
  72016. * @param effect The effect we are binding the data to
  72017. */
  72018. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72019. /**
  72020. * Binds the light information to the effect.
  72021. * @param light The light containing the generator
  72022. * @param effect The effect we are binding the data to
  72023. * @param lightIndex The light index in the effect used to render
  72024. */
  72025. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72026. /**
  72027. * Binds the lights information from the scene to the effect for the given mesh.
  72028. * @param scene The scene the lights belongs to
  72029. * @param mesh The mesh we are binding the information to render
  72030. * @param effect The effect we are binding the data to
  72031. * @param defines The generated defines for the effect
  72032. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72033. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72034. */
  72035. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72036. private static _tempFogColor;
  72037. /**
  72038. * Binds the fog information from the scene to the effect for the given mesh.
  72039. * @param scene The scene the lights belongs to
  72040. * @param mesh The mesh we are binding the information to render
  72041. * @param effect The effect we are binding the data to
  72042. * @param linearSpace Defines if the fog effect is applied in linear space
  72043. */
  72044. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72045. /**
  72046. * Binds the bones information from the mesh to the effect.
  72047. * @param mesh The mesh we are binding the information to render
  72048. * @param effect The effect we are binding the data to
  72049. */
  72050. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72051. /**
  72052. * Binds the morph targets information from the mesh to the effect.
  72053. * @param abstractMesh The mesh we are binding the information to render
  72054. * @param effect The effect we are binding the data to
  72055. */
  72056. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72057. /**
  72058. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72059. * @param defines The generated defines used in the effect
  72060. * @param effect The effect we are binding the data to
  72061. * @param scene The scene we are willing to render with logarithmic scale for
  72062. */
  72063. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72064. /**
  72065. * Binds the clip plane information from the scene to the effect.
  72066. * @param scene The scene the clip plane information are extracted from
  72067. * @param effect The effect we are binding the data to
  72068. */
  72069. static BindClipPlane(effect: Effect, scene: Scene): void;
  72070. }
  72071. }
  72072. declare module BABYLON {
  72073. /** @hidden */
  72074. export var kernelBlurVaryingDeclaration: {
  72075. name: string;
  72076. shader: string;
  72077. };
  72078. }
  72079. declare module BABYLON {
  72080. /** @hidden */
  72081. export var kernelBlurFragment: {
  72082. name: string;
  72083. shader: string;
  72084. };
  72085. }
  72086. declare module BABYLON {
  72087. /** @hidden */
  72088. export var kernelBlurFragment2: {
  72089. name: string;
  72090. shader: string;
  72091. };
  72092. }
  72093. declare module BABYLON {
  72094. /** @hidden */
  72095. export var kernelBlurPixelShader: {
  72096. name: string;
  72097. shader: string;
  72098. };
  72099. }
  72100. declare module BABYLON {
  72101. /** @hidden */
  72102. export var kernelBlurVertex: {
  72103. name: string;
  72104. shader: string;
  72105. };
  72106. }
  72107. declare module BABYLON {
  72108. /** @hidden */
  72109. export var kernelBlurVertexShader: {
  72110. name: string;
  72111. shader: string;
  72112. };
  72113. }
  72114. declare module BABYLON {
  72115. /**
  72116. * The Blur Post Process which blurs an image based on a kernel and direction.
  72117. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  72118. */
  72119. export class BlurPostProcess extends PostProcess {
  72120. /** The direction in which to blur the image. */
  72121. direction: Vector2;
  72122. private blockCompilation;
  72123. protected _kernel: number;
  72124. protected _idealKernel: number;
  72125. protected _packedFloat: boolean;
  72126. private _staticDefines;
  72127. /**
  72128. * Sets the length in pixels of the blur sample region
  72129. */
  72130. /**
  72131. * Gets the length in pixels of the blur sample region
  72132. */
  72133. kernel: number;
  72134. /**
  72135. * Sets wether or not the blur needs to unpack/repack floats
  72136. */
  72137. /**
  72138. * Gets wether or not the blur is unpacking/repacking floats
  72139. */
  72140. packedFloat: boolean;
  72141. /**
  72142. * Creates a new instance BlurPostProcess
  72143. * @param name The name of the effect.
  72144. * @param direction The direction in which to blur the image.
  72145. * @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.
  72146. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72147. * @param camera The camera to apply the render pass to.
  72148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72149. * @param engine The engine which the post process will be applied. (default: current engine)
  72150. * @param reusable If the post process can be reused on the same frame. (default: false)
  72151. * @param textureType Type of textures used when performing the post process. (default: 0)
  72152. * @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)
  72153. */
  72154. constructor(name: string,
  72155. /** The direction in which to blur the image. */
  72156. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  72157. /**
  72158. * Updates the effect with the current post process compile time values and recompiles the shader.
  72159. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72160. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72161. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72162. * @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
  72163. * @param onCompiled Called when the shader has been compiled.
  72164. * @param onError Called if there is an error when compiling a shader.
  72165. */
  72166. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72167. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72168. /**
  72169. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  72170. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  72171. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  72172. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  72173. * The gaps between physical kernels are compensated for in the weighting of the samples
  72174. * @param idealKernel Ideal blur kernel.
  72175. * @return Nearest best kernel.
  72176. */
  72177. protected _nearestBestKernel(idealKernel: number): number;
  72178. /**
  72179. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  72180. * @param x The point on the Gaussian distribution to sample.
  72181. * @return the value of the Gaussian function at x.
  72182. */
  72183. protected _gaussianWeight(x: number): number;
  72184. /**
  72185. * Generates a string that can be used as a floating point number in GLSL.
  72186. * @param x Value to print.
  72187. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  72188. * @return GLSL float string.
  72189. */
  72190. protected _glslFloat(x: number, decimalFigures?: number): string;
  72191. }
  72192. }
  72193. declare module BABYLON {
  72194. /** @hidden */
  72195. export var shadowMapPixelShader: {
  72196. name: string;
  72197. shader: string;
  72198. };
  72199. }
  72200. declare module BABYLON {
  72201. /** @hidden */
  72202. export var bonesDeclaration: {
  72203. name: string;
  72204. shader: string;
  72205. };
  72206. }
  72207. declare module BABYLON {
  72208. /** @hidden */
  72209. export var morphTargetsVertexGlobalDeclaration: {
  72210. name: string;
  72211. shader: string;
  72212. };
  72213. }
  72214. declare module BABYLON {
  72215. /** @hidden */
  72216. export var morphTargetsVertexDeclaration: {
  72217. name: string;
  72218. shader: string;
  72219. };
  72220. }
  72221. declare module BABYLON {
  72222. /** @hidden */
  72223. export var instancesDeclaration: {
  72224. name: string;
  72225. shader: string;
  72226. };
  72227. }
  72228. declare module BABYLON {
  72229. /** @hidden */
  72230. export var helperFunctions: {
  72231. name: string;
  72232. shader: string;
  72233. };
  72234. }
  72235. declare module BABYLON {
  72236. /** @hidden */
  72237. export var morphTargetsVertex: {
  72238. name: string;
  72239. shader: string;
  72240. };
  72241. }
  72242. declare module BABYLON {
  72243. /** @hidden */
  72244. export var instancesVertex: {
  72245. name: string;
  72246. shader: string;
  72247. };
  72248. }
  72249. declare module BABYLON {
  72250. /** @hidden */
  72251. export var bonesVertex: {
  72252. name: string;
  72253. shader: string;
  72254. };
  72255. }
  72256. declare module BABYLON {
  72257. /** @hidden */
  72258. export var shadowMapVertexShader: {
  72259. name: string;
  72260. shader: string;
  72261. };
  72262. }
  72263. declare module BABYLON {
  72264. /** @hidden */
  72265. export var depthBoxBlurPixelShader: {
  72266. name: string;
  72267. shader: string;
  72268. };
  72269. }
  72270. declare module BABYLON {
  72271. /**
  72272. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72273. */
  72274. export interface ICustomShaderOptions {
  72275. /**
  72276. * Gets or sets the custom shader name to use
  72277. */
  72278. shaderName: string;
  72279. /**
  72280. * The list of attribute names used in the shader
  72281. */
  72282. attributes?: string[];
  72283. /**
  72284. * The list of unifrom names used in the shader
  72285. */
  72286. uniforms?: string[];
  72287. /**
  72288. * The list of sampler names used in the shader
  72289. */
  72290. samplers?: string[];
  72291. /**
  72292. * The list of defines used in the shader
  72293. */
  72294. defines?: string[];
  72295. }
  72296. /**
  72297. * Interface to implement to create a shadow generator compatible with BJS.
  72298. */
  72299. export interface IShadowGenerator {
  72300. /**
  72301. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72302. * @returns The render target texture if present otherwise, null
  72303. */
  72304. getShadowMap(): Nullable<RenderTargetTexture>;
  72305. /**
  72306. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72307. * @returns The render target texture if the shadow map is present otherwise, null
  72308. */
  72309. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72310. /**
  72311. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72312. * @param subMesh The submesh we want to render in the shadow map
  72313. * @param useInstances Defines wether will draw in the map using instances
  72314. * @returns true if ready otherwise, false
  72315. */
  72316. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72317. /**
  72318. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72319. * @param defines Defines of the material we want to update
  72320. * @param lightIndex Index of the light in the enabled light list of the material
  72321. */
  72322. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72323. /**
  72324. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72325. * defined in the generator but impacting the effect).
  72326. * It implies the unifroms available on the materials are the standard BJS ones.
  72327. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72328. * @param effect The effect we are binfing the information for
  72329. */
  72330. bindShadowLight(lightIndex: string, effect: Effect): void;
  72331. /**
  72332. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72333. * (eq to shadow prjection matrix * light transform matrix)
  72334. * @returns The transform matrix used to create the shadow map
  72335. */
  72336. getTransformMatrix(): Matrix;
  72337. /**
  72338. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72339. * Cube and 2D textures for instance.
  72340. */
  72341. recreateShadowMap(): void;
  72342. /**
  72343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72344. * @param onCompiled Callback triggered at the and of the effects compilation
  72345. * @param options Sets of optional options forcing the compilation with different modes
  72346. */
  72347. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72348. useInstances: boolean;
  72349. }>): void;
  72350. /**
  72351. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72352. * @param options Sets of optional options forcing the compilation with different modes
  72353. * @returns A promise that resolves when the compilation completes
  72354. */
  72355. forceCompilationAsync(options?: Partial<{
  72356. useInstances: boolean;
  72357. }>): Promise<void>;
  72358. /**
  72359. * Serializes the shadow generator setup to a json object.
  72360. * @returns The serialized JSON object
  72361. */
  72362. serialize(): any;
  72363. /**
  72364. * Disposes the Shadow map and related Textures and effects.
  72365. */
  72366. dispose(): void;
  72367. }
  72368. /**
  72369. * Default implementation IShadowGenerator.
  72370. * This is the main object responsible of generating shadows in the framework.
  72371. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72372. */
  72373. export class ShadowGenerator implements IShadowGenerator {
  72374. /**
  72375. * Shadow generator mode None: no filtering applied.
  72376. */
  72377. static readonly FILTER_NONE: number;
  72378. /**
  72379. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72381. */
  72382. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72383. /**
  72384. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72385. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72386. */
  72387. static readonly FILTER_POISSONSAMPLING: number;
  72388. /**
  72389. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72391. */
  72392. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72393. /**
  72394. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72395. * edge artifacts on steep falloff.
  72396. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72397. */
  72398. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72399. /**
  72400. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72401. * edge artifacts on steep falloff.
  72402. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72403. */
  72404. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72405. /**
  72406. * Shadow generator mode PCF: Percentage Closer Filtering
  72407. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72408. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72409. */
  72410. static readonly FILTER_PCF: number;
  72411. /**
  72412. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  72413. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72414. * Contact Hardening
  72415. */
  72416. static readonly FILTER_PCSS: number;
  72417. /**
  72418. * Reserved for PCF and PCSS
  72419. * Highest Quality.
  72420. *
  72421. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  72422. *
  72423. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  72424. */
  72425. static readonly QUALITY_HIGH: number;
  72426. /**
  72427. * Reserved for PCF and PCSS
  72428. * Good tradeoff for quality/perf cross devices
  72429. *
  72430. * Execute PCF on a 3*3 kernel.
  72431. *
  72432. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  72433. */
  72434. static readonly QUALITY_MEDIUM: number;
  72435. /**
  72436. * Reserved for PCF and PCSS
  72437. * The lowest quality but the fastest.
  72438. *
  72439. * Execute PCF on a 1*1 kernel.
  72440. *
  72441. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  72442. */
  72443. static readonly QUALITY_LOW: number;
  72444. /** Gets or sets the custom shader name to use */
  72445. customShaderOptions: ICustomShaderOptions;
  72446. /**
  72447. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  72448. */
  72449. onBeforeShadowMapRenderObservable: Observable<Effect>;
  72450. /**
  72451. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  72452. */
  72453. onAfterShadowMapRenderObservable: Observable<Effect>;
  72454. /**
  72455. * Observable triggered before a mesh is rendered in the shadow map.
  72456. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  72457. */
  72458. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  72459. /**
  72460. * Observable triggered after a mesh is rendered in the shadow map.
  72461. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  72462. */
  72463. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  72464. private _bias;
  72465. /**
  72466. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  72467. */
  72468. /**
  72469. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  72470. */
  72471. bias: number;
  72472. private _normalBias;
  72473. /**
  72474. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72475. */
  72476. /**
  72477. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72478. */
  72479. normalBias: number;
  72480. private _blurBoxOffset;
  72481. /**
  72482. * Gets the blur box offset: offset applied during the blur pass.
  72483. * Only useful if useKernelBlur = false
  72484. */
  72485. /**
  72486. * Sets the blur box offset: offset applied during the blur pass.
  72487. * Only useful if useKernelBlur = false
  72488. */
  72489. blurBoxOffset: number;
  72490. private _blurScale;
  72491. /**
  72492. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  72493. * 2 means half of the size.
  72494. */
  72495. /**
  72496. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  72497. * 2 means half of the size.
  72498. */
  72499. blurScale: number;
  72500. private _blurKernel;
  72501. /**
  72502. * Gets the blur kernel: kernel size of the blur pass.
  72503. * Only useful if useKernelBlur = true
  72504. */
  72505. /**
  72506. * Sets the blur kernel: kernel size of the blur pass.
  72507. * Only useful if useKernelBlur = true
  72508. */
  72509. blurKernel: number;
  72510. private _useKernelBlur;
  72511. /**
  72512. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  72513. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72514. */
  72515. /**
  72516. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  72517. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72518. */
  72519. useKernelBlur: boolean;
  72520. private _depthScale;
  72521. /**
  72522. * Gets the depth scale used in ESM mode.
  72523. */
  72524. /**
  72525. * Sets the depth scale used in ESM mode.
  72526. * This can override the scale stored on the light.
  72527. */
  72528. depthScale: number;
  72529. private _filter;
  72530. /**
  72531. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  72532. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72533. */
  72534. /**
  72535. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  72536. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72537. */
  72538. filter: number;
  72539. /**
  72540. * Gets if the current filter is set to Poisson Sampling.
  72541. */
  72542. /**
  72543. * Sets the current filter to Poisson Sampling.
  72544. */
  72545. usePoissonSampling: boolean;
  72546. /**
  72547. * Gets if the current filter is set to ESM.
  72548. */
  72549. /**
  72550. * Sets the current filter is to ESM.
  72551. */
  72552. useExponentialShadowMap: boolean;
  72553. /**
  72554. * Gets if the current filter is set to filtered ESM.
  72555. */
  72556. /**
  72557. * Gets if the current filter is set to filtered ESM.
  72558. */
  72559. useBlurExponentialShadowMap: boolean;
  72560. /**
  72561. * Gets if the current filter is set to "close ESM" (using the inverse of the
  72562. * exponential to prevent steep falloff artifacts).
  72563. */
  72564. /**
  72565. * Sets the current filter to "close ESM" (using the inverse of the
  72566. * exponential to prevent steep falloff artifacts).
  72567. */
  72568. useCloseExponentialShadowMap: boolean;
  72569. /**
  72570. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  72571. * exponential to prevent steep falloff artifacts).
  72572. */
  72573. /**
  72574. * Sets the current filter to filtered "close ESM" (using the inverse of the
  72575. * exponential to prevent steep falloff artifacts).
  72576. */
  72577. useBlurCloseExponentialShadowMap: boolean;
  72578. /**
  72579. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  72580. */
  72581. /**
  72582. * Sets the current filter to "PCF" (percentage closer filtering).
  72583. */
  72584. usePercentageCloserFiltering: boolean;
  72585. private _filteringQuality;
  72586. /**
  72587. * Gets the PCF or PCSS Quality.
  72588. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72589. */
  72590. /**
  72591. * Sets the PCF or PCSS Quality.
  72592. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72593. */
  72594. filteringQuality: number;
  72595. /**
  72596. * Gets if the current filter is set to "PCSS" (contact hardening).
  72597. */
  72598. /**
  72599. * Sets the current filter to "PCSS" (contact hardening).
  72600. */
  72601. useContactHardeningShadow: boolean;
  72602. private _contactHardeningLightSizeUVRatio;
  72603. /**
  72604. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72605. * Using a ratio helps keeping shape stability independently of the map size.
  72606. *
  72607. * It does not account for the light projection as it was having too much
  72608. * instability during the light setup or during light position changes.
  72609. *
  72610. * Only valid if useContactHardeningShadow is true.
  72611. */
  72612. /**
  72613. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72614. * Using a ratio helps keeping shape stability independently of the map size.
  72615. *
  72616. * It does not account for the light projection as it was having too much
  72617. * instability during the light setup or during light position changes.
  72618. *
  72619. * Only valid if useContactHardeningShadow is true.
  72620. */
  72621. contactHardeningLightSizeUVRatio: number;
  72622. private _darkness;
  72623. /** Gets or sets the actual darkness of a shadow */
  72624. darkness: number;
  72625. /**
  72626. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  72627. * 0 means strongest and 1 would means no shadow.
  72628. * @returns the darkness.
  72629. */
  72630. getDarkness(): number;
  72631. /**
  72632. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  72633. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  72634. * @returns the shadow generator allowing fluent coding.
  72635. */
  72636. setDarkness(darkness: number): ShadowGenerator;
  72637. private _transparencyShadow;
  72638. /** Gets or sets the ability to have transparent shadow */
  72639. transparencyShadow: boolean;
  72640. /**
  72641. * Sets the ability to have transparent shadow (boolean).
  72642. * @param transparent True if transparent else False
  72643. * @returns the shadow generator allowing fluent coding
  72644. */
  72645. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  72646. private _shadowMap;
  72647. private _shadowMap2;
  72648. /**
  72649. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72650. * @returns The render target texture if present otherwise, null
  72651. */
  72652. getShadowMap(): Nullable<RenderTargetTexture>;
  72653. /**
  72654. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72655. * @returns The render target texture if the shadow map is present otherwise, null
  72656. */
  72657. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72658. /**
  72659. * Gets the class name of that object
  72660. * @returns "ShadowGenerator"
  72661. */
  72662. getClassName(): string;
  72663. /**
  72664. * Helper function to add a mesh and its descendants to the list of shadow casters.
  72665. * @param mesh Mesh to add
  72666. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  72667. * @returns the Shadow Generator itself
  72668. */
  72669. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72670. /**
  72671. * Helper function to remove a mesh and its descendants from the list of shadow casters
  72672. * @param mesh Mesh to remove
  72673. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  72674. * @returns the Shadow Generator itself
  72675. */
  72676. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72677. /**
  72678. * Controls the extent to which the shadows fade out at the edge of the frustum
  72679. * Used only by directionals and spots
  72680. */
  72681. frustumEdgeFalloff: number;
  72682. private _light;
  72683. /**
  72684. * Returns the associated light object.
  72685. * @returns the light generating the shadow
  72686. */
  72687. getLight(): IShadowLight;
  72688. /**
  72689. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  72690. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  72691. * It might on the other hand introduce peter panning.
  72692. */
  72693. forceBackFacesOnly: boolean;
  72694. private _scene;
  72695. private _lightDirection;
  72696. private _effect;
  72697. private _viewMatrix;
  72698. private _projectionMatrix;
  72699. private _transformMatrix;
  72700. private _cachedPosition;
  72701. private _cachedDirection;
  72702. private _cachedDefines;
  72703. private _currentRenderID;
  72704. private _boxBlurPostprocess;
  72705. private _kernelBlurXPostprocess;
  72706. private _kernelBlurYPostprocess;
  72707. private _blurPostProcesses;
  72708. private _mapSize;
  72709. private _currentFaceIndex;
  72710. private _currentFaceIndexCache;
  72711. private _textureType;
  72712. private _defaultTextureMatrix;
  72713. /** @hidden */
  72714. static _SceneComponentInitialization: (scene: Scene) => void;
  72715. /**
  72716. * Creates a ShadowGenerator object.
  72717. * A ShadowGenerator is the required tool to use the shadows.
  72718. * Each light casting shadows needs to use its own ShadowGenerator.
  72719. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  72720. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  72721. * @param light The light object generating the shadows.
  72722. * @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.
  72723. */
  72724. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  72725. private _initializeGenerator;
  72726. private _initializeShadowMap;
  72727. private _initializeBlurRTTAndPostProcesses;
  72728. private _renderForShadowMap;
  72729. private _renderSubMeshForShadowMap;
  72730. private _applyFilterValues;
  72731. /**
  72732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72733. * @param onCompiled Callback triggered at the and of the effects compilation
  72734. * @param options Sets of optional options forcing the compilation with different modes
  72735. */
  72736. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72737. useInstances: boolean;
  72738. }>): void;
  72739. /**
  72740. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72741. * @param options Sets of optional options forcing the compilation with different modes
  72742. * @returns A promise that resolves when the compilation completes
  72743. */
  72744. forceCompilationAsync(options?: Partial<{
  72745. useInstances: boolean;
  72746. }>): Promise<void>;
  72747. /**
  72748. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72749. * @param subMesh The submesh we want to render in the shadow map
  72750. * @param useInstances Defines wether will draw in the map using instances
  72751. * @returns true if ready otherwise, false
  72752. */
  72753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72754. /**
  72755. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72756. * @param defines Defines of the material we want to update
  72757. * @param lightIndex Index of the light in the enabled light list of the material
  72758. */
  72759. prepareDefines(defines: any, lightIndex: number): void;
  72760. /**
  72761. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72762. * defined in the generator but impacting the effect).
  72763. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72764. * @param effect The effect we are binfing the information for
  72765. */
  72766. bindShadowLight(lightIndex: string, effect: Effect): void;
  72767. /**
  72768. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72769. * (eq to shadow prjection matrix * light transform matrix)
  72770. * @returns The transform matrix used to create the shadow map
  72771. */
  72772. getTransformMatrix(): Matrix;
  72773. /**
  72774. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72775. * Cube and 2D textures for instance.
  72776. */
  72777. recreateShadowMap(): void;
  72778. private _disposeBlurPostProcesses;
  72779. private _disposeRTTandPostProcesses;
  72780. /**
  72781. * Disposes the ShadowGenerator.
  72782. * Returns nothing.
  72783. */
  72784. dispose(): void;
  72785. /**
  72786. * Serializes the shadow generator setup to a json object.
  72787. * @returns The serialized JSON object
  72788. */
  72789. serialize(): any;
  72790. /**
  72791. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  72792. * @param parsedShadowGenerator The JSON object to parse
  72793. * @param scene The scene to create the shadow map for
  72794. * @returns The parsed shadow generator
  72795. */
  72796. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  72797. }
  72798. }
  72799. declare module BABYLON {
  72800. /**
  72801. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  72802. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  72803. * 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.
  72804. */
  72805. export abstract class Light extends Node {
  72806. /**
  72807. * Falloff Default: light is falling off following the material specification:
  72808. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  72809. */
  72810. static readonly FALLOFF_DEFAULT: number;
  72811. /**
  72812. * Falloff Physical: light is falling off following the inverse squared distance law.
  72813. */
  72814. static readonly FALLOFF_PHYSICAL: number;
  72815. /**
  72816. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  72817. * to enhance interoperability with other engines.
  72818. */
  72819. static readonly FALLOFF_GLTF: number;
  72820. /**
  72821. * Falloff Standard: light is falling off like in the standard material
  72822. * to enhance interoperability with other materials.
  72823. */
  72824. static readonly FALLOFF_STANDARD: number;
  72825. /**
  72826. * If every light affecting the material is in this lightmapMode,
  72827. * material.lightmapTexture adds or multiplies
  72828. * (depends on material.useLightmapAsShadowmap)
  72829. * after every other light calculations.
  72830. */
  72831. static readonly LIGHTMAP_DEFAULT: number;
  72832. /**
  72833. * material.lightmapTexture as only diffuse lighting from this light
  72834. * adds only specular lighting from this light
  72835. * adds dynamic shadows
  72836. */
  72837. static readonly LIGHTMAP_SPECULAR: number;
  72838. /**
  72839. * material.lightmapTexture as only lighting
  72840. * no light calculation from this light
  72841. * only adds dynamic shadows from this light
  72842. */
  72843. static readonly LIGHTMAP_SHADOWSONLY: number;
  72844. /**
  72845. * Each light type uses the default quantity according to its type:
  72846. * point/spot lights use luminous intensity
  72847. * directional lights use illuminance
  72848. */
  72849. static readonly INTENSITYMODE_AUTOMATIC: number;
  72850. /**
  72851. * lumen (lm)
  72852. */
  72853. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  72854. /**
  72855. * candela (lm/sr)
  72856. */
  72857. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  72858. /**
  72859. * lux (lm/m^2)
  72860. */
  72861. static readonly INTENSITYMODE_ILLUMINANCE: number;
  72862. /**
  72863. * nit (cd/m^2)
  72864. */
  72865. static readonly INTENSITYMODE_LUMINANCE: number;
  72866. /**
  72867. * Light type const id of the point light.
  72868. */
  72869. static readonly LIGHTTYPEID_POINTLIGHT: number;
  72870. /**
  72871. * Light type const id of the directional light.
  72872. */
  72873. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  72874. /**
  72875. * Light type const id of the spot light.
  72876. */
  72877. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  72878. /**
  72879. * Light type const id of the hemispheric light.
  72880. */
  72881. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  72882. /**
  72883. * Diffuse gives the basic color to an object.
  72884. */
  72885. diffuse: Color3;
  72886. /**
  72887. * Specular produces a highlight color on an object.
  72888. * Note: This is note affecting PBR materials.
  72889. */
  72890. specular: Color3;
  72891. /**
  72892. * Defines the falloff type for this light. This lets overrriding how punctual light are
  72893. * falling off base on range or angle.
  72894. * This can be set to any values in Light.FALLOFF_x.
  72895. *
  72896. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  72897. * other types of materials.
  72898. */
  72899. falloffType: number;
  72900. /**
  72901. * Strength of the light.
  72902. * Note: By default it is define in the framework own unit.
  72903. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  72904. */
  72905. intensity: number;
  72906. private _range;
  72907. protected _inverseSquaredRange: number;
  72908. /**
  72909. * Defines how far from the source the light is impacting in scene units.
  72910. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72911. */
  72912. /**
  72913. * Defines how far from the source the light is impacting in scene units.
  72914. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72915. */
  72916. range: number;
  72917. /**
  72918. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  72919. * of light.
  72920. */
  72921. private _photometricScale;
  72922. private _intensityMode;
  72923. /**
  72924. * Gets the photometric scale used to interpret the intensity.
  72925. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72926. */
  72927. /**
  72928. * Sets the photometric scale used to interpret the intensity.
  72929. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72930. */
  72931. intensityMode: number;
  72932. private _radius;
  72933. /**
  72934. * Gets the light radius used by PBR Materials to simulate soft area lights.
  72935. */
  72936. /**
  72937. * sets the light radius used by PBR Materials to simulate soft area lights.
  72938. */
  72939. radius: number;
  72940. private _renderPriority;
  72941. /**
  72942. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  72943. * exceeding the number allowed of the materials.
  72944. */
  72945. renderPriority: number;
  72946. private _shadowEnabled;
  72947. /**
  72948. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72949. * the current shadow generator.
  72950. */
  72951. /**
  72952. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72953. * the current shadow generator.
  72954. */
  72955. shadowEnabled: boolean;
  72956. private _includedOnlyMeshes;
  72957. /**
  72958. * Gets the only meshes impacted by this light.
  72959. */
  72960. /**
  72961. * Sets the only meshes impacted by this light.
  72962. */
  72963. includedOnlyMeshes: AbstractMesh[];
  72964. private _excludedMeshes;
  72965. /**
  72966. * Gets the meshes not impacted by this light.
  72967. */
  72968. /**
  72969. * Sets the meshes not impacted by this light.
  72970. */
  72971. excludedMeshes: AbstractMesh[];
  72972. private _excludeWithLayerMask;
  72973. /**
  72974. * Gets the layer id use to find what meshes are not impacted by the light.
  72975. * Inactive if 0
  72976. */
  72977. /**
  72978. * Sets the layer id use to find what meshes are not impacted by the light.
  72979. * Inactive if 0
  72980. */
  72981. excludeWithLayerMask: number;
  72982. private _includeOnlyWithLayerMask;
  72983. /**
  72984. * Gets the layer id use to find what meshes are impacted by the light.
  72985. * Inactive if 0
  72986. */
  72987. /**
  72988. * Sets the layer id use to find what meshes are impacted by the light.
  72989. * Inactive if 0
  72990. */
  72991. includeOnlyWithLayerMask: number;
  72992. private _lightmapMode;
  72993. /**
  72994. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72995. */
  72996. /**
  72997. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72998. */
  72999. lightmapMode: number;
  73000. /**
  73001. * Shadow generator associted to the light.
  73002. * @hidden Internal use only.
  73003. */
  73004. _shadowGenerator: Nullable<IShadowGenerator>;
  73005. /**
  73006. * @hidden Internal use only.
  73007. */
  73008. _excludedMeshesIds: string[];
  73009. /**
  73010. * @hidden Internal use only.
  73011. */
  73012. _includedOnlyMeshesIds: string[];
  73013. /**
  73014. * The current light unifom buffer.
  73015. * @hidden Internal use only.
  73016. */
  73017. _uniformBuffer: UniformBuffer;
  73018. /**
  73019. * Creates a Light object in the scene.
  73020. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73021. * @param name The firendly name of the light
  73022. * @param scene The scene the light belongs too
  73023. */
  73024. constructor(name: string, scene: Scene);
  73025. protected abstract _buildUniformLayout(): void;
  73026. /**
  73027. * Sets the passed Effect "effect" with the Light information.
  73028. * @param effect The effect to update
  73029. * @param lightIndex The index of the light in the effect to update
  73030. * @returns The light
  73031. */
  73032. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73033. /**
  73034. * Returns the string "Light".
  73035. * @returns the class name
  73036. */
  73037. getClassName(): string;
  73038. /** @hidden */
  73039. readonly _isLight: boolean;
  73040. /**
  73041. * Converts the light information to a readable string for debug purpose.
  73042. * @param fullDetails Supports for multiple levels of logging within scene loading
  73043. * @returns the human readable light info
  73044. */
  73045. toString(fullDetails?: boolean): string;
  73046. /** @hidden */
  73047. protected _syncParentEnabledState(): void;
  73048. /**
  73049. * Set the enabled state of this node.
  73050. * @param value - the new enabled state
  73051. */
  73052. setEnabled(value: boolean): void;
  73053. /**
  73054. * Returns the Light associated shadow generator if any.
  73055. * @return the associated shadow generator.
  73056. */
  73057. getShadowGenerator(): Nullable<IShadowGenerator>;
  73058. /**
  73059. * Returns a Vector3, the absolute light position in the World.
  73060. * @returns the world space position of the light
  73061. */
  73062. getAbsolutePosition(): Vector3;
  73063. /**
  73064. * Specifies if the light will affect the passed mesh.
  73065. * @param mesh The mesh to test against the light
  73066. * @return true the mesh is affected otherwise, false.
  73067. */
  73068. canAffectMesh(mesh: AbstractMesh): boolean;
  73069. /**
  73070. * Sort function to order lights for rendering.
  73071. * @param a First Light object to compare to second.
  73072. * @param b Second Light object to compare first.
  73073. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73074. */
  73075. static CompareLightsPriority(a: Light, b: Light): number;
  73076. /**
  73077. * Releases resources associated with this node.
  73078. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73079. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73080. */
  73081. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73082. /**
  73083. * Returns the light type ID (integer).
  73084. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73085. */
  73086. getTypeID(): number;
  73087. /**
  73088. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73089. * @returns the scaled intensity in intensity mode unit
  73090. */
  73091. getScaledIntensity(): number;
  73092. /**
  73093. * Returns a new Light object, named "name", from the current one.
  73094. * @param name The name of the cloned light
  73095. * @returns the new created light
  73096. */
  73097. clone(name: string): Nullable<Light>;
  73098. /**
  73099. * Serializes the current light into a Serialization object.
  73100. * @returns the serialized object.
  73101. */
  73102. serialize(): any;
  73103. /**
  73104. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73105. * This new light is named "name" and added to the passed scene.
  73106. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73107. * @param name The friendly name of the light
  73108. * @param scene The scene the new light will belong to
  73109. * @returns the constructor function
  73110. */
  73111. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73112. /**
  73113. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73114. * @param parsedLight The JSON representation of the light
  73115. * @param scene The scene to create the parsed light in
  73116. * @returns the created light after parsing
  73117. */
  73118. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73119. private _hookArrayForExcluded;
  73120. private _hookArrayForIncludedOnly;
  73121. private _resyncMeshes;
  73122. /**
  73123. * Forces the meshes to update their light related information in their rendering used effects
  73124. * @hidden Internal Use Only
  73125. */
  73126. _markMeshesAsLightDirty(): void;
  73127. /**
  73128. * Recomputes the cached photometric scale if needed.
  73129. */
  73130. private _computePhotometricScale;
  73131. /**
  73132. * Returns the Photometric Scale according to the light type and intensity mode.
  73133. */
  73134. private _getPhotometricScale;
  73135. /**
  73136. * Reorder the light in the scene according to their defined priority.
  73137. * @hidden Internal Use Only
  73138. */
  73139. _reorderLightsInScene(): void;
  73140. /**
  73141. * Prepares the list of defines specific to the light type.
  73142. * @param defines the list of defines
  73143. * @param lightIndex defines the index of the light for the effect
  73144. */
  73145. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73146. }
  73147. }
  73148. declare module BABYLON {
  73149. /**
  73150. * Interface used to define Action
  73151. */
  73152. export interface IAction {
  73153. /**
  73154. * Trigger for the action
  73155. */
  73156. trigger: number;
  73157. /** Options of the trigger */
  73158. triggerOptions: any;
  73159. /**
  73160. * Gets the trigger parameters
  73161. * @returns the trigger parameters
  73162. */
  73163. getTriggerParameter(): any;
  73164. /**
  73165. * Internal only - executes current action event
  73166. * @hidden
  73167. */
  73168. _executeCurrent(evt?: ActionEvent): void;
  73169. /**
  73170. * Serialize placeholder for child classes
  73171. * @param parent of child
  73172. * @returns the serialized object
  73173. */
  73174. serialize(parent: any): any;
  73175. /**
  73176. * Internal only
  73177. * @hidden
  73178. */
  73179. _prepare(): void;
  73180. /**
  73181. * Internal only - manager for action
  73182. * @hidden
  73183. */
  73184. _actionManager: AbstractActionManager;
  73185. /**
  73186. * Adds action to chain of actions, may be a DoNothingAction
  73187. * @param action defines the next action to execute
  73188. * @returns The action passed in
  73189. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73190. */
  73191. then(action: IAction): IAction;
  73192. }
  73193. /**
  73194. * The action to be carried out following a trigger
  73195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73196. */
  73197. export class Action implements IAction {
  73198. /** the trigger, with or without parameters, for the action */
  73199. triggerOptions: any;
  73200. /**
  73201. * Trigger for the action
  73202. */
  73203. trigger: number;
  73204. /**
  73205. * Internal only - manager for action
  73206. * @hidden
  73207. */
  73208. _actionManager: ActionManager;
  73209. private _nextActiveAction;
  73210. private _child;
  73211. private _condition?;
  73212. private _triggerParameter;
  73213. /**
  73214. * An event triggered prior to action being executed.
  73215. */
  73216. onBeforeExecuteObservable: Observable<Action>;
  73217. /**
  73218. * Creates a new Action
  73219. * @param triggerOptions the trigger, with or without parameters, for the action
  73220. * @param condition an optional determinant of action
  73221. */
  73222. constructor(
  73223. /** the trigger, with or without parameters, for the action */
  73224. triggerOptions: any, condition?: Condition);
  73225. /**
  73226. * Internal only
  73227. * @hidden
  73228. */
  73229. _prepare(): void;
  73230. /**
  73231. * Gets the trigger parameters
  73232. * @returns the trigger parameters
  73233. */
  73234. getTriggerParameter(): any;
  73235. /**
  73236. * Internal only - executes current action event
  73237. * @hidden
  73238. */
  73239. _executeCurrent(evt?: ActionEvent): void;
  73240. /**
  73241. * Execute placeholder for child classes
  73242. * @param evt optional action event
  73243. */
  73244. execute(evt?: ActionEvent): void;
  73245. /**
  73246. * Skips to next active action
  73247. */
  73248. skipToNextActiveAction(): void;
  73249. /**
  73250. * Adds action to chain of actions, may be a DoNothingAction
  73251. * @param action defines the next action to execute
  73252. * @returns The action passed in
  73253. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73254. */
  73255. then(action: Action): Action;
  73256. /**
  73257. * Internal only
  73258. * @hidden
  73259. */
  73260. _getProperty(propertyPath: string): string;
  73261. /**
  73262. * Internal only
  73263. * @hidden
  73264. */
  73265. _getEffectiveTarget(target: any, propertyPath: string): any;
  73266. /**
  73267. * Serialize placeholder for child classes
  73268. * @param parent of child
  73269. * @returns the serialized object
  73270. */
  73271. serialize(parent: any): any;
  73272. /**
  73273. * Internal only called by serialize
  73274. * @hidden
  73275. */
  73276. protected _serialize(serializedAction: any, parent?: any): any;
  73277. /**
  73278. * Internal only
  73279. * @hidden
  73280. */
  73281. static _SerializeValueAsString: (value: any) => string;
  73282. /**
  73283. * Internal only
  73284. * @hidden
  73285. */
  73286. static _GetTargetProperty: (target: Scene | Node) => {
  73287. name: string;
  73288. targetType: string;
  73289. value: string;
  73290. };
  73291. }
  73292. }
  73293. declare module BABYLON {
  73294. /**
  73295. * A Condition applied to an Action
  73296. */
  73297. export class Condition {
  73298. /**
  73299. * Internal only - manager for action
  73300. * @hidden
  73301. */
  73302. _actionManager: ActionManager;
  73303. /**
  73304. * Internal only
  73305. * @hidden
  73306. */
  73307. _evaluationId: number;
  73308. /**
  73309. * Internal only
  73310. * @hidden
  73311. */
  73312. _currentResult: boolean;
  73313. /**
  73314. * Creates a new Condition
  73315. * @param actionManager the manager of the action the condition is applied to
  73316. */
  73317. constructor(actionManager: ActionManager);
  73318. /**
  73319. * Check if the current condition is valid
  73320. * @returns a boolean
  73321. */
  73322. isValid(): boolean;
  73323. /**
  73324. * Internal only
  73325. * @hidden
  73326. */
  73327. _getProperty(propertyPath: string): string;
  73328. /**
  73329. * Internal only
  73330. * @hidden
  73331. */
  73332. _getEffectiveTarget(target: any, propertyPath: string): any;
  73333. /**
  73334. * Serialize placeholder for child classes
  73335. * @returns the serialized object
  73336. */
  73337. serialize(): any;
  73338. /**
  73339. * Internal only
  73340. * @hidden
  73341. */
  73342. protected _serialize(serializedCondition: any): any;
  73343. }
  73344. /**
  73345. * Defines specific conditional operators as extensions of Condition
  73346. */
  73347. export class ValueCondition extends Condition {
  73348. /** path to specify the property of the target the conditional operator uses */
  73349. propertyPath: string;
  73350. /** the value compared by the conditional operator against the current value of the property */
  73351. value: any;
  73352. /** the conditional operator, default ValueCondition.IsEqual */
  73353. operator: number;
  73354. /**
  73355. * Internal only
  73356. * @hidden
  73357. */
  73358. private static _IsEqual;
  73359. /**
  73360. * Internal only
  73361. * @hidden
  73362. */
  73363. private static _IsDifferent;
  73364. /**
  73365. * Internal only
  73366. * @hidden
  73367. */
  73368. private static _IsGreater;
  73369. /**
  73370. * Internal only
  73371. * @hidden
  73372. */
  73373. private static _IsLesser;
  73374. /**
  73375. * returns the number for IsEqual
  73376. */
  73377. static readonly IsEqual: number;
  73378. /**
  73379. * Returns the number for IsDifferent
  73380. */
  73381. static readonly IsDifferent: number;
  73382. /**
  73383. * Returns the number for IsGreater
  73384. */
  73385. static readonly IsGreater: number;
  73386. /**
  73387. * Returns the number for IsLesser
  73388. */
  73389. static readonly IsLesser: number;
  73390. /**
  73391. * Internal only The action manager for the condition
  73392. * @hidden
  73393. */
  73394. _actionManager: ActionManager;
  73395. /**
  73396. * Internal only
  73397. * @hidden
  73398. */
  73399. private _target;
  73400. /**
  73401. * Internal only
  73402. * @hidden
  73403. */
  73404. private _effectiveTarget;
  73405. /**
  73406. * Internal only
  73407. * @hidden
  73408. */
  73409. private _property;
  73410. /**
  73411. * Creates a new ValueCondition
  73412. * @param actionManager manager for the action the condition applies to
  73413. * @param target for the action
  73414. * @param propertyPath path to specify the property of the target the conditional operator uses
  73415. * @param value the value compared by the conditional operator against the current value of the property
  73416. * @param operator the conditional operator, default ValueCondition.IsEqual
  73417. */
  73418. constructor(actionManager: ActionManager, target: any,
  73419. /** path to specify the property of the target the conditional operator uses */
  73420. propertyPath: string,
  73421. /** the value compared by the conditional operator against the current value of the property */
  73422. value: any,
  73423. /** the conditional operator, default ValueCondition.IsEqual */
  73424. operator?: number);
  73425. /**
  73426. * Compares the given value with the property value for the specified conditional operator
  73427. * @returns the result of the comparison
  73428. */
  73429. isValid(): boolean;
  73430. /**
  73431. * Serialize the ValueCondition into a JSON compatible object
  73432. * @returns serialization object
  73433. */
  73434. serialize(): any;
  73435. /**
  73436. * Gets the name of the conditional operator for the ValueCondition
  73437. * @param operator the conditional operator
  73438. * @returns the name
  73439. */
  73440. static GetOperatorName(operator: number): string;
  73441. }
  73442. /**
  73443. * Defines a predicate condition as an extension of Condition
  73444. */
  73445. export class PredicateCondition extends Condition {
  73446. /** defines the predicate function used to validate the condition */
  73447. predicate: () => boolean;
  73448. /**
  73449. * Internal only - manager for action
  73450. * @hidden
  73451. */
  73452. _actionManager: ActionManager;
  73453. /**
  73454. * Creates a new PredicateCondition
  73455. * @param actionManager manager for the action the condition applies to
  73456. * @param predicate defines the predicate function used to validate the condition
  73457. */
  73458. constructor(actionManager: ActionManager,
  73459. /** defines the predicate function used to validate the condition */
  73460. predicate: () => boolean);
  73461. /**
  73462. * @returns the validity of the predicate condition
  73463. */
  73464. isValid(): boolean;
  73465. }
  73466. /**
  73467. * Defines a state condition as an extension of Condition
  73468. */
  73469. export class StateCondition extends Condition {
  73470. /** Value to compare with target state */
  73471. value: string;
  73472. /**
  73473. * Internal only - manager for action
  73474. * @hidden
  73475. */
  73476. _actionManager: ActionManager;
  73477. /**
  73478. * Internal only
  73479. * @hidden
  73480. */
  73481. private _target;
  73482. /**
  73483. * Creates a new StateCondition
  73484. * @param actionManager manager for the action the condition applies to
  73485. * @param target of the condition
  73486. * @param value to compare with target state
  73487. */
  73488. constructor(actionManager: ActionManager, target: any,
  73489. /** Value to compare with target state */
  73490. value: string);
  73491. /**
  73492. * Gets a boolean indicating if the current condition is met
  73493. * @returns the validity of the state
  73494. */
  73495. isValid(): boolean;
  73496. /**
  73497. * Serialize the StateCondition into a JSON compatible object
  73498. * @returns serialization object
  73499. */
  73500. serialize(): any;
  73501. }
  73502. }
  73503. declare module BABYLON {
  73504. /**
  73505. * This defines an action responsible to toggle a boolean once triggered.
  73506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73507. */
  73508. export class SwitchBooleanAction extends Action {
  73509. /**
  73510. * The path to the boolean property in the target object
  73511. */
  73512. propertyPath: string;
  73513. private _target;
  73514. private _effectiveTarget;
  73515. private _property;
  73516. /**
  73517. * Instantiate the action
  73518. * @param triggerOptions defines the trigger options
  73519. * @param target defines the object containing the boolean
  73520. * @param propertyPath defines the path to the boolean property in the target object
  73521. * @param condition defines the trigger related conditions
  73522. */
  73523. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  73524. /** @hidden */
  73525. _prepare(): void;
  73526. /**
  73527. * Execute the action toggle the boolean value.
  73528. */
  73529. execute(): void;
  73530. /**
  73531. * Serializes the actions and its related information.
  73532. * @param parent defines the object to serialize in
  73533. * @returns the serialized object
  73534. */
  73535. serialize(parent: any): any;
  73536. }
  73537. /**
  73538. * This defines an action responsible to set a the state field of the target
  73539. * to a desired value once triggered.
  73540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73541. */
  73542. export class SetStateAction extends Action {
  73543. /**
  73544. * The value to store in the state field.
  73545. */
  73546. value: string;
  73547. private _target;
  73548. /**
  73549. * Instantiate the action
  73550. * @param triggerOptions defines the trigger options
  73551. * @param target defines the object containing the state property
  73552. * @param value defines the value to store in the state field
  73553. * @param condition defines the trigger related conditions
  73554. */
  73555. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  73556. /**
  73557. * Execute the action and store the value on the target state property.
  73558. */
  73559. execute(): void;
  73560. /**
  73561. * Serializes the actions and its related information.
  73562. * @param parent defines the object to serialize in
  73563. * @returns the serialized object
  73564. */
  73565. serialize(parent: any): any;
  73566. }
  73567. /**
  73568. * This defines an action responsible to set a property of the target
  73569. * to a desired value once triggered.
  73570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73571. */
  73572. export class SetValueAction extends Action {
  73573. /**
  73574. * The path of the property to set in the target.
  73575. */
  73576. propertyPath: string;
  73577. /**
  73578. * The value to set in the property
  73579. */
  73580. value: any;
  73581. private _target;
  73582. private _effectiveTarget;
  73583. private _property;
  73584. /**
  73585. * Instantiate the action
  73586. * @param triggerOptions defines the trigger options
  73587. * @param target defines the object containing the property
  73588. * @param propertyPath defines the path of the property to set in the target
  73589. * @param value defines the value to set in the property
  73590. * @param condition defines the trigger related conditions
  73591. */
  73592. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73593. /** @hidden */
  73594. _prepare(): void;
  73595. /**
  73596. * Execute the action and set the targetted property to the desired value.
  73597. */
  73598. execute(): void;
  73599. /**
  73600. * Serializes the actions and its related information.
  73601. * @param parent defines the object to serialize in
  73602. * @returns the serialized object
  73603. */
  73604. serialize(parent: any): any;
  73605. }
  73606. /**
  73607. * This defines an action responsible to increment the target value
  73608. * to a desired value once triggered.
  73609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73610. */
  73611. export class IncrementValueAction extends Action {
  73612. /**
  73613. * The path of the property to increment in the target.
  73614. */
  73615. propertyPath: string;
  73616. /**
  73617. * The value we should increment the property by.
  73618. */
  73619. value: any;
  73620. private _target;
  73621. private _effectiveTarget;
  73622. private _property;
  73623. /**
  73624. * Instantiate the action
  73625. * @param triggerOptions defines the trigger options
  73626. * @param target defines the object containing the property
  73627. * @param propertyPath defines the path of the property to increment in the target
  73628. * @param value defines the value value we should increment the property by
  73629. * @param condition defines the trigger related conditions
  73630. */
  73631. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73632. /** @hidden */
  73633. _prepare(): void;
  73634. /**
  73635. * Execute the action and increment the target of the value amount.
  73636. */
  73637. execute(): void;
  73638. /**
  73639. * Serializes the actions and its related information.
  73640. * @param parent defines the object to serialize in
  73641. * @returns the serialized object
  73642. */
  73643. serialize(parent: any): any;
  73644. }
  73645. /**
  73646. * This defines an action responsible to start an animation once triggered.
  73647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73648. */
  73649. export class PlayAnimationAction extends Action {
  73650. /**
  73651. * Where the animation should start (animation frame)
  73652. */
  73653. from: number;
  73654. /**
  73655. * Where the animation should stop (animation frame)
  73656. */
  73657. to: number;
  73658. /**
  73659. * Define if the animation should loop or stop after the first play.
  73660. */
  73661. loop?: boolean;
  73662. private _target;
  73663. /**
  73664. * Instantiate the action
  73665. * @param triggerOptions defines the trigger options
  73666. * @param target defines the target animation or animation name
  73667. * @param from defines from where the animation should start (animation frame)
  73668. * @param end defines where the animation should stop (animation frame)
  73669. * @param loop defines if the animation should loop or stop after the first play
  73670. * @param condition defines the trigger related conditions
  73671. */
  73672. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  73673. /** @hidden */
  73674. _prepare(): void;
  73675. /**
  73676. * Execute the action and play the animation.
  73677. */
  73678. execute(): void;
  73679. /**
  73680. * Serializes the actions and its related information.
  73681. * @param parent defines the object to serialize in
  73682. * @returns the serialized object
  73683. */
  73684. serialize(parent: any): any;
  73685. }
  73686. /**
  73687. * This defines an action responsible to stop an animation once triggered.
  73688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73689. */
  73690. export class StopAnimationAction extends Action {
  73691. private _target;
  73692. /**
  73693. * Instantiate the action
  73694. * @param triggerOptions defines the trigger options
  73695. * @param target defines the target animation or animation name
  73696. * @param condition defines the trigger related conditions
  73697. */
  73698. constructor(triggerOptions: any, target: any, condition?: Condition);
  73699. /** @hidden */
  73700. _prepare(): void;
  73701. /**
  73702. * Execute the action and stop the animation.
  73703. */
  73704. execute(): void;
  73705. /**
  73706. * Serializes the actions and its related information.
  73707. * @param parent defines the object to serialize in
  73708. * @returns the serialized object
  73709. */
  73710. serialize(parent: any): any;
  73711. }
  73712. /**
  73713. * This defines an action responsible that does nothing once triggered.
  73714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73715. */
  73716. export class DoNothingAction extends Action {
  73717. /**
  73718. * Instantiate the action
  73719. * @param triggerOptions defines the trigger options
  73720. * @param condition defines the trigger related conditions
  73721. */
  73722. constructor(triggerOptions?: any, condition?: Condition);
  73723. /**
  73724. * Execute the action and do nothing.
  73725. */
  73726. execute(): void;
  73727. /**
  73728. * Serializes the actions and its related information.
  73729. * @param parent defines the object to serialize in
  73730. * @returns the serialized object
  73731. */
  73732. serialize(parent: any): any;
  73733. }
  73734. /**
  73735. * This defines an action responsible to trigger several actions once triggered.
  73736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73737. */
  73738. export class CombineAction extends Action {
  73739. /**
  73740. * The list of aggregated animations to run.
  73741. */
  73742. children: Action[];
  73743. /**
  73744. * Instantiate the action
  73745. * @param triggerOptions defines the trigger options
  73746. * @param children defines the list of aggregated animations to run
  73747. * @param condition defines the trigger related conditions
  73748. */
  73749. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  73750. /** @hidden */
  73751. _prepare(): void;
  73752. /**
  73753. * Execute the action and executes all the aggregated actions.
  73754. */
  73755. execute(evt: ActionEvent): void;
  73756. /**
  73757. * Serializes the actions and its related information.
  73758. * @param parent defines the object to serialize in
  73759. * @returns the serialized object
  73760. */
  73761. serialize(parent: any): any;
  73762. }
  73763. /**
  73764. * This defines an action responsible to run code (external event) once triggered.
  73765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73766. */
  73767. export class ExecuteCodeAction extends Action {
  73768. /**
  73769. * The callback function to run.
  73770. */
  73771. func: (evt: ActionEvent) => void;
  73772. /**
  73773. * Instantiate the action
  73774. * @param triggerOptions defines the trigger options
  73775. * @param func defines the callback function to run
  73776. * @param condition defines the trigger related conditions
  73777. */
  73778. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  73779. /**
  73780. * Execute the action and run the attached code.
  73781. */
  73782. execute(evt: ActionEvent): void;
  73783. }
  73784. /**
  73785. * This defines an action responsible to set the parent property of the target once triggered.
  73786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73787. */
  73788. export class SetParentAction extends Action {
  73789. private _parent;
  73790. private _target;
  73791. /**
  73792. * Instantiate the action
  73793. * @param triggerOptions defines the trigger options
  73794. * @param target defines the target containing the parent property
  73795. * @param parent defines from where the animation should start (animation frame)
  73796. * @param condition defines the trigger related conditions
  73797. */
  73798. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  73799. /** @hidden */
  73800. _prepare(): void;
  73801. /**
  73802. * Execute the action and set the parent property.
  73803. */
  73804. execute(): void;
  73805. /**
  73806. * Serializes the actions and its related information.
  73807. * @param parent defines the object to serialize in
  73808. * @returns the serialized object
  73809. */
  73810. serialize(parent: any): any;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  73816. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  73817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73818. */
  73819. export class ActionManager extends AbstractActionManager {
  73820. /**
  73821. * Nothing
  73822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73823. */
  73824. static readonly NothingTrigger: number;
  73825. /**
  73826. * On pick
  73827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73828. */
  73829. static readonly OnPickTrigger: number;
  73830. /**
  73831. * On left pick
  73832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73833. */
  73834. static readonly OnLeftPickTrigger: number;
  73835. /**
  73836. * On right pick
  73837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73838. */
  73839. static readonly OnRightPickTrigger: number;
  73840. /**
  73841. * On center pick
  73842. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73843. */
  73844. static readonly OnCenterPickTrigger: number;
  73845. /**
  73846. * On pick down
  73847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73848. */
  73849. static readonly OnPickDownTrigger: number;
  73850. /**
  73851. * On double pick
  73852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73853. */
  73854. static readonly OnDoublePickTrigger: number;
  73855. /**
  73856. * On pick up
  73857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73858. */
  73859. static readonly OnPickUpTrigger: number;
  73860. /**
  73861. * On pick out.
  73862. * This trigger will only be raised if you also declared a OnPickDown
  73863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73864. */
  73865. static readonly OnPickOutTrigger: number;
  73866. /**
  73867. * On long press
  73868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73869. */
  73870. static readonly OnLongPressTrigger: number;
  73871. /**
  73872. * On pointer over
  73873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73874. */
  73875. static readonly OnPointerOverTrigger: number;
  73876. /**
  73877. * On pointer out
  73878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73879. */
  73880. static readonly OnPointerOutTrigger: number;
  73881. /**
  73882. * On every frame
  73883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73884. */
  73885. static readonly OnEveryFrameTrigger: number;
  73886. /**
  73887. * On intersection enter
  73888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73889. */
  73890. static readonly OnIntersectionEnterTrigger: number;
  73891. /**
  73892. * On intersection exit
  73893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73894. */
  73895. static readonly OnIntersectionExitTrigger: number;
  73896. /**
  73897. * On key down
  73898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73899. */
  73900. static readonly OnKeyDownTrigger: number;
  73901. /**
  73902. * On key up
  73903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73904. */
  73905. static readonly OnKeyUpTrigger: number;
  73906. private _scene;
  73907. /**
  73908. * Creates a new action manager
  73909. * @param scene defines the hosting scene
  73910. */
  73911. constructor(scene: Scene);
  73912. /**
  73913. * Releases all associated resources
  73914. */
  73915. dispose(): void;
  73916. /**
  73917. * Gets hosting scene
  73918. * @returns the hosting scene
  73919. */
  73920. getScene(): Scene;
  73921. /**
  73922. * Does this action manager handles actions of any of the given triggers
  73923. * @param triggers defines the triggers to be tested
  73924. * @return a boolean indicating whether one (or more) of the triggers is handled
  73925. */
  73926. hasSpecificTriggers(triggers: number[]): boolean;
  73927. /**
  73928. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  73929. * speed.
  73930. * @param triggerA defines the trigger to be tested
  73931. * @param triggerB defines the trigger to be tested
  73932. * @return a boolean indicating whether one (or more) of the triggers is handled
  73933. */
  73934. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  73935. /**
  73936. * Does this action manager handles actions of a given trigger
  73937. * @param trigger defines the trigger to be tested
  73938. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  73939. * @return whether the trigger is handled
  73940. */
  73941. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  73942. /**
  73943. * Does this action manager has pointer triggers
  73944. */
  73945. readonly hasPointerTriggers: boolean;
  73946. /**
  73947. * Does this action manager has pick triggers
  73948. */
  73949. readonly hasPickTriggers: boolean;
  73950. /**
  73951. * Registers an action to this action manager
  73952. * @param action defines the action to be registered
  73953. * @return the action amended (prepared) after registration
  73954. */
  73955. registerAction(action: IAction): Nullable<IAction>;
  73956. /**
  73957. * Unregisters an action to this action manager
  73958. * @param action defines the action to be unregistered
  73959. * @return a boolean indicating whether the action has been unregistered
  73960. */
  73961. unregisterAction(action: IAction): Boolean;
  73962. /**
  73963. * Process a specific trigger
  73964. * @param trigger defines the trigger to process
  73965. * @param evt defines the event details to be processed
  73966. */
  73967. processTrigger(trigger: number, evt?: IActionEvent): void;
  73968. /** @hidden */
  73969. _getEffectiveTarget(target: any, propertyPath: string): any;
  73970. /** @hidden */
  73971. _getProperty(propertyPath: string): string;
  73972. /**
  73973. * Serialize this manager to a JSON object
  73974. * @param name defines the property name to store this manager
  73975. * @returns a JSON representation of this manager
  73976. */
  73977. serialize(name: string): any;
  73978. /**
  73979. * Creates a new ActionManager from a JSON data
  73980. * @param parsedActions defines the JSON data to read from
  73981. * @param object defines the hosting mesh
  73982. * @param scene defines the hosting scene
  73983. */
  73984. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  73985. /**
  73986. * Get a trigger name by index
  73987. * @param trigger defines the trigger index
  73988. * @returns a trigger name
  73989. */
  73990. static GetTriggerName(trigger: number): string;
  73991. }
  73992. }
  73993. declare module BABYLON {
  73994. /**
  73995. * Class representing a ray with position and direction
  73996. */
  73997. export class Ray {
  73998. /** origin point */
  73999. origin: Vector3;
  74000. /** direction */
  74001. direction: Vector3;
  74002. /** length of the ray */
  74003. length: number;
  74004. private static readonly TmpVector3;
  74005. private _tmpRay;
  74006. /**
  74007. * Creates a new ray
  74008. * @param origin origin point
  74009. * @param direction direction
  74010. * @param length length of the ray
  74011. */
  74012. constructor(
  74013. /** origin point */
  74014. origin: Vector3,
  74015. /** direction */
  74016. direction: Vector3,
  74017. /** length of the ray */
  74018. length?: number);
  74019. /**
  74020. * Checks if the ray intersects a box
  74021. * @param minimum bound of the box
  74022. * @param maximum bound of the box
  74023. * @param intersectionTreshold extra extend to be added to the box in all direction
  74024. * @returns if the box was hit
  74025. */
  74026. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74027. /**
  74028. * Checks if the ray intersects a box
  74029. * @param box the bounding box to check
  74030. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74031. * @returns if the box was hit
  74032. */
  74033. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74034. /**
  74035. * If the ray hits a sphere
  74036. * @param sphere the bounding sphere to check
  74037. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74038. * @returns true if it hits the sphere
  74039. */
  74040. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74041. /**
  74042. * If the ray hits a triange
  74043. * @param vertex0 triangle vertex
  74044. * @param vertex1 triangle vertex
  74045. * @param vertex2 triangle vertex
  74046. * @returns intersection information if hit
  74047. */
  74048. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74049. /**
  74050. * Checks if ray intersects a plane
  74051. * @param plane the plane to check
  74052. * @returns the distance away it was hit
  74053. */
  74054. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74055. /**
  74056. * Checks if ray intersects a mesh
  74057. * @param mesh the mesh to check
  74058. * @param fastCheck if only the bounding box should checked
  74059. * @returns picking info of the intersecton
  74060. */
  74061. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74062. /**
  74063. * Checks if ray intersects a mesh
  74064. * @param meshes the meshes to check
  74065. * @param fastCheck if only the bounding box should checked
  74066. * @param results array to store result in
  74067. * @returns Array of picking infos
  74068. */
  74069. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74070. private _comparePickingInfo;
  74071. private static smallnum;
  74072. private static rayl;
  74073. /**
  74074. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74075. * @param sega the first point of the segment to test the intersection against
  74076. * @param segb the second point of the segment to test the intersection against
  74077. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74078. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74079. */
  74080. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74081. /**
  74082. * Update the ray from viewport position
  74083. * @param x position
  74084. * @param y y position
  74085. * @param viewportWidth viewport width
  74086. * @param viewportHeight viewport height
  74087. * @param world world matrix
  74088. * @param view view matrix
  74089. * @param projection projection matrix
  74090. * @returns this ray updated
  74091. */
  74092. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74093. /**
  74094. * Creates a ray with origin and direction of 0,0,0
  74095. * @returns the new ray
  74096. */
  74097. static Zero(): Ray;
  74098. /**
  74099. * Creates a new ray from screen space and viewport
  74100. * @param x position
  74101. * @param y y position
  74102. * @param viewportWidth viewport width
  74103. * @param viewportHeight viewport height
  74104. * @param world world matrix
  74105. * @param view view matrix
  74106. * @param projection projection matrix
  74107. * @returns new ray
  74108. */
  74109. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74110. /**
  74111. * 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
  74112. * transformed to the given world matrix.
  74113. * @param origin The origin point
  74114. * @param end The end point
  74115. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74116. * @returns the new ray
  74117. */
  74118. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74119. /**
  74120. * Transforms a ray by a matrix
  74121. * @param ray ray to transform
  74122. * @param matrix matrix to apply
  74123. * @returns the resulting new ray
  74124. */
  74125. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74126. /**
  74127. * Transforms a ray by a matrix
  74128. * @param ray ray to transform
  74129. * @param matrix matrix to apply
  74130. * @param result ray to store result in
  74131. */
  74132. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74133. /**
  74134. * Unproject a ray from screen space to object space
  74135. * @param sourceX defines the screen space x coordinate to use
  74136. * @param sourceY defines the screen space y coordinate to use
  74137. * @param viewportWidth defines the current width of the viewport
  74138. * @param viewportHeight defines the current height of the viewport
  74139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74140. * @param view defines the view matrix to use
  74141. * @param projection defines the projection matrix to use
  74142. */
  74143. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74144. }
  74145. /**
  74146. * Type used to define predicate used to select faces when a mesh intersection is detected
  74147. */
  74148. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74149. interface Scene {
  74150. /** @hidden */
  74151. _tempPickingRay: Nullable<Ray>;
  74152. /** @hidden */
  74153. _cachedRayForTransform: Ray;
  74154. /** @hidden */
  74155. _pickWithRayInverseMatrix: Matrix;
  74156. /** @hidden */
  74157. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74158. /** @hidden */
  74159. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74160. }
  74161. }
  74162. declare module BABYLON {
  74163. /**
  74164. * Groups all the scene component constants in one place to ease maintenance.
  74165. * @hidden
  74166. */
  74167. export class SceneComponentConstants {
  74168. static readonly NAME_EFFECTLAYER: string;
  74169. static readonly NAME_LAYER: string;
  74170. static readonly NAME_LENSFLARESYSTEM: string;
  74171. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74172. static readonly NAME_PARTICLESYSTEM: string;
  74173. static readonly NAME_GAMEPAD: string;
  74174. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74175. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74176. static readonly NAME_DEPTHRENDERER: string;
  74177. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74178. static readonly NAME_SPRITE: string;
  74179. static readonly NAME_OUTLINERENDERER: string;
  74180. static readonly NAME_PROCEDURALTEXTURE: string;
  74181. static readonly NAME_SHADOWGENERATOR: string;
  74182. static readonly NAME_OCTREE: string;
  74183. static readonly NAME_PHYSICSENGINE: string;
  74184. static readonly NAME_AUDIO: string;
  74185. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74186. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74187. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74188. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74189. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74190. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74191. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74192. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74193. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74194. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74195. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74196. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74197. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74198. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74199. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74200. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74201. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74202. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74204. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74205. static readonly STEP_AFTERRENDER_AUDIO: number;
  74206. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74207. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74208. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74209. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74210. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74211. static readonly STEP_POINTERMOVE_SPRITE: number;
  74212. static readonly STEP_POINTERDOWN_SPRITE: number;
  74213. static readonly STEP_POINTERUP_SPRITE: number;
  74214. }
  74215. /**
  74216. * This represents a scene component.
  74217. *
  74218. * This is used to decouple the dependency the scene is having on the different workloads like
  74219. * layers, post processes...
  74220. */
  74221. export interface ISceneComponent {
  74222. /**
  74223. * The name of the component. Each component must have a unique name.
  74224. */
  74225. name: string;
  74226. /**
  74227. * The scene the component belongs to.
  74228. */
  74229. scene: Scene;
  74230. /**
  74231. * Register the component to one instance of a scene.
  74232. */
  74233. register(): void;
  74234. /**
  74235. * Rebuilds the elements related to this component in case of
  74236. * context lost for instance.
  74237. */
  74238. rebuild(): void;
  74239. /**
  74240. * Disposes the component and the associated ressources.
  74241. */
  74242. dispose(): void;
  74243. }
  74244. /**
  74245. * This represents a SERIALIZABLE scene component.
  74246. *
  74247. * This extends Scene Component to add Serialization methods on top.
  74248. */
  74249. export interface ISceneSerializableComponent extends ISceneComponent {
  74250. /**
  74251. * Adds all the elements from the container to the scene
  74252. * @param container the container holding the elements
  74253. */
  74254. addFromContainer(container: AbstractScene): void;
  74255. /**
  74256. * Removes all the elements in the container from the scene
  74257. * @param container contains the elements to remove
  74258. * @param dispose if the removed element should be disposed (default: false)
  74259. */
  74260. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74261. /**
  74262. * Serializes the component data to the specified json object
  74263. * @param serializationObject The object to serialize to
  74264. */
  74265. serialize(serializationObject: any): void;
  74266. }
  74267. /**
  74268. * Strong typing of a Mesh related stage step action
  74269. */
  74270. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74271. /**
  74272. * Strong typing of a Evaluate Sub Mesh related stage step action
  74273. */
  74274. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74275. /**
  74276. * Strong typing of a Active Mesh related stage step action
  74277. */
  74278. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74279. /**
  74280. * Strong typing of a Camera related stage step action
  74281. */
  74282. export type CameraStageAction = (camera: Camera) => void;
  74283. /**
  74284. * Strong typing of a Camera Frame buffer related stage step action
  74285. */
  74286. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74287. /**
  74288. * Strong typing of a Render Target related stage step action
  74289. */
  74290. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74291. /**
  74292. * Strong typing of a RenderingGroup related stage step action
  74293. */
  74294. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74295. /**
  74296. * Strong typing of a Mesh Render related stage step action
  74297. */
  74298. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74299. /**
  74300. * Strong typing of a simple stage step action
  74301. */
  74302. export type SimpleStageAction = () => void;
  74303. /**
  74304. * Strong typing of a render target action.
  74305. */
  74306. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74307. /**
  74308. * Strong typing of a pointer move action.
  74309. */
  74310. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74311. /**
  74312. * Strong typing of a pointer up/down action.
  74313. */
  74314. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74315. /**
  74316. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74317. * @hidden
  74318. */
  74319. export class Stage<T extends Function> extends Array<{
  74320. index: number;
  74321. component: ISceneComponent;
  74322. action: T;
  74323. }> {
  74324. /**
  74325. * Hide ctor from the rest of the world.
  74326. * @param items The items to add.
  74327. */
  74328. private constructor();
  74329. /**
  74330. * Creates a new Stage.
  74331. * @returns A new instance of a Stage
  74332. */
  74333. static Create<T extends Function>(): Stage<T>;
  74334. /**
  74335. * Registers a step in an ordered way in the targeted stage.
  74336. * @param index Defines the position to register the step in
  74337. * @param component Defines the component attached to the step
  74338. * @param action Defines the action to launch during the step
  74339. */
  74340. registerStep(index: number, component: ISceneComponent, action: T): void;
  74341. /**
  74342. * Clears all the steps from the stage.
  74343. */
  74344. clear(): void;
  74345. }
  74346. }
  74347. declare module BABYLON {
  74348. interface Scene {
  74349. /** @hidden */
  74350. _pointerOverSprite: Nullable<Sprite>;
  74351. /** @hidden */
  74352. _pickedDownSprite: Nullable<Sprite>;
  74353. /** @hidden */
  74354. _tempSpritePickingRay: Nullable<Ray>;
  74355. /**
  74356. * All of the sprite managers added to this scene
  74357. * @see http://doc.babylonjs.com/babylon101/sprites
  74358. */
  74359. spriteManagers: Array<ISpriteManager>;
  74360. /**
  74361. * An event triggered when sprites rendering is about to start
  74362. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74363. */
  74364. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74365. /**
  74366. * An event triggered when sprites rendering is done
  74367. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74368. */
  74369. onAfterSpritesRenderingObservable: Observable<Scene>;
  74370. /** @hidden */
  74371. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74372. /** Launch a ray to try to pick a sprite in the scene
  74373. * @param x position on screen
  74374. * @param y position on screen
  74375. * @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
  74376. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74377. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74378. * @returns a PickingInfo
  74379. */
  74380. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74381. /** Use the given ray to pick a sprite in the scene
  74382. * @param ray The ray (in world space) to use to pick meshes
  74383. * @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
  74384. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74385. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74386. * @returns a PickingInfo
  74387. */
  74388. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74389. /**
  74390. * Force the sprite under the pointer
  74391. * @param sprite defines the sprite to use
  74392. */
  74393. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74394. /**
  74395. * Gets the sprite under the pointer
  74396. * @returns a Sprite or null if no sprite is under the pointer
  74397. */
  74398. getPointerOverSprite(): Nullable<Sprite>;
  74399. }
  74400. /**
  74401. * Defines the sprite scene component responsible to manage sprites
  74402. * in a given scene.
  74403. */
  74404. export class SpriteSceneComponent implements ISceneComponent {
  74405. /**
  74406. * The component name helpfull to identify the component in the list of scene components.
  74407. */
  74408. readonly name: string;
  74409. /**
  74410. * The scene the component belongs to.
  74411. */
  74412. scene: Scene;
  74413. /** @hidden */
  74414. private _spritePredicate;
  74415. /**
  74416. * Creates a new instance of the component for the given scene
  74417. * @param scene Defines the scene to register the component in
  74418. */
  74419. constructor(scene: Scene);
  74420. /**
  74421. * Registers the component in a given scene
  74422. */
  74423. register(): void;
  74424. /**
  74425. * Rebuilds the elements related to this component in case of
  74426. * context lost for instance.
  74427. */
  74428. rebuild(): void;
  74429. /**
  74430. * Disposes the component and the associated ressources.
  74431. */
  74432. dispose(): void;
  74433. private _pickSpriteButKeepRay;
  74434. private _pointerMove;
  74435. private _pointerDown;
  74436. private _pointerUp;
  74437. }
  74438. }
  74439. declare module BABYLON {
  74440. /** @hidden */
  74441. export var fogFragmentDeclaration: {
  74442. name: string;
  74443. shader: string;
  74444. };
  74445. }
  74446. declare module BABYLON {
  74447. /** @hidden */
  74448. export var fogFragment: {
  74449. name: string;
  74450. shader: string;
  74451. };
  74452. }
  74453. declare module BABYLON {
  74454. /** @hidden */
  74455. export var spritesPixelShader: {
  74456. name: string;
  74457. shader: string;
  74458. };
  74459. }
  74460. declare module BABYLON {
  74461. /** @hidden */
  74462. export var fogVertexDeclaration: {
  74463. name: string;
  74464. shader: string;
  74465. };
  74466. }
  74467. declare module BABYLON {
  74468. /** @hidden */
  74469. export var spritesVertexShader: {
  74470. name: string;
  74471. shader: string;
  74472. };
  74473. }
  74474. declare module BABYLON {
  74475. /**
  74476. * Defines the minimum interface to fullfil in order to be a sprite manager.
  74477. */
  74478. export interface ISpriteManager extends IDisposable {
  74479. /**
  74480. * Restricts the camera to viewing objects with the same layerMask.
  74481. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  74482. */
  74483. layerMask: number;
  74484. /**
  74485. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74486. */
  74487. isPickable: boolean;
  74488. /**
  74489. * Specifies the rendering group id for this mesh (0 by default)
  74490. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74491. */
  74492. renderingGroupId: number;
  74493. /**
  74494. * Defines the list of sprites managed by the manager.
  74495. */
  74496. sprites: Array<Sprite>;
  74497. /**
  74498. * Tests the intersection of a sprite with a specific ray.
  74499. * @param ray The ray we are sending to test the collision
  74500. * @param camera The camera space we are sending rays in
  74501. * @param predicate A predicate allowing excluding sprites from the list of object to test
  74502. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  74503. * @returns picking info or null.
  74504. */
  74505. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74506. /**
  74507. * Renders the list of sprites on screen.
  74508. */
  74509. render(): void;
  74510. }
  74511. /**
  74512. * Class used to manage multiple sprites on the same spritesheet
  74513. * @see http://doc.babylonjs.com/babylon101/sprites
  74514. */
  74515. export class SpriteManager implements ISpriteManager {
  74516. /** defines the manager's name */
  74517. name: string;
  74518. /** Gets the list of sprites */
  74519. sprites: Sprite[];
  74520. /** Gets or sets the rendering group id (0 by default) */
  74521. renderingGroupId: number;
  74522. /** Gets or sets camera layer mask */
  74523. layerMask: number;
  74524. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  74525. fogEnabled: boolean;
  74526. /** Gets or sets a boolean indicating if the sprites are pickable */
  74527. isPickable: boolean;
  74528. /** Defines the default width of a cell in the spritesheet */
  74529. cellWidth: number;
  74530. /** Defines the default height of a cell in the spritesheet */
  74531. cellHeight: number;
  74532. /**
  74533. * An event triggered when the manager is disposed.
  74534. */
  74535. onDisposeObservable: Observable<SpriteManager>;
  74536. private _onDisposeObserver;
  74537. /**
  74538. * Callback called when the manager is disposed
  74539. */
  74540. onDispose: () => void;
  74541. private _capacity;
  74542. private _spriteTexture;
  74543. private _epsilon;
  74544. private _scene;
  74545. private _vertexData;
  74546. private _buffer;
  74547. private _vertexBuffers;
  74548. private _indexBuffer;
  74549. private _effectBase;
  74550. private _effectFog;
  74551. /**
  74552. * Gets or sets the spritesheet texture
  74553. */
  74554. texture: Texture;
  74555. /**
  74556. * Creates a new sprite manager
  74557. * @param name defines the manager's name
  74558. * @param imgUrl defines the sprite sheet url
  74559. * @param capacity defines the maximum allowed number of sprites
  74560. * @param cellSize defines the size of a sprite cell
  74561. * @param scene defines the hosting scene
  74562. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74563. * @param samplingMode defines the smapling mode to use with spritesheet
  74564. */
  74565. constructor(
  74566. /** defines the manager's name */
  74567. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  74568. private _appendSpriteVertex;
  74569. /**
  74570. * Intersects the sprites with a ray
  74571. * @param ray defines the ray to intersect with
  74572. * @param camera defines the current active camera
  74573. * @param predicate defines a predicate used to select candidate sprites
  74574. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  74575. * @returns null if no hit or a PickingInfo
  74576. */
  74577. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74578. /**
  74579. * Render all child sprites
  74580. */
  74581. render(): void;
  74582. /**
  74583. * Release associated resources
  74584. */
  74585. dispose(): void;
  74586. }
  74587. }
  74588. declare module BABYLON {
  74589. /**
  74590. * Class used to represent a sprite
  74591. * @see http://doc.babylonjs.com/babylon101/sprites
  74592. */
  74593. export class Sprite {
  74594. /** defines the name */
  74595. name: string;
  74596. /** Gets or sets the current world position */
  74597. position: Vector3;
  74598. /** Gets or sets the main color */
  74599. color: Color4;
  74600. /** Gets or sets the width */
  74601. width: number;
  74602. /** Gets or sets the height */
  74603. height: number;
  74604. /** Gets or sets rotation angle */
  74605. angle: number;
  74606. /** Gets or sets the cell index in the sprite sheet */
  74607. cellIndex: number;
  74608. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  74609. invertU: number;
  74610. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  74611. invertV: number;
  74612. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  74613. disposeWhenFinishedAnimating: boolean;
  74614. /** Gets the list of attached animations */
  74615. animations: Animation[];
  74616. /** Gets or sets a boolean indicating if the sprite can be picked */
  74617. isPickable: boolean;
  74618. /**
  74619. * Gets or sets the associated action manager
  74620. */
  74621. actionManager: Nullable<ActionManager>;
  74622. private _animationStarted;
  74623. private _loopAnimation;
  74624. private _fromIndex;
  74625. private _toIndex;
  74626. private _delay;
  74627. private _direction;
  74628. private _manager;
  74629. private _time;
  74630. private _onAnimationEnd;
  74631. /**
  74632. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  74633. */
  74634. isVisible: boolean;
  74635. /**
  74636. * Gets or sets the sprite size
  74637. */
  74638. size: number;
  74639. /**
  74640. * Creates a new Sprite
  74641. * @param name defines the name
  74642. * @param manager defines the manager
  74643. */
  74644. constructor(
  74645. /** defines the name */
  74646. name: string, manager: ISpriteManager);
  74647. /**
  74648. * Starts an animation
  74649. * @param from defines the initial key
  74650. * @param to defines the end key
  74651. * @param loop defines if the animation must loop
  74652. * @param delay defines the start delay (in ms)
  74653. * @param onAnimationEnd defines a callback to call when animation ends
  74654. */
  74655. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  74656. /** Stops current animation (if any) */
  74657. stopAnimation(): void;
  74658. /** @hidden */
  74659. _animate(deltaTime: number): void;
  74660. /** Release associated resources */
  74661. dispose(): void;
  74662. }
  74663. }
  74664. declare module BABYLON {
  74665. /**
  74666. * Information about the result of picking within a scene
  74667. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  74668. */
  74669. export class PickingInfo {
  74670. /** @hidden */
  74671. _pickingUnavailable: boolean;
  74672. /**
  74673. * If the pick collided with an object
  74674. */
  74675. hit: boolean;
  74676. /**
  74677. * Distance away where the pick collided
  74678. */
  74679. distance: number;
  74680. /**
  74681. * The location of pick collision
  74682. */
  74683. pickedPoint: Nullable<Vector3>;
  74684. /**
  74685. * The mesh corresponding the the pick collision
  74686. */
  74687. pickedMesh: Nullable<AbstractMesh>;
  74688. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  74689. bu: number;
  74690. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  74691. bv: number;
  74692. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  74693. faceId: number;
  74694. /** Id of the the submesh that was picked */
  74695. subMeshId: number;
  74696. /** If a sprite was picked, this will be the sprite the pick collided with */
  74697. pickedSprite: Nullable<Sprite>;
  74698. /**
  74699. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  74700. */
  74701. originMesh: Nullable<AbstractMesh>;
  74702. /**
  74703. * The ray that was used to perform the picking.
  74704. */
  74705. ray: Nullable<Ray>;
  74706. /**
  74707. * Gets the normal correspodning to the face the pick collided with
  74708. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  74709. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  74710. * @returns The normal correspodning to the face the pick collided with
  74711. */
  74712. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  74713. /**
  74714. * Gets the texture coordinates of where the pick occured
  74715. * @returns the vector containing the coordnates of the texture
  74716. */
  74717. getTextureCoordinates(): Nullable<Vector2>;
  74718. }
  74719. }
  74720. declare module BABYLON {
  74721. /**
  74722. * Gather the list of pointer event types as constants.
  74723. */
  74724. export class PointerEventTypes {
  74725. /**
  74726. * 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.
  74727. */
  74728. static readonly POINTERDOWN: number;
  74729. /**
  74730. * The pointerup event is fired when a pointer is no longer active.
  74731. */
  74732. static readonly POINTERUP: number;
  74733. /**
  74734. * The pointermove event is fired when a pointer changes coordinates.
  74735. */
  74736. static readonly POINTERMOVE: number;
  74737. /**
  74738. * The pointerwheel event is fired when a mouse wheel has been rotated.
  74739. */
  74740. static readonly POINTERWHEEL: number;
  74741. /**
  74742. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  74743. */
  74744. static readonly POINTERPICK: number;
  74745. /**
  74746. * The pointertap event is fired when a the object has been touched and released without drag.
  74747. */
  74748. static readonly POINTERTAP: number;
  74749. /**
  74750. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  74751. */
  74752. static readonly POINTERDOUBLETAP: number;
  74753. }
  74754. /**
  74755. * Base class of pointer info types.
  74756. */
  74757. export class PointerInfoBase {
  74758. /**
  74759. * Defines the type of event (PointerEventTypes)
  74760. */
  74761. type: number;
  74762. /**
  74763. * Defines the related dom event
  74764. */
  74765. event: PointerEvent | MouseWheelEvent;
  74766. /**
  74767. * Instantiates the base class of pointers info.
  74768. * @param type Defines the type of event (PointerEventTypes)
  74769. * @param event Defines the related dom event
  74770. */
  74771. constructor(
  74772. /**
  74773. * Defines the type of event (PointerEventTypes)
  74774. */
  74775. type: number,
  74776. /**
  74777. * Defines the related dom event
  74778. */
  74779. event: PointerEvent | MouseWheelEvent);
  74780. }
  74781. /**
  74782. * This class is used to store pointer related info for the onPrePointerObservable event.
  74783. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  74784. */
  74785. export class PointerInfoPre extends PointerInfoBase {
  74786. /**
  74787. * Ray from a pointer if availible (eg. 6dof controller)
  74788. */
  74789. ray: Nullable<Ray>;
  74790. /**
  74791. * Defines the local position of the pointer on the canvas.
  74792. */
  74793. localPosition: Vector2;
  74794. /**
  74795. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  74796. */
  74797. skipOnPointerObservable: boolean;
  74798. /**
  74799. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  74800. * @param type Defines the type of event (PointerEventTypes)
  74801. * @param event Defines the related dom event
  74802. * @param localX Defines the local x coordinates of the pointer when the event occured
  74803. * @param localY Defines the local y coordinates of the pointer when the event occured
  74804. */
  74805. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  74806. }
  74807. /**
  74808. * This type contains all the data related to a pointer event in Babylon.js.
  74809. * 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.
  74810. */
  74811. export class PointerInfo extends PointerInfoBase {
  74812. /**
  74813. * Defines the picking info associated to the info (if any)\
  74814. */
  74815. pickInfo: Nullable<PickingInfo>;
  74816. /**
  74817. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  74818. * @param type Defines the type of event (PointerEventTypes)
  74819. * @param event Defines the related dom event
  74820. * @param pickInfo Defines the picking info associated to the info (if any)\
  74821. */
  74822. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  74823. /**
  74824. * Defines the picking info associated to the info (if any)\
  74825. */
  74826. pickInfo: Nullable<PickingInfo>);
  74827. }
  74828. /**
  74829. * Data relating to a touch event on the screen.
  74830. */
  74831. export interface PointerTouch {
  74832. /**
  74833. * X coordinate of touch.
  74834. */
  74835. x: number;
  74836. /**
  74837. * Y coordinate of touch.
  74838. */
  74839. y: number;
  74840. /**
  74841. * Id of touch. Unique for each finger.
  74842. */
  74843. pointerId: number;
  74844. /**
  74845. * Event type passed from DOM.
  74846. */
  74847. type: any;
  74848. }
  74849. }
  74850. declare module BABYLON {
  74851. /**
  74852. * Manage the mouse inputs to control the movement of a free camera.
  74853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74854. */
  74855. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  74856. /**
  74857. * Define if touch is enabled in the mouse input
  74858. */
  74859. touchEnabled: boolean;
  74860. /**
  74861. * Defines the camera the input is attached to.
  74862. */
  74863. camera: FreeCamera;
  74864. /**
  74865. * Defines the buttons associated with the input to handle camera move.
  74866. */
  74867. buttons: number[];
  74868. /**
  74869. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  74870. */
  74871. angularSensibility: number;
  74872. private _pointerInput;
  74873. private _onMouseMove;
  74874. private _observer;
  74875. private previousPosition;
  74876. /**
  74877. * Observable for when a pointer move event occurs containing the move offset
  74878. */
  74879. onPointerMovedObservable: Observable<{
  74880. offsetX: number;
  74881. offsetY: number;
  74882. }>;
  74883. /**
  74884. * @hidden
  74885. * If the camera should be rotated automatically based on pointer movement
  74886. */
  74887. _allowCameraRotation: boolean;
  74888. /**
  74889. * Manage the mouse inputs to control the movement of a free camera.
  74890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74891. * @param touchEnabled Defines if touch is enabled or not
  74892. */
  74893. constructor(
  74894. /**
  74895. * Define if touch is enabled in the mouse input
  74896. */
  74897. touchEnabled?: boolean);
  74898. /**
  74899. * Attach the input controls to a specific dom element to get the input from.
  74900. * @param element Defines the element the controls should be listened from
  74901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74902. */
  74903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74904. /**
  74905. * Called on JS contextmenu event.
  74906. * Override this method to provide functionality.
  74907. */
  74908. protected onContextMenu(evt: PointerEvent): void;
  74909. /**
  74910. * Detach the current controls from the specified dom element.
  74911. * @param element Defines the element to stop listening the inputs from
  74912. */
  74913. detachControl(element: Nullable<HTMLElement>): void;
  74914. /**
  74915. * Gets the class name of the current intput.
  74916. * @returns the class name
  74917. */
  74918. getClassName(): string;
  74919. /**
  74920. * Get the friendly name associated with the input class.
  74921. * @returns the input friendly name
  74922. */
  74923. getSimpleName(): string;
  74924. }
  74925. }
  74926. declare module BABYLON {
  74927. /**
  74928. * Manage the touch inputs to control the movement of a free camera.
  74929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74930. */
  74931. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  74932. /**
  74933. * Defines the camera the input is attached to.
  74934. */
  74935. camera: FreeCamera;
  74936. /**
  74937. * Defines the touch sensibility for rotation.
  74938. * The higher the faster.
  74939. */
  74940. touchAngularSensibility: number;
  74941. /**
  74942. * Defines the touch sensibility for move.
  74943. * The higher the faster.
  74944. */
  74945. touchMoveSensibility: number;
  74946. private _offsetX;
  74947. private _offsetY;
  74948. private _pointerPressed;
  74949. private _pointerInput;
  74950. private _observer;
  74951. private _onLostFocus;
  74952. /**
  74953. * Attach the input controls to a specific dom element to get the input from.
  74954. * @param element Defines the element the controls should be listened from
  74955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74956. */
  74957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74958. /**
  74959. * Detach the current controls from the specified dom element.
  74960. * @param element Defines the element to stop listening the inputs from
  74961. */
  74962. detachControl(element: Nullable<HTMLElement>): void;
  74963. /**
  74964. * Update the current camera state depending on the inputs that have been used this frame.
  74965. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74966. */
  74967. checkInputs(): void;
  74968. /**
  74969. * Gets the class name of the current intput.
  74970. * @returns the class name
  74971. */
  74972. getClassName(): string;
  74973. /**
  74974. * Get the friendly name associated with the input class.
  74975. * @returns the input friendly name
  74976. */
  74977. getSimpleName(): string;
  74978. }
  74979. }
  74980. declare module BABYLON {
  74981. /**
  74982. * Default Inputs manager for the FreeCamera.
  74983. * It groups all the default supported inputs for ease of use.
  74984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74985. */
  74986. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  74987. /**
  74988. * @hidden
  74989. */
  74990. _mouseInput: Nullable<FreeCameraMouseInput>;
  74991. /**
  74992. * Instantiates a new FreeCameraInputsManager.
  74993. * @param camera Defines the camera the inputs belong to
  74994. */
  74995. constructor(camera: FreeCamera);
  74996. /**
  74997. * Add keyboard input support to the input manager.
  74998. * @returns the current input manager
  74999. */
  75000. addKeyboard(): FreeCameraInputsManager;
  75001. /**
  75002. * Add mouse input support to the input manager.
  75003. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75004. * @returns the current input manager
  75005. */
  75006. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75007. /**
  75008. * Removes the mouse input support from the manager
  75009. * @returns the current input manager
  75010. */
  75011. removeMouse(): FreeCameraInputsManager;
  75012. /**
  75013. * Add touch input support to the input manager.
  75014. * @returns the current input manager
  75015. */
  75016. addTouch(): FreeCameraInputsManager;
  75017. /**
  75018. * Remove all attached input methods from a camera
  75019. */
  75020. clear(): void;
  75021. }
  75022. }
  75023. declare module BABYLON {
  75024. /**
  75025. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75026. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75028. */
  75029. export class FreeCamera extends TargetCamera {
  75030. /**
  75031. * Define the collision ellipsoid of the camera.
  75032. * This is helpful to simulate a camera body like the player body around the camera
  75033. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75034. */
  75035. ellipsoid: Vector3;
  75036. /**
  75037. * Define an offset for the position of the ellipsoid around the camera.
  75038. * This can be helpful to determine the center of the body near the gravity center of the body
  75039. * instead of its head.
  75040. */
  75041. ellipsoidOffset: Vector3;
  75042. /**
  75043. * Enable or disable collisions of the camera with the rest of the scene objects.
  75044. */
  75045. checkCollisions: boolean;
  75046. /**
  75047. * Enable or disable gravity on the camera.
  75048. */
  75049. applyGravity: boolean;
  75050. /**
  75051. * Define the input manager associated to the camera.
  75052. */
  75053. inputs: FreeCameraInputsManager;
  75054. /**
  75055. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75056. * Higher values reduce sensitivity.
  75057. */
  75058. /**
  75059. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75060. * Higher values reduce sensitivity.
  75061. */
  75062. angularSensibility: number;
  75063. /**
  75064. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75065. */
  75066. keysUp: number[];
  75067. /**
  75068. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75069. */
  75070. keysDown: number[];
  75071. /**
  75072. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75073. */
  75074. keysLeft: number[];
  75075. /**
  75076. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75077. */
  75078. keysRight: number[];
  75079. /**
  75080. * Event raised when the camera collide with a mesh in the scene.
  75081. */
  75082. onCollide: (collidedMesh: AbstractMesh) => void;
  75083. private _collider;
  75084. private _needMoveForGravity;
  75085. private _oldPosition;
  75086. private _diffPosition;
  75087. private _newPosition;
  75088. /** @hidden */
  75089. _localDirection: Vector3;
  75090. /** @hidden */
  75091. _transformedDirection: Vector3;
  75092. /**
  75093. * Instantiates a Free Camera.
  75094. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75095. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75096. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75097. * @param name Define the name of the camera in the scene
  75098. * @param position Define the start position of the camera in the scene
  75099. * @param scene Define the scene the camera belongs to
  75100. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75101. */
  75102. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75103. /**
  75104. * Attached controls to the current camera.
  75105. * @param element Defines the element the controls should be listened from
  75106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75107. */
  75108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75109. /**
  75110. * Detach the current controls from the camera.
  75111. * The camera will stop reacting to inputs.
  75112. * @param element Defines the element to stop listening the inputs from
  75113. */
  75114. detachControl(element: HTMLElement): void;
  75115. private _collisionMask;
  75116. /**
  75117. * Define a collision mask to limit the list of object the camera can collide with
  75118. */
  75119. collisionMask: number;
  75120. /** @hidden */
  75121. _collideWithWorld(displacement: Vector3): void;
  75122. private _onCollisionPositionChange;
  75123. /** @hidden */
  75124. _checkInputs(): void;
  75125. /** @hidden */
  75126. _decideIfNeedsToMove(): boolean;
  75127. /** @hidden */
  75128. _updatePosition(): void;
  75129. /**
  75130. * Destroy the camera and release the current resources hold by it.
  75131. */
  75132. dispose(): void;
  75133. /**
  75134. * Gets the current object class name.
  75135. * @return the class name
  75136. */
  75137. getClassName(): string;
  75138. }
  75139. }
  75140. declare module BABYLON {
  75141. /**
  75142. * Represents a gamepad control stick position
  75143. */
  75144. export class StickValues {
  75145. /**
  75146. * The x component of the control stick
  75147. */
  75148. x: number;
  75149. /**
  75150. * The y component of the control stick
  75151. */
  75152. y: number;
  75153. /**
  75154. * Initializes the gamepad x and y control stick values
  75155. * @param x The x component of the gamepad control stick value
  75156. * @param y The y component of the gamepad control stick value
  75157. */
  75158. constructor(
  75159. /**
  75160. * The x component of the control stick
  75161. */
  75162. x: number,
  75163. /**
  75164. * The y component of the control stick
  75165. */
  75166. y: number);
  75167. }
  75168. /**
  75169. * An interface which manages callbacks for gamepad button changes
  75170. */
  75171. export interface GamepadButtonChanges {
  75172. /**
  75173. * Called when a gamepad has been changed
  75174. */
  75175. changed: boolean;
  75176. /**
  75177. * Called when a gamepad press event has been triggered
  75178. */
  75179. pressChanged: boolean;
  75180. /**
  75181. * Called when a touch event has been triggered
  75182. */
  75183. touchChanged: boolean;
  75184. /**
  75185. * Called when a value has changed
  75186. */
  75187. valueChanged: boolean;
  75188. }
  75189. /**
  75190. * Represents a gamepad
  75191. */
  75192. export class Gamepad {
  75193. /**
  75194. * The id of the gamepad
  75195. */
  75196. id: string;
  75197. /**
  75198. * The index of the gamepad
  75199. */
  75200. index: number;
  75201. /**
  75202. * The browser gamepad
  75203. */
  75204. browserGamepad: any;
  75205. /**
  75206. * Specifies what type of gamepad this represents
  75207. */
  75208. type: number;
  75209. private _leftStick;
  75210. private _rightStick;
  75211. /** @hidden */
  75212. _isConnected: boolean;
  75213. private _leftStickAxisX;
  75214. private _leftStickAxisY;
  75215. private _rightStickAxisX;
  75216. private _rightStickAxisY;
  75217. /**
  75218. * Triggered when the left control stick has been changed
  75219. */
  75220. private _onleftstickchanged;
  75221. /**
  75222. * Triggered when the right control stick has been changed
  75223. */
  75224. private _onrightstickchanged;
  75225. /**
  75226. * Represents a gamepad controller
  75227. */
  75228. static GAMEPAD: number;
  75229. /**
  75230. * Represents a generic controller
  75231. */
  75232. static GENERIC: number;
  75233. /**
  75234. * Represents an XBox controller
  75235. */
  75236. static XBOX: number;
  75237. /**
  75238. * Represents a pose-enabled controller
  75239. */
  75240. static POSE_ENABLED: number;
  75241. /**
  75242. * Specifies whether the left control stick should be Y-inverted
  75243. */
  75244. protected _invertLeftStickY: boolean;
  75245. /**
  75246. * Specifies if the gamepad has been connected
  75247. */
  75248. readonly isConnected: boolean;
  75249. /**
  75250. * Initializes the gamepad
  75251. * @param id The id of the gamepad
  75252. * @param index The index of the gamepad
  75253. * @param browserGamepad The browser gamepad
  75254. * @param leftStickX The x component of the left joystick
  75255. * @param leftStickY The y component of the left joystick
  75256. * @param rightStickX The x component of the right joystick
  75257. * @param rightStickY The y component of the right joystick
  75258. */
  75259. constructor(
  75260. /**
  75261. * The id of the gamepad
  75262. */
  75263. id: string,
  75264. /**
  75265. * The index of the gamepad
  75266. */
  75267. index: number,
  75268. /**
  75269. * The browser gamepad
  75270. */
  75271. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75272. /**
  75273. * Callback triggered when the left joystick has changed
  75274. * @param callback
  75275. */
  75276. onleftstickchanged(callback: (values: StickValues) => void): void;
  75277. /**
  75278. * Callback triggered when the right joystick has changed
  75279. * @param callback
  75280. */
  75281. onrightstickchanged(callback: (values: StickValues) => void): void;
  75282. /**
  75283. * Gets the left joystick
  75284. */
  75285. /**
  75286. * Sets the left joystick values
  75287. */
  75288. leftStick: StickValues;
  75289. /**
  75290. * Gets the right joystick
  75291. */
  75292. /**
  75293. * Sets the right joystick value
  75294. */
  75295. rightStick: StickValues;
  75296. /**
  75297. * Updates the gamepad joystick positions
  75298. */
  75299. update(): void;
  75300. /**
  75301. * Disposes the gamepad
  75302. */
  75303. dispose(): void;
  75304. }
  75305. /**
  75306. * Represents a generic gamepad
  75307. */
  75308. export class GenericPad extends Gamepad {
  75309. private _buttons;
  75310. private _onbuttondown;
  75311. private _onbuttonup;
  75312. /**
  75313. * Observable triggered when a button has been pressed
  75314. */
  75315. onButtonDownObservable: Observable<number>;
  75316. /**
  75317. * Observable triggered when a button has been released
  75318. */
  75319. onButtonUpObservable: Observable<number>;
  75320. /**
  75321. * Callback triggered when a button has been pressed
  75322. * @param callback Called when a button has been pressed
  75323. */
  75324. onbuttondown(callback: (buttonPressed: number) => void): void;
  75325. /**
  75326. * Callback triggered when a button has been released
  75327. * @param callback Called when a button has been released
  75328. */
  75329. onbuttonup(callback: (buttonReleased: number) => void): void;
  75330. /**
  75331. * Initializes the generic gamepad
  75332. * @param id The id of the generic gamepad
  75333. * @param index The index of the generic gamepad
  75334. * @param browserGamepad The browser gamepad
  75335. */
  75336. constructor(id: string, index: number, browserGamepad: any);
  75337. private _setButtonValue;
  75338. /**
  75339. * Updates the generic gamepad
  75340. */
  75341. update(): void;
  75342. /**
  75343. * Disposes the generic gamepad
  75344. */
  75345. dispose(): void;
  75346. }
  75347. }
  75348. declare module BABYLON {
  75349. /**
  75350. * Defines the types of pose enabled controllers that are supported
  75351. */
  75352. export enum PoseEnabledControllerType {
  75353. /**
  75354. * HTC Vive
  75355. */
  75356. VIVE = 0,
  75357. /**
  75358. * Oculus Rift
  75359. */
  75360. OCULUS = 1,
  75361. /**
  75362. * Windows mixed reality
  75363. */
  75364. WINDOWS = 2,
  75365. /**
  75366. * Samsung gear VR
  75367. */
  75368. GEAR_VR = 3,
  75369. /**
  75370. * Google Daydream
  75371. */
  75372. DAYDREAM = 4,
  75373. /**
  75374. * Generic
  75375. */
  75376. GENERIC = 5
  75377. }
  75378. /**
  75379. * Defines the MutableGamepadButton interface for the state of a gamepad button
  75380. */
  75381. export interface MutableGamepadButton {
  75382. /**
  75383. * Value of the button/trigger
  75384. */
  75385. value: number;
  75386. /**
  75387. * If the button/trigger is currently touched
  75388. */
  75389. touched: boolean;
  75390. /**
  75391. * If the button/trigger is currently pressed
  75392. */
  75393. pressed: boolean;
  75394. }
  75395. /**
  75396. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  75397. * @hidden
  75398. */
  75399. export interface ExtendedGamepadButton extends GamepadButton {
  75400. /**
  75401. * If the button/trigger is currently pressed
  75402. */
  75403. readonly pressed: boolean;
  75404. /**
  75405. * If the button/trigger is currently touched
  75406. */
  75407. readonly touched: boolean;
  75408. /**
  75409. * Value of the button/trigger
  75410. */
  75411. readonly value: number;
  75412. }
  75413. /** @hidden */
  75414. export interface _GamePadFactory {
  75415. /**
  75416. * Returns wether or not the current gamepad can be created for this type of controller.
  75417. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  75418. * @returns true if it can be created, otherwise false
  75419. */
  75420. canCreate(gamepadInfo: any): boolean;
  75421. /**
  75422. * Creates a new instance of the Gamepad.
  75423. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  75424. * @returns the new gamepad instance
  75425. */
  75426. create(gamepadInfo: any): Gamepad;
  75427. }
  75428. /**
  75429. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75430. */
  75431. export class PoseEnabledControllerHelper {
  75432. /** @hidden */
  75433. static _ControllerFactories: _GamePadFactory[];
  75434. /** @hidden */
  75435. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  75436. /**
  75437. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75438. * @param vrGamepad the gamepad to initialized
  75439. * @returns a vr controller of the type the gamepad identified as
  75440. */
  75441. static InitiateController(vrGamepad: any): Gamepad;
  75442. }
  75443. /**
  75444. * Defines the PoseEnabledController object that contains state of a vr capable controller
  75445. */
  75446. export class PoseEnabledController extends Gamepad implements PoseControlled {
  75447. private _deviceRoomPosition;
  75448. private _deviceRoomRotationQuaternion;
  75449. /**
  75450. * The device position in babylon space
  75451. */
  75452. devicePosition: Vector3;
  75453. /**
  75454. * The device rotation in babylon space
  75455. */
  75456. deviceRotationQuaternion: Quaternion;
  75457. /**
  75458. * The scale factor of the device in babylon space
  75459. */
  75460. deviceScaleFactor: number;
  75461. /**
  75462. * (Likely devicePosition should be used instead) The device position in its room space
  75463. */
  75464. position: Vector3;
  75465. /**
  75466. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  75467. */
  75468. rotationQuaternion: Quaternion;
  75469. /**
  75470. * The type of controller (Eg. Windows mixed reality)
  75471. */
  75472. controllerType: PoseEnabledControllerType;
  75473. protected _calculatedPosition: Vector3;
  75474. private _calculatedRotation;
  75475. /**
  75476. * The raw pose from the device
  75477. */
  75478. rawPose: DevicePose;
  75479. private _trackPosition;
  75480. private _maxRotationDistFromHeadset;
  75481. private _draggedRoomRotation;
  75482. /**
  75483. * @hidden
  75484. */
  75485. _disableTrackPosition(fixedPosition: Vector3): void;
  75486. /**
  75487. * Internal, the mesh attached to the controller
  75488. * @hidden
  75489. */
  75490. _mesh: Nullable<AbstractMesh>;
  75491. private _poseControlledCamera;
  75492. private _leftHandSystemQuaternion;
  75493. /**
  75494. * Internal, matrix used to convert room space to babylon space
  75495. * @hidden
  75496. */
  75497. _deviceToWorld: Matrix;
  75498. /**
  75499. * Node to be used when casting a ray from the controller
  75500. * @hidden
  75501. */
  75502. _pointingPoseNode: Nullable<TransformNode>;
  75503. /**
  75504. * Name of the child mesh that can be used to cast a ray from the controller
  75505. */
  75506. static readonly POINTING_POSE: string;
  75507. /**
  75508. * Creates a new PoseEnabledController from a gamepad
  75509. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  75510. */
  75511. constructor(browserGamepad: any);
  75512. private _workingMatrix;
  75513. /**
  75514. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  75515. */
  75516. update(): void;
  75517. /**
  75518. * Updates only the pose device and mesh without doing any button event checking
  75519. */
  75520. protected _updatePoseAndMesh(): void;
  75521. /**
  75522. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  75523. * @param poseData raw pose fromthe device
  75524. */
  75525. updateFromDevice(poseData: DevicePose): void;
  75526. /**
  75527. * @hidden
  75528. */
  75529. _meshAttachedObservable: Observable<AbstractMesh>;
  75530. /**
  75531. * Attaches a mesh to the controller
  75532. * @param mesh the mesh to be attached
  75533. */
  75534. attachToMesh(mesh: AbstractMesh): void;
  75535. /**
  75536. * Attaches the controllers mesh to a camera
  75537. * @param camera the camera the mesh should be attached to
  75538. */
  75539. attachToPoseControlledCamera(camera: TargetCamera): void;
  75540. /**
  75541. * Disposes of the controller
  75542. */
  75543. dispose(): void;
  75544. /**
  75545. * The mesh that is attached to the controller
  75546. */
  75547. readonly mesh: Nullable<AbstractMesh>;
  75548. /**
  75549. * Gets the ray of the controller in the direction the controller is pointing
  75550. * @param length the length the resulting ray should be
  75551. * @returns a ray in the direction the controller is pointing
  75552. */
  75553. getForwardRay(length?: number): Ray;
  75554. }
  75555. }
  75556. declare module BABYLON {
  75557. /**
  75558. * Defines the WebVRController object that represents controllers tracked in 3D space
  75559. */
  75560. export abstract class WebVRController extends PoseEnabledController {
  75561. /**
  75562. * Internal, the default controller model for the controller
  75563. */
  75564. protected _defaultModel: AbstractMesh;
  75565. /**
  75566. * Fired when the trigger state has changed
  75567. */
  75568. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  75569. /**
  75570. * Fired when the main button state has changed
  75571. */
  75572. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75573. /**
  75574. * Fired when the secondary button state has changed
  75575. */
  75576. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75577. /**
  75578. * Fired when the pad state has changed
  75579. */
  75580. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  75581. /**
  75582. * Fired when controllers stick values have changed
  75583. */
  75584. onPadValuesChangedObservable: Observable<StickValues>;
  75585. /**
  75586. * Array of button availible on the controller
  75587. */
  75588. protected _buttons: Array<MutableGamepadButton>;
  75589. private _onButtonStateChange;
  75590. /**
  75591. * Fired when a controller button's state has changed
  75592. * @param callback the callback containing the button that was modified
  75593. */
  75594. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  75595. /**
  75596. * X and Y axis corrisponding to the controllers joystick
  75597. */
  75598. pad: StickValues;
  75599. /**
  75600. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  75601. */
  75602. hand: string;
  75603. /**
  75604. * The default controller model for the controller
  75605. */
  75606. readonly defaultModel: AbstractMesh;
  75607. /**
  75608. * Creates a new WebVRController from a gamepad
  75609. * @param vrGamepad the gamepad that the WebVRController should be created from
  75610. */
  75611. constructor(vrGamepad: any);
  75612. /**
  75613. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  75614. */
  75615. update(): void;
  75616. /**
  75617. * Function to be called when a button is modified
  75618. */
  75619. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  75620. /**
  75621. * Loads a mesh and attaches it to the controller
  75622. * @param scene the scene the mesh should be added to
  75623. * @param meshLoaded callback for when the mesh has been loaded
  75624. */
  75625. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  75626. private _setButtonValue;
  75627. private _changes;
  75628. private _checkChanges;
  75629. /**
  75630. * Disposes of th webVRCOntroller
  75631. */
  75632. dispose(): void;
  75633. }
  75634. }
  75635. declare module BABYLON {
  75636. /**
  75637. * The HemisphericLight simulates the ambient environment light,
  75638. * so the passed direction is the light reflection direction, not the incoming direction.
  75639. */
  75640. export class HemisphericLight extends Light {
  75641. /**
  75642. * The groundColor is the light in the opposite direction to the one specified during creation.
  75643. * 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.
  75644. */
  75645. groundColor: Color3;
  75646. /**
  75647. * The light reflection direction, not the incoming direction.
  75648. */
  75649. direction: Vector3;
  75650. /**
  75651. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  75652. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  75653. * The HemisphericLight can't cast shadows.
  75654. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75655. * @param name The friendly name of the light
  75656. * @param direction The direction of the light reflection
  75657. * @param scene The scene the light belongs to
  75658. */
  75659. constructor(name: string, direction: Vector3, scene: Scene);
  75660. protected _buildUniformLayout(): void;
  75661. /**
  75662. * Returns the string "HemisphericLight".
  75663. * @return The class name
  75664. */
  75665. getClassName(): string;
  75666. /**
  75667. * Sets the HemisphericLight direction towards the passed target (Vector3).
  75668. * Returns the updated direction.
  75669. * @param target The target the direction should point to
  75670. * @return The computed direction
  75671. */
  75672. setDirectionToTarget(target: Vector3): Vector3;
  75673. /**
  75674. * Returns the shadow generator associated to the light.
  75675. * @returns Always null for hemispheric lights because it does not support shadows.
  75676. */
  75677. getShadowGenerator(): Nullable<IShadowGenerator>;
  75678. /**
  75679. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  75680. * @param effect The effect to update
  75681. * @param lightIndex The index of the light in the effect to update
  75682. * @returns The hemispheric light
  75683. */
  75684. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  75685. /**
  75686. * Computes the world matrix of the node
  75687. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75688. * @param useWasUpdatedFlag defines a reserved property
  75689. * @returns the world matrix
  75690. */
  75691. computeWorldMatrix(): Matrix;
  75692. /**
  75693. * Returns the integer 3.
  75694. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75695. */
  75696. getTypeID(): number;
  75697. /**
  75698. * Prepares the list of defines specific to the light type.
  75699. * @param defines the list of defines
  75700. * @param lightIndex defines the index of the light for the effect
  75701. */
  75702. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75703. }
  75704. }
  75705. declare module BABYLON {
  75706. /** @hidden */
  75707. export var vrMultiviewToSingleviewPixelShader: {
  75708. name: string;
  75709. shader: string;
  75710. };
  75711. }
  75712. declare module BABYLON {
  75713. /**
  75714. * Renders to multiple views with a single draw call
  75715. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  75716. */
  75717. export class MultiviewRenderTarget extends RenderTargetTexture {
  75718. /**
  75719. * Creates a multiview render target
  75720. * @param scene scene used with the render target
  75721. * @param size the size of the render target (used for each view)
  75722. */
  75723. constructor(scene: Scene, size?: number | {
  75724. width: number;
  75725. height: number;
  75726. } | {
  75727. ratio: number;
  75728. });
  75729. /**
  75730. * @hidden
  75731. * @param faceIndex the face index, if its a cube texture
  75732. */
  75733. _bindFrameBuffer(faceIndex?: number): void;
  75734. /**
  75735. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  75736. * @returns the view count
  75737. */
  75738. getViewCount(): number;
  75739. }
  75740. }
  75741. declare module BABYLON {
  75742. interface Engine {
  75743. /**
  75744. * Creates a new multiview render target
  75745. * @param width defines the width of the texture
  75746. * @param height defines the height of the texture
  75747. * @returns the created multiview texture
  75748. */
  75749. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  75750. /**
  75751. * Binds a multiview framebuffer to be drawn to
  75752. * @param multiviewTexture texture to bind
  75753. */
  75754. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  75755. }
  75756. interface Camera {
  75757. /**
  75758. * @hidden
  75759. * 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)
  75760. */
  75761. _useMultiviewToSingleView: boolean;
  75762. /**
  75763. * @hidden
  75764. * 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)
  75765. */
  75766. _multiviewTexture: Nullable<RenderTargetTexture>;
  75767. /**
  75768. * @hidden
  75769. * ensures the multiview texture of the camera exists and has the specified width/height
  75770. * @param width height to set on the multiview texture
  75771. * @param height width to set on the multiview texture
  75772. */
  75773. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  75774. }
  75775. interface Scene {
  75776. /** @hidden */
  75777. _transformMatrixR: Matrix;
  75778. /** @hidden */
  75779. _multiviewSceneUbo: Nullable<UniformBuffer>;
  75780. /** @hidden */
  75781. _createMultiviewUbo(): void;
  75782. /** @hidden */
  75783. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  75784. /** @hidden */
  75785. _renderMultiviewToSingleView(camera: Camera): void;
  75786. }
  75787. }
  75788. declare module BABYLON {
  75789. /**
  75790. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  75791. * This will not be used for webXR as it supports displaying texture arrays directly
  75792. */
  75793. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  75794. /**
  75795. * Initializes a VRMultiviewToSingleview
  75796. * @param name name of the post process
  75797. * @param camera camera to be applied to
  75798. * @param scaleFactor scaling factor to the size of the output texture
  75799. */
  75800. constructor(name: string, camera: Camera, scaleFactor: number);
  75801. }
  75802. }
  75803. declare module BABYLON {
  75804. interface Engine {
  75805. /** @hidden */
  75806. _vrDisplay: any;
  75807. /** @hidden */
  75808. _vrSupported: boolean;
  75809. /** @hidden */
  75810. _oldSize: Size;
  75811. /** @hidden */
  75812. _oldHardwareScaleFactor: number;
  75813. /** @hidden */
  75814. _vrExclusivePointerMode: boolean;
  75815. /** @hidden */
  75816. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  75817. /** @hidden */
  75818. _onVRDisplayPointerRestricted: () => void;
  75819. /** @hidden */
  75820. _onVRDisplayPointerUnrestricted: () => void;
  75821. /** @hidden */
  75822. _onVrDisplayConnect: Nullable<(display: any) => void>;
  75823. /** @hidden */
  75824. _onVrDisplayDisconnect: Nullable<() => void>;
  75825. /** @hidden */
  75826. _onVrDisplayPresentChange: Nullable<() => void>;
  75827. /**
  75828. * Observable signaled when VR display mode changes
  75829. */
  75830. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  75831. /**
  75832. * Observable signaled when VR request present is complete
  75833. */
  75834. onVRRequestPresentComplete: Observable<boolean>;
  75835. /**
  75836. * Observable signaled when VR request present starts
  75837. */
  75838. onVRRequestPresentStart: Observable<Engine>;
  75839. /**
  75840. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  75841. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  75842. */
  75843. isInVRExclusivePointerMode: boolean;
  75844. /**
  75845. * Gets a boolean indicating if a webVR device was detected
  75846. * @returns true if a webVR device was detected
  75847. */
  75848. isVRDevicePresent(): boolean;
  75849. /**
  75850. * Gets the current webVR device
  75851. * @returns the current webVR device (or null)
  75852. */
  75853. getVRDevice(): any;
  75854. /**
  75855. * Initializes a webVR display and starts listening to display change events
  75856. * The onVRDisplayChangedObservable will be notified upon these changes
  75857. * @returns A promise containing a VRDisplay and if vr is supported
  75858. */
  75859. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  75860. /** @hidden */
  75861. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  75862. /**
  75863. * Call this function to switch to webVR mode
  75864. * Will do nothing if webVR is not supported or if there is no webVR device
  75865. * @see http://doc.babylonjs.com/how_to/webvr_camera
  75866. */
  75867. enableVR(): void;
  75868. /** @hidden */
  75869. _onVRFullScreenTriggered(): void;
  75870. }
  75871. }
  75872. declare module BABYLON {
  75873. /**
  75874. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  75875. * IMPORTANT!! The data is right-hand data.
  75876. * @export
  75877. * @interface DevicePose
  75878. */
  75879. export interface DevicePose {
  75880. /**
  75881. * The position of the device, values in array are [x,y,z].
  75882. */
  75883. readonly position: Nullable<Float32Array>;
  75884. /**
  75885. * The linearVelocity of the device, values in array are [x,y,z].
  75886. */
  75887. readonly linearVelocity: Nullable<Float32Array>;
  75888. /**
  75889. * The linearAcceleration of the device, values in array are [x,y,z].
  75890. */
  75891. readonly linearAcceleration: Nullable<Float32Array>;
  75892. /**
  75893. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  75894. */
  75895. readonly orientation: Nullable<Float32Array>;
  75896. /**
  75897. * The angularVelocity of the device, values in array are [x,y,z].
  75898. */
  75899. readonly angularVelocity: Nullable<Float32Array>;
  75900. /**
  75901. * The angularAcceleration of the device, values in array are [x,y,z].
  75902. */
  75903. readonly angularAcceleration: Nullable<Float32Array>;
  75904. }
  75905. /**
  75906. * Interface representing a pose controlled object in Babylon.
  75907. * A pose controlled object has both regular pose values as well as pose values
  75908. * from an external device such as a VR head mounted display
  75909. */
  75910. export interface PoseControlled {
  75911. /**
  75912. * The position of the object in babylon space.
  75913. */
  75914. position: Vector3;
  75915. /**
  75916. * The rotation quaternion of the object in babylon space.
  75917. */
  75918. rotationQuaternion: Quaternion;
  75919. /**
  75920. * The position of the device in babylon space.
  75921. */
  75922. devicePosition?: Vector3;
  75923. /**
  75924. * The rotation quaternion of the device in babylon space.
  75925. */
  75926. deviceRotationQuaternion: Quaternion;
  75927. /**
  75928. * The raw pose coming from the device.
  75929. */
  75930. rawPose: Nullable<DevicePose>;
  75931. /**
  75932. * The scale of the device to be used when translating from device space to babylon space.
  75933. */
  75934. deviceScaleFactor: number;
  75935. /**
  75936. * Updates the poseControlled values based on the input device pose.
  75937. * @param poseData the pose data to update the object with
  75938. */
  75939. updateFromDevice(poseData: DevicePose): void;
  75940. }
  75941. /**
  75942. * Set of options to customize the webVRCamera
  75943. */
  75944. export interface WebVROptions {
  75945. /**
  75946. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  75947. */
  75948. trackPosition?: boolean;
  75949. /**
  75950. * Sets the scale of the vrDevice in babylon space. (default: 1)
  75951. */
  75952. positionScale?: number;
  75953. /**
  75954. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  75955. */
  75956. displayName?: string;
  75957. /**
  75958. * Should the native controller meshes be initialized. (default: true)
  75959. */
  75960. controllerMeshes?: boolean;
  75961. /**
  75962. * Creating a default HemiLight only on controllers. (default: true)
  75963. */
  75964. defaultLightingOnControllers?: boolean;
  75965. /**
  75966. * If you don't want to use the default VR button of the helper. (default: false)
  75967. */
  75968. useCustomVRButton?: boolean;
  75969. /**
  75970. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  75971. */
  75972. customVRButton?: HTMLButtonElement;
  75973. /**
  75974. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  75975. */
  75976. rayLength?: number;
  75977. /**
  75978. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  75979. */
  75980. defaultHeight?: number;
  75981. /**
  75982. * If multiview should be used if availible (default: false)
  75983. */
  75984. useMultiview?: boolean;
  75985. }
  75986. /**
  75987. * This represents a WebVR camera.
  75988. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  75989. * @example http://doc.babylonjs.com/how_to/webvr_camera
  75990. */
  75991. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  75992. private webVROptions;
  75993. /**
  75994. * @hidden
  75995. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  75996. */
  75997. _vrDevice: any;
  75998. /**
  75999. * The rawPose of the vrDevice.
  76000. */
  76001. rawPose: Nullable<DevicePose>;
  76002. private _onVREnabled;
  76003. private _specsVersion;
  76004. private _attached;
  76005. private _frameData;
  76006. protected _descendants: Array<Node>;
  76007. private _deviceRoomPosition;
  76008. /** @hidden */
  76009. _deviceRoomRotationQuaternion: Quaternion;
  76010. private _standingMatrix;
  76011. /**
  76012. * Represents device position in babylon space.
  76013. */
  76014. devicePosition: Vector3;
  76015. /**
  76016. * Represents device rotation in babylon space.
  76017. */
  76018. deviceRotationQuaternion: Quaternion;
  76019. /**
  76020. * The scale of the device to be used when translating from device space to babylon space.
  76021. */
  76022. deviceScaleFactor: number;
  76023. private _deviceToWorld;
  76024. private _worldToDevice;
  76025. /**
  76026. * References to the webVR controllers for the vrDevice.
  76027. */
  76028. controllers: Array<WebVRController>;
  76029. /**
  76030. * Emits an event when a controller is attached.
  76031. */
  76032. onControllersAttachedObservable: Observable<WebVRController[]>;
  76033. /**
  76034. * Emits an event when a controller's mesh has been loaded;
  76035. */
  76036. onControllerMeshLoadedObservable: Observable<WebVRController>;
  76037. /**
  76038. * Emits an event when the HMD's pose has been updated.
  76039. */
  76040. onPoseUpdatedFromDeviceObservable: Observable<any>;
  76041. private _poseSet;
  76042. /**
  76043. * If the rig cameras be used as parent instead of this camera.
  76044. */
  76045. rigParenting: boolean;
  76046. private _lightOnControllers;
  76047. private _defaultHeight?;
  76048. /**
  76049. * Instantiates a WebVRFreeCamera.
  76050. * @param name The name of the WebVRFreeCamera
  76051. * @param position The starting anchor position for the camera
  76052. * @param scene The scene the camera belongs to
  76053. * @param webVROptions a set of customizable options for the webVRCamera
  76054. */
  76055. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  76056. /**
  76057. * Gets the device distance from the ground in meters.
  76058. * @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.
  76059. */
  76060. deviceDistanceToRoomGround(): number;
  76061. /**
  76062. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  76063. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  76064. */
  76065. useStandingMatrix(callback?: (bool: boolean) => void): void;
  76066. /**
  76067. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  76068. * @returns A promise with a boolean set to if the standing matrix is supported.
  76069. */
  76070. useStandingMatrixAsync(): Promise<boolean>;
  76071. /**
  76072. * Disposes the camera
  76073. */
  76074. dispose(): void;
  76075. /**
  76076. * Gets a vrController by name.
  76077. * @param name The name of the controller to retreive
  76078. * @returns the controller matching the name specified or null if not found
  76079. */
  76080. getControllerByName(name: string): Nullable<WebVRController>;
  76081. private _leftController;
  76082. /**
  76083. * The controller corrisponding to the users left hand.
  76084. */
  76085. readonly leftController: Nullable<WebVRController>;
  76086. private _rightController;
  76087. /**
  76088. * The controller corrisponding to the users right hand.
  76089. */
  76090. readonly rightController: Nullable<WebVRController>;
  76091. /**
  76092. * Casts a ray forward from the vrCamera's gaze.
  76093. * @param length Length of the ray (default: 100)
  76094. * @returns the ray corrisponding to the gaze
  76095. */
  76096. getForwardRay(length?: number): Ray;
  76097. /**
  76098. * @hidden
  76099. * Updates the camera based on device's frame data
  76100. */
  76101. _checkInputs(): void;
  76102. /**
  76103. * Updates the poseControlled values based on the input device pose.
  76104. * @param poseData Pose coming from the device
  76105. */
  76106. updateFromDevice(poseData: DevicePose): void;
  76107. private _htmlElementAttached;
  76108. private _detachIfAttached;
  76109. /**
  76110. * WebVR's attach control will start broadcasting frames to the device.
  76111. * Note that in certain browsers (chrome for example) this function must be called
  76112. * within a user-interaction callback. Example:
  76113. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  76114. *
  76115. * @param element html element to attach the vrDevice to
  76116. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  76117. */
  76118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  76119. /**
  76120. * Detaches the camera from the html element and disables VR
  76121. *
  76122. * @param element html element to detach from
  76123. */
  76124. detachControl(element: HTMLElement): void;
  76125. /**
  76126. * @returns the name of this class
  76127. */
  76128. getClassName(): string;
  76129. /**
  76130. * Calls resetPose on the vrDisplay
  76131. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  76132. */
  76133. resetToCurrentRotation(): void;
  76134. /**
  76135. * @hidden
  76136. * Updates the rig cameras (left and right eye)
  76137. */
  76138. _updateRigCameras(): void;
  76139. private _workingVector;
  76140. private _oneVector;
  76141. private _workingMatrix;
  76142. private updateCacheCalled;
  76143. private _correctPositionIfNotTrackPosition;
  76144. /**
  76145. * @hidden
  76146. * Updates the cached values of the camera
  76147. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  76148. */
  76149. _updateCache(ignoreParentClass?: boolean): void;
  76150. /**
  76151. * @hidden
  76152. * Get current device position in babylon world
  76153. */
  76154. _computeDevicePosition(): void;
  76155. /**
  76156. * Updates the current device position and rotation in the babylon world
  76157. */
  76158. update(): void;
  76159. /**
  76160. * @hidden
  76161. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  76162. * @returns an identity matrix
  76163. */
  76164. _getViewMatrix(): Matrix;
  76165. private _tmpMatrix;
  76166. /**
  76167. * This function is called by the two RIG cameras.
  76168. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  76169. * @hidden
  76170. */
  76171. _getWebVRViewMatrix(): Matrix;
  76172. /** @hidden */
  76173. _getWebVRProjectionMatrix(): Matrix;
  76174. private _onGamepadConnectedObserver;
  76175. private _onGamepadDisconnectedObserver;
  76176. private _updateCacheWhenTrackingDisabledObserver;
  76177. /**
  76178. * Initializes the controllers and their meshes
  76179. */
  76180. initControllers(): void;
  76181. }
  76182. }
  76183. declare module BABYLON {
  76184. /**
  76185. * Size options for a post process
  76186. */
  76187. export type PostProcessOptions = {
  76188. width: number;
  76189. height: number;
  76190. };
  76191. /**
  76192. * PostProcess can be used to apply a shader to a texture after it has been rendered
  76193. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76194. */
  76195. export class PostProcess {
  76196. /** Name of the PostProcess. */
  76197. name: string;
  76198. /**
  76199. * Gets or sets the unique id of the post process
  76200. */
  76201. uniqueId: number;
  76202. /**
  76203. * Width of the texture to apply the post process on
  76204. */
  76205. width: number;
  76206. /**
  76207. * Height of the texture to apply the post process on
  76208. */
  76209. height: number;
  76210. /**
  76211. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  76212. * @hidden
  76213. */
  76214. _outputTexture: Nullable<InternalTexture>;
  76215. /**
  76216. * Sampling mode used by the shader
  76217. * See https://doc.babylonjs.com/classes/3.1/texture
  76218. */
  76219. renderTargetSamplingMode: number;
  76220. /**
  76221. * Clear color to use when screen clearing
  76222. */
  76223. clearColor: Color4;
  76224. /**
  76225. * If the buffer needs to be cleared before applying the post process. (default: true)
  76226. * Should be set to false if shader will overwrite all previous pixels.
  76227. */
  76228. autoClear: boolean;
  76229. /**
  76230. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  76231. */
  76232. alphaMode: number;
  76233. /**
  76234. * Sets the setAlphaBlendConstants of the babylon engine
  76235. */
  76236. alphaConstants: Color4;
  76237. /**
  76238. * Animations to be used for the post processing
  76239. */
  76240. animations: Animation[];
  76241. /**
  76242. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  76243. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  76244. */
  76245. enablePixelPerfectMode: boolean;
  76246. /**
  76247. * Force the postprocess to be applied without taking in account viewport
  76248. */
  76249. forceFullscreenViewport: boolean;
  76250. /**
  76251. * List of inspectable custom properties (used by the Inspector)
  76252. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76253. */
  76254. inspectableCustomProperties: IInspectable[];
  76255. /**
  76256. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  76257. *
  76258. * | Value | Type | Description |
  76259. * | ----- | ----------------------------------- | ----------- |
  76260. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  76261. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  76262. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  76263. *
  76264. */
  76265. scaleMode: number;
  76266. /**
  76267. * Force textures to be a power of two (default: false)
  76268. */
  76269. alwaysForcePOT: boolean;
  76270. private _samples;
  76271. /**
  76272. * Number of sample textures (default: 1)
  76273. */
  76274. samples: number;
  76275. /**
  76276. * Modify the scale of the post process to be the same as the viewport (default: false)
  76277. */
  76278. adaptScaleToCurrentViewport: boolean;
  76279. private _camera;
  76280. private _scene;
  76281. private _engine;
  76282. private _options;
  76283. private _reusable;
  76284. private _textureType;
  76285. /**
  76286. * Smart array of input and output textures for the post process.
  76287. * @hidden
  76288. */
  76289. _textures: SmartArray<InternalTexture>;
  76290. /**
  76291. * The index in _textures that corresponds to the output texture.
  76292. * @hidden
  76293. */
  76294. _currentRenderTextureInd: number;
  76295. private _effect;
  76296. private _samplers;
  76297. private _fragmentUrl;
  76298. private _vertexUrl;
  76299. private _parameters;
  76300. private _scaleRatio;
  76301. protected _indexParameters: any;
  76302. private _shareOutputWithPostProcess;
  76303. private _texelSize;
  76304. private _forcedOutputTexture;
  76305. /**
  76306. * Returns the fragment url or shader name used in the post process.
  76307. * @returns the fragment url or name in the shader store.
  76308. */
  76309. getEffectName(): string;
  76310. /**
  76311. * An event triggered when the postprocess is activated.
  76312. */
  76313. onActivateObservable: Observable<Camera>;
  76314. private _onActivateObserver;
  76315. /**
  76316. * A function that is added to the onActivateObservable
  76317. */
  76318. onActivate: Nullable<(camera: Camera) => void>;
  76319. /**
  76320. * An event triggered when the postprocess changes its size.
  76321. */
  76322. onSizeChangedObservable: Observable<PostProcess>;
  76323. private _onSizeChangedObserver;
  76324. /**
  76325. * A function that is added to the onSizeChangedObservable
  76326. */
  76327. onSizeChanged: (postProcess: PostProcess) => void;
  76328. /**
  76329. * An event triggered when the postprocess applies its effect.
  76330. */
  76331. onApplyObservable: Observable<Effect>;
  76332. private _onApplyObserver;
  76333. /**
  76334. * A function that is added to the onApplyObservable
  76335. */
  76336. onApply: (effect: Effect) => void;
  76337. /**
  76338. * An event triggered before rendering the postprocess
  76339. */
  76340. onBeforeRenderObservable: Observable<Effect>;
  76341. private _onBeforeRenderObserver;
  76342. /**
  76343. * A function that is added to the onBeforeRenderObservable
  76344. */
  76345. onBeforeRender: (effect: Effect) => void;
  76346. /**
  76347. * An event triggered after rendering the postprocess
  76348. */
  76349. onAfterRenderObservable: Observable<Effect>;
  76350. private _onAfterRenderObserver;
  76351. /**
  76352. * A function that is added to the onAfterRenderObservable
  76353. */
  76354. onAfterRender: (efect: Effect) => void;
  76355. /**
  76356. * 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
  76357. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  76358. */
  76359. inputTexture: InternalTexture;
  76360. /**
  76361. * Gets the camera which post process is applied to.
  76362. * @returns The camera the post process is applied to.
  76363. */
  76364. getCamera(): Camera;
  76365. /**
  76366. * Gets the texel size of the postprocess.
  76367. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  76368. */
  76369. readonly texelSize: Vector2;
  76370. /**
  76371. * Creates a new instance PostProcess
  76372. * @param name The name of the PostProcess.
  76373. * @param fragmentUrl The url of the fragment shader to be used.
  76374. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  76375. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  76376. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  76377. * @param camera The camera to apply the render pass to.
  76378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76379. * @param engine The engine which the post process will be applied. (default: current engine)
  76380. * @param reusable If the post process can be reused on the same frame. (default: false)
  76381. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  76382. * @param textureType Type of textures used when performing the post process. (default: 0)
  76383. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  76384. * @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
  76385. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  76386. */
  76387. constructor(
  76388. /** Name of the PostProcess. */
  76389. 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);
  76390. /**
  76391. * Gets a string idenfifying the name of the class
  76392. * @returns "PostProcess" string
  76393. */
  76394. getClassName(): string;
  76395. /**
  76396. * Gets the engine which this post process belongs to.
  76397. * @returns The engine the post process was enabled with.
  76398. */
  76399. getEngine(): Engine;
  76400. /**
  76401. * The effect that is created when initializing the post process.
  76402. * @returns The created effect corrisponding the the postprocess.
  76403. */
  76404. getEffect(): Effect;
  76405. /**
  76406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  76407. * @param postProcess The post process to share the output with.
  76408. * @returns This post process.
  76409. */
  76410. shareOutputWith(postProcess: PostProcess): PostProcess;
  76411. /**
  76412. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  76413. * This should be called if the post process that shares output with this post process is disabled/disposed.
  76414. */
  76415. useOwnOutput(): void;
  76416. /**
  76417. * Updates the effect with the current post process compile time values and recompiles the shader.
  76418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  76419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  76420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  76421. * @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
  76422. * @param onCompiled Called when the shader has been compiled.
  76423. * @param onError Called if there is an error when compiling a shader.
  76424. */
  76425. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  76426. /**
  76427. * The post process is reusable if it can be used multiple times within one frame.
  76428. * @returns If the post process is reusable
  76429. */
  76430. isReusable(): boolean;
  76431. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  76432. markTextureDirty(): void;
  76433. /**
  76434. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  76435. * 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.
  76436. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  76437. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  76438. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  76439. * @returns The target texture that was bound to be written to.
  76440. */
  76441. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  76442. /**
  76443. * If the post process is supported.
  76444. */
  76445. readonly isSupported: boolean;
  76446. /**
  76447. * The aspect ratio of the output texture.
  76448. */
  76449. readonly aspectRatio: number;
  76450. /**
  76451. * Get a value indicating if the post-process is ready to be used
  76452. * @returns true if the post-process is ready (shader is compiled)
  76453. */
  76454. isReady(): boolean;
  76455. /**
  76456. * Binds all textures and uniforms to the shader, this will be run on every pass.
  76457. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  76458. */
  76459. apply(): Nullable<Effect>;
  76460. private _disposeTextures;
  76461. /**
  76462. * Disposes the post process.
  76463. * @param camera The camera to dispose the post process on.
  76464. */
  76465. dispose(camera?: Camera): void;
  76466. }
  76467. }
  76468. declare module BABYLON {
  76469. /**
  76470. * PostProcessManager is used to manage one or more post processes or post process pipelines
  76471. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76472. */
  76473. export class PostProcessManager {
  76474. private _scene;
  76475. private _indexBuffer;
  76476. private _vertexBuffers;
  76477. /**
  76478. * Creates a new instance PostProcess
  76479. * @param scene The scene that the post process is associated with.
  76480. */
  76481. constructor(scene: Scene);
  76482. private _prepareBuffers;
  76483. private _buildIndexBuffer;
  76484. /**
  76485. * Rebuilds the vertex buffers of the manager.
  76486. * @hidden
  76487. */
  76488. _rebuild(): void;
  76489. /**
  76490. * Prepares a frame to be run through a post process.
  76491. * @param sourceTexture The input texture to the post procesess. (default: null)
  76492. * @param postProcesses An array of post processes to be run. (default: null)
  76493. * @returns True if the post processes were able to be run.
  76494. * @hidden
  76495. */
  76496. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  76497. /**
  76498. * Manually render a set of post processes to a texture.
  76499. * @param postProcesses An array of post processes to be run.
  76500. * @param targetTexture The target texture to render to.
  76501. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  76502. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  76503. * @param lodLevel defines which lod of the texture to render to
  76504. */
  76505. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  76506. /**
  76507. * Finalize the result of the output of the postprocesses.
  76508. * @param doNotPresent If true the result will not be displayed to the screen.
  76509. * @param targetTexture The target texture to render to.
  76510. * @param faceIndex The index of the face to bind the target texture to.
  76511. * @param postProcesses The array of post processes to render.
  76512. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  76513. * @hidden
  76514. */
  76515. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  76516. /**
  76517. * Disposes of the post process manager.
  76518. */
  76519. dispose(): void;
  76520. }
  76521. }
  76522. declare module BABYLON {
  76523. interface AbstractScene {
  76524. /**
  76525. * The list of procedural textures added to the scene
  76526. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76527. */
  76528. proceduralTextures: Array<ProceduralTexture>;
  76529. }
  76530. /**
  76531. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  76532. * in a given scene.
  76533. */
  76534. export class ProceduralTextureSceneComponent implements ISceneComponent {
  76535. /**
  76536. * The component name helpfull to identify the component in the list of scene components.
  76537. */
  76538. readonly name: string;
  76539. /**
  76540. * The scene the component belongs to.
  76541. */
  76542. scene: Scene;
  76543. /**
  76544. * Creates a new instance of the component for the given scene
  76545. * @param scene Defines the scene to register the component in
  76546. */
  76547. constructor(scene: Scene);
  76548. /**
  76549. * Registers the component in a given scene
  76550. */
  76551. register(): void;
  76552. /**
  76553. * Rebuilds the elements related to this component in case of
  76554. * context lost for instance.
  76555. */
  76556. rebuild(): void;
  76557. /**
  76558. * Disposes the component and the associated ressources.
  76559. */
  76560. dispose(): void;
  76561. private _beforeClear;
  76562. }
  76563. }
  76564. declare module BABYLON {
  76565. interface Engine {
  76566. /**
  76567. * Creates a new render target cube texture
  76568. * @param size defines the size of the texture
  76569. * @param options defines the options used to create the texture
  76570. * @returns a new render target cube texture stored in an InternalTexture
  76571. */
  76572. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  76573. }
  76574. }
  76575. declare module BABYLON {
  76576. /** @hidden */
  76577. export var proceduralVertexShader: {
  76578. name: string;
  76579. shader: string;
  76580. };
  76581. }
  76582. declare module BABYLON {
  76583. /**
  76584. * 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.
  76585. * This is the base class of any Procedural texture and contains most of the shareable code.
  76586. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76587. */
  76588. export class ProceduralTexture extends Texture {
  76589. isCube: boolean;
  76590. /**
  76591. * Define if the texture is enabled or not (disabled texture will not render)
  76592. */
  76593. isEnabled: boolean;
  76594. /**
  76595. * Define if the texture must be cleared before rendering (default is true)
  76596. */
  76597. autoClear: boolean;
  76598. /**
  76599. * Callback called when the texture is generated
  76600. */
  76601. onGenerated: () => void;
  76602. /**
  76603. * Event raised when the texture is generated
  76604. */
  76605. onGeneratedObservable: Observable<ProceduralTexture>;
  76606. /** @hidden */
  76607. _generateMipMaps: boolean;
  76608. /** @hidden **/
  76609. _effect: Effect;
  76610. /** @hidden */
  76611. _textures: {
  76612. [key: string]: Texture;
  76613. };
  76614. private _size;
  76615. private _currentRefreshId;
  76616. private _refreshRate;
  76617. private _vertexBuffers;
  76618. private _indexBuffer;
  76619. private _uniforms;
  76620. private _samplers;
  76621. private _fragment;
  76622. private _floats;
  76623. private _ints;
  76624. private _floatsArrays;
  76625. private _colors3;
  76626. private _colors4;
  76627. private _vectors2;
  76628. private _vectors3;
  76629. private _matrices;
  76630. private _fallbackTexture;
  76631. private _fallbackTextureUsed;
  76632. private _engine;
  76633. private _cachedDefines;
  76634. private _contentUpdateId;
  76635. private _contentData;
  76636. /**
  76637. * Instantiates a new procedural texture.
  76638. * 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.
  76639. * This is the base class of any Procedural texture and contains most of the shareable code.
  76640. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76641. * @param name Define the name of the texture
  76642. * @param size Define the size of the texture to create
  76643. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  76644. * @param scene Define the scene the texture belongs to
  76645. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  76646. * @param generateMipMaps Define if the texture should creates mip maps or not
  76647. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  76648. */
  76649. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  76650. /**
  76651. * The effect that is created when initializing the post process.
  76652. * @returns The created effect corrisponding the the postprocess.
  76653. */
  76654. getEffect(): Effect;
  76655. /**
  76656. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  76657. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  76658. */
  76659. getContent(): Nullable<ArrayBufferView>;
  76660. private _createIndexBuffer;
  76661. /** @hidden */
  76662. _rebuild(): void;
  76663. /**
  76664. * Resets the texture in order to recreate its associated resources.
  76665. * This can be called in case of context loss
  76666. */
  76667. reset(): void;
  76668. protected _getDefines(): string;
  76669. /**
  76670. * Is the texture ready to be used ? (rendered at least once)
  76671. * @returns true if ready, otherwise, false.
  76672. */
  76673. isReady(): boolean;
  76674. /**
  76675. * Resets the refresh counter of the texture and start bak from scratch.
  76676. * Could be useful to regenerate the texture if it is setup to render only once.
  76677. */
  76678. resetRefreshCounter(): void;
  76679. /**
  76680. * Set the fragment shader to use in order to render the texture.
  76681. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  76682. */
  76683. setFragment(fragment: any): void;
  76684. /**
  76685. * Define the refresh rate of the texture or the rendering frequency.
  76686. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76687. */
  76688. refreshRate: number;
  76689. /** @hidden */
  76690. _shouldRender(): boolean;
  76691. /**
  76692. * Get the size the texture is rendering at.
  76693. * @returns the size (texture is always squared)
  76694. */
  76695. getRenderSize(): number;
  76696. /**
  76697. * Resize the texture to new value.
  76698. * @param size Define the new size the texture should have
  76699. * @param generateMipMaps Define whether the new texture should create mip maps
  76700. */
  76701. resize(size: number, generateMipMaps: boolean): void;
  76702. private _checkUniform;
  76703. /**
  76704. * Set a texture in the shader program used to render.
  76705. * @param name Define the name of the uniform samplers as defined in the shader
  76706. * @param texture Define the texture to bind to this sampler
  76707. * @return the texture itself allowing "fluent" like uniform updates
  76708. */
  76709. setTexture(name: string, texture: Texture): ProceduralTexture;
  76710. /**
  76711. * Set a float in the shader.
  76712. * @param name Define the name of the uniform as defined in the shader
  76713. * @param value Define the value to give to the uniform
  76714. * @return the texture itself allowing "fluent" like uniform updates
  76715. */
  76716. setFloat(name: string, value: number): ProceduralTexture;
  76717. /**
  76718. * Set a int in the shader.
  76719. * @param name Define the name of the uniform as defined in the shader
  76720. * @param value Define the value to give to the uniform
  76721. * @return the texture itself allowing "fluent" like uniform updates
  76722. */
  76723. setInt(name: string, value: number): ProceduralTexture;
  76724. /**
  76725. * Set an array of floats in the shader.
  76726. * @param name Define the name of the uniform as defined in the shader
  76727. * @param value Define the value to give to the uniform
  76728. * @return the texture itself allowing "fluent" like uniform updates
  76729. */
  76730. setFloats(name: string, value: number[]): ProceduralTexture;
  76731. /**
  76732. * Set a vec3 in the shader from a Color3.
  76733. * @param name Define the name of the uniform as defined in the shader
  76734. * @param value Define the value to give to the uniform
  76735. * @return the texture itself allowing "fluent" like uniform updates
  76736. */
  76737. setColor3(name: string, value: Color3): ProceduralTexture;
  76738. /**
  76739. * Set a vec4 in the shader from a Color4.
  76740. * @param name Define the name of the uniform as defined in the shader
  76741. * @param value Define the value to give to the uniform
  76742. * @return the texture itself allowing "fluent" like uniform updates
  76743. */
  76744. setColor4(name: string, value: Color4): ProceduralTexture;
  76745. /**
  76746. * Set a vec2 in the shader from a Vector2.
  76747. * @param name Define the name of the uniform as defined in the shader
  76748. * @param value Define the value to give to the uniform
  76749. * @return the texture itself allowing "fluent" like uniform updates
  76750. */
  76751. setVector2(name: string, value: Vector2): ProceduralTexture;
  76752. /**
  76753. * Set a vec3 in the shader from a Vector3.
  76754. * @param name Define the name of the uniform as defined in the shader
  76755. * @param value Define the value to give to the uniform
  76756. * @return the texture itself allowing "fluent" like uniform updates
  76757. */
  76758. setVector3(name: string, value: Vector3): ProceduralTexture;
  76759. /**
  76760. * Set a mat4 in the shader from a MAtrix.
  76761. * @param name Define the name of the uniform as defined in the shader
  76762. * @param value Define the value to give to the uniform
  76763. * @return the texture itself allowing "fluent" like uniform updates
  76764. */
  76765. setMatrix(name: string, value: Matrix): ProceduralTexture;
  76766. /**
  76767. * Render the texture to its associated render target.
  76768. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  76769. */
  76770. render(useCameraPostProcess?: boolean): void;
  76771. /**
  76772. * Clone the texture.
  76773. * @returns the cloned texture
  76774. */
  76775. clone(): ProceduralTexture;
  76776. /**
  76777. * Dispose the texture and release its asoociated resources.
  76778. */
  76779. dispose(): void;
  76780. }
  76781. }
  76782. declare module BABYLON {
  76783. /**
  76784. * This represents the base class for particle system in Babylon.
  76785. * 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.
  76786. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76787. * @example https://doc.babylonjs.com/babylon101/particles
  76788. */
  76789. export class BaseParticleSystem {
  76790. /**
  76791. * Source color is added to the destination color without alpha affecting the result
  76792. */
  76793. static BLENDMODE_ONEONE: number;
  76794. /**
  76795. * Blend current color and particle color using particle’s alpha
  76796. */
  76797. static BLENDMODE_STANDARD: number;
  76798. /**
  76799. * Add current color and particle color multiplied by particle’s alpha
  76800. */
  76801. static BLENDMODE_ADD: number;
  76802. /**
  76803. * Multiply current color with particle color
  76804. */
  76805. static BLENDMODE_MULTIPLY: number;
  76806. /**
  76807. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  76808. */
  76809. static BLENDMODE_MULTIPLYADD: number;
  76810. /**
  76811. * List of animations used by the particle system.
  76812. */
  76813. animations: Animation[];
  76814. /**
  76815. * The id of the Particle system.
  76816. */
  76817. id: string;
  76818. /**
  76819. * The friendly name of the Particle system.
  76820. */
  76821. name: string;
  76822. /**
  76823. * The rendering group used by the Particle system to chose when to render.
  76824. */
  76825. renderingGroupId: number;
  76826. /**
  76827. * The emitter represents the Mesh or position we are attaching the particle system to.
  76828. */
  76829. emitter: Nullable<AbstractMesh | Vector3>;
  76830. /**
  76831. * The maximum number of particles to emit per frame
  76832. */
  76833. emitRate: number;
  76834. /**
  76835. * If you want to launch only a few particles at once, that can be done, as well.
  76836. */
  76837. manualEmitCount: number;
  76838. /**
  76839. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76840. */
  76841. updateSpeed: number;
  76842. /**
  76843. * The amount of time the particle system is running (depends of the overall update speed).
  76844. */
  76845. targetStopDuration: number;
  76846. /**
  76847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76848. */
  76849. disposeOnStop: boolean;
  76850. /**
  76851. * Minimum power of emitting particles.
  76852. */
  76853. minEmitPower: number;
  76854. /**
  76855. * Maximum power of emitting particles.
  76856. */
  76857. maxEmitPower: number;
  76858. /**
  76859. * Minimum life time of emitting particles.
  76860. */
  76861. minLifeTime: number;
  76862. /**
  76863. * Maximum life time of emitting particles.
  76864. */
  76865. maxLifeTime: number;
  76866. /**
  76867. * Minimum Size of emitting particles.
  76868. */
  76869. minSize: number;
  76870. /**
  76871. * Maximum Size of emitting particles.
  76872. */
  76873. maxSize: number;
  76874. /**
  76875. * Minimum scale of emitting particles on X axis.
  76876. */
  76877. minScaleX: number;
  76878. /**
  76879. * Maximum scale of emitting particles on X axis.
  76880. */
  76881. maxScaleX: number;
  76882. /**
  76883. * Minimum scale of emitting particles on Y axis.
  76884. */
  76885. minScaleY: number;
  76886. /**
  76887. * Maximum scale of emitting particles on Y axis.
  76888. */
  76889. maxScaleY: number;
  76890. /**
  76891. * Gets or sets the minimal initial rotation in radians.
  76892. */
  76893. minInitialRotation: number;
  76894. /**
  76895. * Gets or sets the maximal initial rotation in radians.
  76896. */
  76897. maxInitialRotation: number;
  76898. /**
  76899. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76900. */
  76901. minAngularSpeed: number;
  76902. /**
  76903. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76904. */
  76905. maxAngularSpeed: number;
  76906. /**
  76907. * The texture used to render each particle. (this can be a spritesheet)
  76908. */
  76909. particleTexture: Nullable<Texture>;
  76910. /**
  76911. * The layer mask we are rendering the particles through.
  76912. */
  76913. layerMask: number;
  76914. /**
  76915. * This can help using your own shader to render the particle system.
  76916. * The according effect will be created
  76917. */
  76918. customShader: any;
  76919. /**
  76920. * By default particle system starts as soon as they are created. This prevents the
  76921. * automatic start to happen and let you decide when to start emitting particles.
  76922. */
  76923. preventAutoStart: boolean;
  76924. private _noiseTexture;
  76925. /**
  76926. * Gets or sets a texture used to add random noise to particle positions
  76927. */
  76928. noiseTexture: Nullable<ProceduralTexture>;
  76929. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76930. noiseStrength: Vector3;
  76931. /**
  76932. * Callback triggered when the particle animation is ending.
  76933. */
  76934. onAnimationEnd: Nullable<() => void>;
  76935. /**
  76936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  76937. */
  76938. blendMode: number;
  76939. /**
  76940. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  76941. * to override the particles.
  76942. */
  76943. forceDepthWrite: boolean;
  76944. /** 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 */
  76945. preWarmCycles: number;
  76946. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  76947. preWarmStepOffset: number;
  76948. /**
  76949. * 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)
  76950. */
  76951. spriteCellChangeSpeed: number;
  76952. /**
  76953. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76954. */
  76955. startSpriteCellID: number;
  76956. /**
  76957. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76958. */
  76959. endSpriteCellID: number;
  76960. /**
  76961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76962. */
  76963. spriteCellWidth: number;
  76964. /**
  76965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76966. */
  76967. spriteCellHeight: number;
  76968. /**
  76969. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76970. */
  76971. spriteRandomStartCell: boolean;
  76972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76973. translationPivot: Vector2;
  76974. /** @hidden */
  76975. protected _isAnimationSheetEnabled: boolean;
  76976. /**
  76977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76978. */
  76979. beginAnimationOnStart: boolean;
  76980. /**
  76981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76982. */
  76983. beginAnimationFrom: number;
  76984. /**
  76985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76986. */
  76987. beginAnimationTo: number;
  76988. /**
  76989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76990. */
  76991. beginAnimationLoop: boolean;
  76992. /**
  76993. * Gets or sets a world offset applied to all particles
  76994. */
  76995. worldOffset: Vector3;
  76996. /**
  76997. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  76998. */
  76999. isAnimationSheetEnabled: boolean;
  77000. /**
  77001. * Get hosting scene
  77002. * @returns the scene
  77003. */
  77004. getScene(): Scene;
  77005. /**
  77006. * You can use gravity if you want to give an orientation to your particles.
  77007. */
  77008. gravity: Vector3;
  77009. protected _colorGradients: Nullable<Array<ColorGradient>>;
  77010. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  77011. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  77012. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  77013. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  77014. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  77015. protected _dragGradients: Nullable<Array<FactorGradient>>;
  77016. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  77017. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  77018. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  77019. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  77020. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  77021. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  77022. /**
  77023. * Defines the delay in milliseconds before starting the system (0 by default)
  77024. */
  77025. startDelay: number;
  77026. /**
  77027. * Gets the current list of drag gradients.
  77028. * You must use addDragGradient and removeDragGradient to udpate this list
  77029. * @returns the list of drag gradients
  77030. */
  77031. getDragGradients(): Nullable<Array<FactorGradient>>;
  77032. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  77033. limitVelocityDamping: number;
  77034. /**
  77035. * Gets the current list of limit velocity gradients.
  77036. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  77037. * @returns the list of limit velocity gradients
  77038. */
  77039. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  77040. /**
  77041. * Gets the current list of color gradients.
  77042. * You must use addColorGradient and removeColorGradient to udpate this list
  77043. * @returns the list of color gradients
  77044. */
  77045. getColorGradients(): Nullable<Array<ColorGradient>>;
  77046. /**
  77047. * Gets the current list of size gradients.
  77048. * You must use addSizeGradient and removeSizeGradient to udpate this list
  77049. * @returns the list of size gradients
  77050. */
  77051. getSizeGradients(): Nullable<Array<FactorGradient>>;
  77052. /**
  77053. * Gets the current list of color remap gradients.
  77054. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  77055. * @returns the list of color remap gradients
  77056. */
  77057. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  77058. /**
  77059. * Gets the current list of alpha remap gradients.
  77060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  77061. * @returns the list of alpha remap gradients
  77062. */
  77063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  77064. /**
  77065. * Gets the current list of life time gradients.
  77066. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  77067. * @returns the list of life time gradients
  77068. */
  77069. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  77070. /**
  77071. * Gets the current list of angular speed gradients.
  77072. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  77073. * @returns the list of angular speed gradients
  77074. */
  77075. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  77076. /**
  77077. * Gets the current list of velocity gradients.
  77078. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  77079. * @returns the list of velocity gradients
  77080. */
  77081. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  77082. /**
  77083. * Gets the current list of start size gradients.
  77084. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  77085. * @returns the list of start size gradients
  77086. */
  77087. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  77088. /**
  77089. * Gets the current list of emit rate gradients.
  77090. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  77091. * @returns the list of emit rate gradients
  77092. */
  77093. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  77094. /**
  77095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77097. */
  77098. direction1: Vector3;
  77099. /**
  77100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77102. */
  77103. direction2: Vector3;
  77104. /**
  77105. * 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.
  77106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77107. */
  77108. minEmitBox: Vector3;
  77109. /**
  77110. * 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.
  77111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  77112. */
  77113. maxEmitBox: Vector3;
  77114. /**
  77115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  77116. */
  77117. color1: Color4;
  77118. /**
  77119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  77120. */
  77121. color2: Color4;
  77122. /**
  77123. * Color the particle will have at the end of its lifetime
  77124. */
  77125. colorDead: Color4;
  77126. /**
  77127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  77128. */
  77129. textureMask: Color4;
  77130. /**
  77131. * The particle emitter type defines the emitter used by the particle system.
  77132. * It can be for example box, sphere, or cone...
  77133. */
  77134. particleEmitterType: IParticleEmitterType;
  77135. /** @hidden */
  77136. _isSubEmitter: boolean;
  77137. /**
  77138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  77139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  77140. */
  77141. billboardMode: number;
  77142. protected _isBillboardBased: boolean;
  77143. /**
  77144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  77145. */
  77146. isBillboardBased: boolean;
  77147. /**
  77148. * The scene the particle system belongs to.
  77149. */
  77150. protected _scene: Scene;
  77151. /**
  77152. * Local cache of defines for image processing.
  77153. */
  77154. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  77155. /**
  77156. * Default configuration related to image processing available in the standard Material.
  77157. */
  77158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  77159. /**
  77160. * Gets the image processing configuration used either in this material.
  77161. */
  77162. /**
  77163. * Sets the Default image processing configuration used either in the this material.
  77164. *
  77165. * If sets to null, the scene one is in use.
  77166. */
  77167. imageProcessingConfiguration: ImageProcessingConfiguration;
  77168. /**
  77169. * Attaches a new image processing configuration to the Standard Material.
  77170. * @param configuration
  77171. */
  77172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  77173. /** @hidden */
  77174. protected _reset(): void;
  77175. /** @hidden */
  77176. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  77177. /**
  77178. * Instantiates a particle system.
  77179. * 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.
  77180. * @param name The name of the particle system
  77181. */
  77182. constructor(name: string);
  77183. /**
  77184. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  77185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  77186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  77187. * @returns the emitter
  77188. */
  77189. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  77190. /**
  77191. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  77192. * @param radius The radius of the hemisphere to emit from
  77193. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  77194. * @returns the emitter
  77195. */
  77196. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  77197. /**
  77198. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  77199. * @param radius The radius of the sphere to emit from
  77200. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  77201. * @returns the emitter
  77202. */
  77203. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  77204. /**
  77205. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  77206. * @param radius The radius of the sphere to emit from
  77207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  77208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  77209. * @returns the emitter
  77210. */
  77211. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  77212. /**
  77213. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  77214. * @param radius The radius of the emission cylinder
  77215. * @param height The height of the emission cylinder
  77216. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  77217. * @param directionRandomizer How much to randomize the particle direction [0-1]
  77218. * @returns the emitter
  77219. */
  77220. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  77221. /**
  77222. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  77223. * @param radius The radius of the cylinder to emit from
  77224. * @param height The height of the emission cylinder
  77225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  77227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  77228. * @returns the emitter
  77229. */
  77230. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  77231. /**
  77232. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  77233. * @param radius The radius of the cone to emit from
  77234. * @param angle The base angle of the cone
  77235. * @returns the emitter
  77236. */
  77237. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  77238. /**
  77239. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  77240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  77241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  77242. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  77243. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  77244. * @returns the emitter
  77245. */
  77246. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  77247. }
  77248. }
  77249. declare module BABYLON {
  77250. /**
  77251. * Type of sub emitter
  77252. */
  77253. export enum SubEmitterType {
  77254. /**
  77255. * Attached to the particle over it's lifetime
  77256. */
  77257. ATTACHED = 0,
  77258. /**
  77259. * Created when the particle dies
  77260. */
  77261. END = 1
  77262. }
  77263. /**
  77264. * Sub emitter class used to emit particles from an existing particle
  77265. */
  77266. export class SubEmitter {
  77267. /**
  77268. * the particle system to be used by the sub emitter
  77269. */
  77270. particleSystem: ParticleSystem;
  77271. /**
  77272. * Type of the submitter (Default: END)
  77273. */
  77274. type: SubEmitterType;
  77275. /**
  77276. * 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)
  77277. * Note: This only is supported when using an emitter of type Mesh
  77278. */
  77279. inheritDirection: boolean;
  77280. /**
  77281. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  77282. */
  77283. inheritedVelocityAmount: number;
  77284. /**
  77285. * Creates a sub emitter
  77286. * @param particleSystem the particle system to be used by the sub emitter
  77287. */
  77288. constructor(
  77289. /**
  77290. * the particle system to be used by the sub emitter
  77291. */
  77292. particleSystem: ParticleSystem);
  77293. /**
  77294. * Clones the sub emitter
  77295. * @returns the cloned sub emitter
  77296. */
  77297. clone(): SubEmitter;
  77298. /**
  77299. * Serialize current object to a JSON object
  77300. * @returns the serialized object
  77301. */
  77302. serialize(): any;
  77303. /** @hidden */
  77304. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  77305. /**
  77306. * Creates a new SubEmitter from a serialized JSON version
  77307. * @param serializationObject defines the JSON object to read from
  77308. * @param scene defines the hosting scene
  77309. * @param rootUrl defines the rootUrl for data loading
  77310. * @returns a new SubEmitter
  77311. */
  77312. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  77313. /** Release associated resources */
  77314. dispose(): void;
  77315. }
  77316. }
  77317. declare module BABYLON {
  77318. /** @hidden */
  77319. export var clipPlaneFragmentDeclaration: {
  77320. name: string;
  77321. shader: string;
  77322. };
  77323. }
  77324. declare module BABYLON {
  77325. /** @hidden */
  77326. export var imageProcessingDeclaration: {
  77327. name: string;
  77328. shader: string;
  77329. };
  77330. }
  77331. declare module BABYLON {
  77332. /** @hidden */
  77333. export var imageProcessingFunctions: {
  77334. name: string;
  77335. shader: string;
  77336. };
  77337. }
  77338. declare module BABYLON {
  77339. /** @hidden */
  77340. export var clipPlaneFragment: {
  77341. name: string;
  77342. shader: string;
  77343. };
  77344. }
  77345. declare module BABYLON {
  77346. /** @hidden */
  77347. export var particlesPixelShader: {
  77348. name: string;
  77349. shader: string;
  77350. };
  77351. }
  77352. declare module BABYLON {
  77353. /** @hidden */
  77354. export var clipPlaneVertexDeclaration: {
  77355. name: string;
  77356. shader: string;
  77357. };
  77358. }
  77359. declare module BABYLON {
  77360. /** @hidden */
  77361. export var clipPlaneVertex: {
  77362. name: string;
  77363. shader: string;
  77364. };
  77365. }
  77366. declare module BABYLON {
  77367. /** @hidden */
  77368. export var particlesVertexShader: {
  77369. name: string;
  77370. shader: string;
  77371. };
  77372. }
  77373. declare module BABYLON {
  77374. /**
  77375. * This represents a particle system in Babylon.
  77376. * 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.
  77377. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  77378. * @example https://doc.babylonjs.com/babylon101/particles
  77379. */
  77380. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  77381. /**
  77382. * Billboard mode will only apply to Y axis
  77383. */
  77384. static readonly BILLBOARDMODE_Y: number;
  77385. /**
  77386. * Billboard mode will apply to all axes
  77387. */
  77388. static readonly BILLBOARDMODE_ALL: number;
  77389. /**
  77390. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  77391. */
  77392. static readonly BILLBOARDMODE_STRETCHED: number;
  77393. /**
  77394. * This function can be defined to provide custom update for active particles.
  77395. * This function will be called instead of regular update (age, position, color, etc.).
  77396. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  77397. */
  77398. updateFunction: (particles: Particle[]) => void;
  77399. private _emitterWorldMatrix;
  77400. /**
  77401. * This function can be defined to specify initial direction for every new particle.
  77402. * It by default use the emitterType defined function
  77403. */
  77404. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  77405. /**
  77406. * This function can be defined to specify initial position for every new particle.
  77407. * It by default use the emitterType defined function
  77408. */
  77409. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  77410. /**
  77411. * @hidden
  77412. */
  77413. _inheritedVelocityOffset: Vector3;
  77414. /**
  77415. * An event triggered when the system is disposed
  77416. */
  77417. onDisposeObservable: Observable<ParticleSystem>;
  77418. private _onDisposeObserver;
  77419. /**
  77420. * Sets a callback that will be triggered when the system is disposed
  77421. */
  77422. onDispose: () => void;
  77423. private _particles;
  77424. private _epsilon;
  77425. private _capacity;
  77426. private _stockParticles;
  77427. private _newPartsExcess;
  77428. private _vertexData;
  77429. private _vertexBuffer;
  77430. private _vertexBuffers;
  77431. private _spriteBuffer;
  77432. private _indexBuffer;
  77433. private _effect;
  77434. private _customEffect;
  77435. private _cachedDefines;
  77436. private _scaledColorStep;
  77437. private _colorDiff;
  77438. private _scaledDirection;
  77439. private _scaledGravity;
  77440. private _currentRenderId;
  77441. private _alive;
  77442. private _useInstancing;
  77443. private _started;
  77444. private _stopped;
  77445. private _actualFrame;
  77446. private _scaledUpdateSpeed;
  77447. private _vertexBufferSize;
  77448. /** @hidden */
  77449. _currentEmitRateGradient: Nullable<FactorGradient>;
  77450. /** @hidden */
  77451. _currentEmitRate1: number;
  77452. /** @hidden */
  77453. _currentEmitRate2: number;
  77454. /** @hidden */
  77455. _currentStartSizeGradient: Nullable<FactorGradient>;
  77456. /** @hidden */
  77457. _currentStartSize1: number;
  77458. /** @hidden */
  77459. _currentStartSize2: number;
  77460. private readonly _rawTextureWidth;
  77461. private _rampGradientsTexture;
  77462. private _useRampGradients;
  77463. /** Gets or sets a boolean indicating that ramp gradients must be used
  77464. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  77465. */
  77466. useRampGradients: boolean;
  77467. /**
  77468. * 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.
  77469. * 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: [])
  77470. */
  77471. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  77472. private _subEmitters;
  77473. /**
  77474. * @hidden
  77475. * If the particle systems emitter should be disposed when the particle system is disposed
  77476. */
  77477. _disposeEmitterOnDispose: boolean;
  77478. /**
  77479. * The current active Sub-systems, this property is used by the root particle system only.
  77480. */
  77481. activeSubSystems: Array<ParticleSystem>;
  77482. private _rootParticleSystem;
  77483. /**
  77484. * Gets the current list of active particles
  77485. */
  77486. readonly particles: Particle[];
  77487. /**
  77488. * Returns the string "ParticleSystem"
  77489. * @returns a string containing the class name
  77490. */
  77491. getClassName(): string;
  77492. /**
  77493. * Instantiates a particle system.
  77494. * 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.
  77495. * @param name The name of the particle system
  77496. * @param capacity The max number of particles alive at the same time
  77497. * @param scene The scene the particle system belongs to
  77498. * @param customEffect a custom effect used to change the way particles are rendered by default
  77499. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  77500. * @param epsilon Offset used to render the particles
  77501. */
  77502. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  77503. private _addFactorGradient;
  77504. private _removeFactorGradient;
  77505. /**
  77506. * Adds a new life time gradient
  77507. * @param gradient defines the gradient to use (between 0 and 1)
  77508. * @param factor defines the life time factor to affect to the specified gradient
  77509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77510. * @returns the current particle system
  77511. */
  77512. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77513. /**
  77514. * Remove a specific life time gradient
  77515. * @param gradient defines the gradient to remove
  77516. * @returns the current particle system
  77517. */
  77518. removeLifeTimeGradient(gradient: number): IParticleSystem;
  77519. /**
  77520. * Adds a new size gradient
  77521. * @param gradient defines the gradient to use (between 0 and 1)
  77522. * @param factor defines the size factor to affect to the specified gradient
  77523. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77524. * @returns the current particle system
  77525. */
  77526. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77527. /**
  77528. * Remove a specific size gradient
  77529. * @param gradient defines the gradient to remove
  77530. * @returns the current particle system
  77531. */
  77532. removeSizeGradient(gradient: number): IParticleSystem;
  77533. /**
  77534. * Adds a new color remap gradient
  77535. * @param gradient defines the gradient to use (between 0 and 1)
  77536. * @param min defines the color remap minimal range
  77537. * @param max defines the color remap maximal range
  77538. * @returns the current particle system
  77539. */
  77540. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77541. /**
  77542. * Remove a specific color remap gradient
  77543. * @param gradient defines the gradient to remove
  77544. * @returns the current particle system
  77545. */
  77546. removeColorRemapGradient(gradient: number): IParticleSystem;
  77547. /**
  77548. * Adds a new alpha remap gradient
  77549. * @param gradient defines the gradient to use (between 0 and 1)
  77550. * @param min defines the alpha remap minimal range
  77551. * @param max defines the alpha remap maximal range
  77552. * @returns the current particle system
  77553. */
  77554. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77555. /**
  77556. * Remove a specific alpha remap gradient
  77557. * @param gradient defines the gradient to remove
  77558. * @returns the current particle system
  77559. */
  77560. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  77561. /**
  77562. * Adds a new angular speed gradient
  77563. * @param gradient defines the gradient to use (between 0 and 1)
  77564. * @param factor defines the angular speed to affect to the specified gradient
  77565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77566. * @returns the current particle system
  77567. */
  77568. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77569. /**
  77570. * Remove a specific angular speed gradient
  77571. * @param gradient defines the gradient to remove
  77572. * @returns the current particle system
  77573. */
  77574. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  77575. /**
  77576. * Adds a new velocity gradient
  77577. * @param gradient defines the gradient to use (between 0 and 1)
  77578. * @param factor defines the velocity to affect to the specified gradient
  77579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77580. * @returns the current particle system
  77581. */
  77582. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77583. /**
  77584. * Remove a specific velocity gradient
  77585. * @param gradient defines the gradient to remove
  77586. * @returns the current particle system
  77587. */
  77588. removeVelocityGradient(gradient: number): IParticleSystem;
  77589. /**
  77590. * Adds a new limit velocity gradient
  77591. * @param gradient defines the gradient to use (between 0 and 1)
  77592. * @param factor defines the limit velocity value to affect to the specified gradient
  77593. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77594. * @returns the current particle system
  77595. */
  77596. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77597. /**
  77598. * Remove a specific limit velocity gradient
  77599. * @param gradient defines the gradient to remove
  77600. * @returns the current particle system
  77601. */
  77602. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  77603. /**
  77604. * Adds a new drag gradient
  77605. * @param gradient defines the gradient to use (between 0 and 1)
  77606. * @param factor defines the drag value to affect to the specified gradient
  77607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77608. * @returns the current particle system
  77609. */
  77610. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77611. /**
  77612. * Remove a specific drag gradient
  77613. * @param gradient defines the gradient to remove
  77614. * @returns the current particle system
  77615. */
  77616. removeDragGradient(gradient: number): IParticleSystem;
  77617. /**
  77618. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  77619. * @param gradient defines the gradient to use (between 0 and 1)
  77620. * @param factor defines the emit rate value to affect to the specified gradient
  77621. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77622. * @returns the current particle system
  77623. */
  77624. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77625. /**
  77626. * Remove a specific emit rate gradient
  77627. * @param gradient defines the gradient to remove
  77628. * @returns the current particle system
  77629. */
  77630. removeEmitRateGradient(gradient: number): IParticleSystem;
  77631. /**
  77632. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  77633. * @param gradient defines the gradient to use (between 0 and 1)
  77634. * @param factor defines the start size value to affect to the specified gradient
  77635. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77636. * @returns the current particle system
  77637. */
  77638. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77639. /**
  77640. * Remove a specific start size gradient
  77641. * @param gradient defines the gradient to remove
  77642. * @returns the current particle system
  77643. */
  77644. removeStartSizeGradient(gradient: number): IParticleSystem;
  77645. private _createRampGradientTexture;
  77646. /**
  77647. * Gets the current list of ramp gradients.
  77648. * You must use addRampGradient and removeRampGradient to udpate this list
  77649. * @returns the list of ramp gradients
  77650. */
  77651. getRampGradients(): Nullable<Array<Color3Gradient>>;
  77652. /**
  77653. * Adds a new ramp gradient used to remap particle colors
  77654. * @param gradient defines the gradient to use (between 0 and 1)
  77655. * @param color defines the color to affect to the specified gradient
  77656. * @returns the current particle system
  77657. */
  77658. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  77659. /**
  77660. * Remove a specific ramp gradient
  77661. * @param gradient defines the gradient to remove
  77662. * @returns the current particle system
  77663. */
  77664. removeRampGradient(gradient: number): ParticleSystem;
  77665. /**
  77666. * Adds a new color gradient
  77667. * @param gradient defines the gradient to use (between 0 and 1)
  77668. * @param color1 defines the color to affect to the specified gradient
  77669. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  77670. * @returns this particle system
  77671. */
  77672. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  77673. /**
  77674. * Remove a specific color gradient
  77675. * @param gradient defines the gradient to remove
  77676. * @returns this particle system
  77677. */
  77678. removeColorGradient(gradient: number): IParticleSystem;
  77679. private _fetchR;
  77680. protected _reset(): void;
  77681. private _resetEffect;
  77682. private _createVertexBuffers;
  77683. private _createIndexBuffer;
  77684. /**
  77685. * Gets the maximum number of particles active at the same time.
  77686. * @returns The max number of active particles.
  77687. */
  77688. getCapacity(): number;
  77689. /**
  77690. * Gets whether there are still active particles in the system.
  77691. * @returns True if it is alive, otherwise false.
  77692. */
  77693. isAlive(): boolean;
  77694. /**
  77695. * Gets if the system has been started. (Note: this will still be true after stop is called)
  77696. * @returns True if it has been started, otherwise false.
  77697. */
  77698. isStarted(): boolean;
  77699. private _prepareSubEmitterInternalArray;
  77700. /**
  77701. * Starts the particle system and begins to emit
  77702. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  77703. */
  77704. start(delay?: number): void;
  77705. /**
  77706. * Stops the particle system.
  77707. * @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.
  77708. */
  77709. stop(stopSubEmitters?: boolean): void;
  77710. /**
  77711. * Remove all active particles
  77712. */
  77713. reset(): void;
  77714. /**
  77715. * @hidden (for internal use only)
  77716. */
  77717. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  77718. /**
  77719. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  77720. * Its lifetime will start back at 0.
  77721. */
  77722. recycleParticle: (particle: Particle) => void;
  77723. private _stopSubEmitters;
  77724. private _createParticle;
  77725. private _removeFromRoot;
  77726. private _emitFromParticle;
  77727. private _update;
  77728. /** @hidden */
  77729. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  77730. /** @hidden */
  77731. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  77732. /** @hidden */
  77733. private _getEffect;
  77734. /**
  77735. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  77736. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  77737. */
  77738. animate(preWarmOnly?: boolean): void;
  77739. private _appendParticleVertices;
  77740. /**
  77741. * Rebuilds the particle system.
  77742. */
  77743. rebuild(): void;
  77744. /**
  77745. * Is this system ready to be used/rendered
  77746. * @return true if the system is ready
  77747. */
  77748. isReady(): boolean;
  77749. private _render;
  77750. /**
  77751. * Renders the particle system in its current state.
  77752. * @returns the current number of particles
  77753. */
  77754. render(): number;
  77755. /**
  77756. * Disposes the particle system and free the associated resources
  77757. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  77758. */
  77759. dispose(disposeTexture?: boolean): void;
  77760. /**
  77761. * Clones the particle system.
  77762. * @param name The name of the cloned object
  77763. * @param newEmitter The new emitter to use
  77764. * @returns the cloned particle system
  77765. */
  77766. clone(name: string, newEmitter: any): ParticleSystem;
  77767. /**
  77768. * Serializes the particle system to a JSON object.
  77769. * @returns the JSON object
  77770. */
  77771. serialize(): any;
  77772. /** @hidden */
  77773. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  77774. /** @hidden */
  77775. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  77776. /**
  77777. * Parses a JSON object to create a particle system.
  77778. * @param parsedParticleSystem The JSON object to parse
  77779. * @param scene The scene to create the particle system in
  77780. * @param rootUrl The root url to use to load external dependencies like texture
  77781. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  77782. * @returns the Parsed particle system
  77783. */
  77784. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  77785. }
  77786. }
  77787. declare module BABYLON {
  77788. /**
  77789. * A particle represents one of the element emitted by a particle system.
  77790. * This is mainly define by its coordinates, direction, velocity and age.
  77791. */
  77792. export class Particle {
  77793. /**
  77794. * The particle system the particle belongs to.
  77795. */
  77796. particleSystem: ParticleSystem;
  77797. private static _Count;
  77798. /**
  77799. * Unique ID of the particle
  77800. */
  77801. id: number;
  77802. /**
  77803. * The world position of the particle in the scene.
  77804. */
  77805. position: Vector3;
  77806. /**
  77807. * The world direction of the particle in the scene.
  77808. */
  77809. direction: Vector3;
  77810. /**
  77811. * The color of the particle.
  77812. */
  77813. color: Color4;
  77814. /**
  77815. * The color change of the particle per step.
  77816. */
  77817. colorStep: Color4;
  77818. /**
  77819. * Defines how long will the life of the particle be.
  77820. */
  77821. lifeTime: number;
  77822. /**
  77823. * The current age of the particle.
  77824. */
  77825. age: number;
  77826. /**
  77827. * The current size of the particle.
  77828. */
  77829. size: number;
  77830. /**
  77831. * The current scale of the particle.
  77832. */
  77833. scale: Vector2;
  77834. /**
  77835. * The current angle of the particle.
  77836. */
  77837. angle: number;
  77838. /**
  77839. * Defines how fast is the angle changing.
  77840. */
  77841. angularSpeed: number;
  77842. /**
  77843. * Defines the cell index used by the particle to be rendered from a sprite.
  77844. */
  77845. cellIndex: number;
  77846. /**
  77847. * The information required to support color remapping
  77848. */
  77849. remapData: Vector4;
  77850. /** @hidden */
  77851. _randomCellOffset?: number;
  77852. /** @hidden */
  77853. _initialDirection: Nullable<Vector3>;
  77854. /** @hidden */
  77855. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  77856. /** @hidden */
  77857. _initialStartSpriteCellID: number;
  77858. /** @hidden */
  77859. _initialEndSpriteCellID: number;
  77860. /** @hidden */
  77861. _currentColorGradient: Nullable<ColorGradient>;
  77862. /** @hidden */
  77863. _currentColor1: Color4;
  77864. /** @hidden */
  77865. _currentColor2: Color4;
  77866. /** @hidden */
  77867. _currentSizeGradient: Nullable<FactorGradient>;
  77868. /** @hidden */
  77869. _currentSize1: number;
  77870. /** @hidden */
  77871. _currentSize2: number;
  77872. /** @hidden */
  77873. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  77874. /** @hidden */
  77875. _currentAngularSpeed1: number;
  77876. /** @hidden */
  77877. _currentAngularSpeed2: number;
  77878. /** @hidden */
  77879. _currentVelocityGradient: Nullable<FactorGradient>;
  77880. /** @hidden */
  77881. _currentVelocity1: number;
  77882. /** @hidden */
  77883. _currentVelocity2: number;
  77884. /** @hidden */
  77885. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  77886. /** @hidden */
  77887. _currentLimitVelocity1: number;
  77888. /** @hidden */
  77889. _currentLimitVelocity2: number;
  77890. /** @hidden */
  77891. _currentDragGradient: Nullable<FactorGradient>;
  77892. /** @hidden */
  77893. _currentDrag1: number;
  77894. /** @hidden */
  77895. _currentDrag2: number;
  77896. /** @hidden */
  77897. _randomNoiseCoordinates1: Vector3;
  77898. /** @hidden */
  77899. _randomNoiseCoordinates2: Vector3;
  77900. /**
  77901. * Creates a new instance Particle
  77902. * @param particleSystem the particle system the particle belongs to
  77903. */
  77904. constructor(
  77905. /**
  77906. * The particle system the particle belongs to.
  77907. */
  77908. particleSystem: ParticleSystem);
  77909. private updateCellInfoFromSystem;
  77910. /**
  77911. * Defines how the sprite cell index is updated for the particle
  77912. */
  77913. updateCellIndex(): void;
  77914. /** @hidden */
  77915. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  77916. /** @hidden */
  77917. _inheritParticleInfoToSubEmitters(): void;
  77918. /** @hidden */
  77919. _reset(): void;
  77920. /**
  77921. * Copy the properties of particle to another one.
  77922. * @param other the particle to copy the information to.
  77923. */
  77924. copyTo(other: Particle): void;
  77925. }
  77926. }
  77927. declare module BABYLON {
  77928. /**
  77929. * Particle emitter represents a volume emitting particles.
  77930. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  77931. */
  77932. export interface IParticleEmitterType {
  77933. /**
  77934. * Called by the particle System when the direction is computed for the created particle.
  77935. * @param worldMatrix is the world matrix of the particle system
  77936. * @param directionToUpdate is the direction vector to update with the result
  77937. * @param particle is the particle we are computed the direction for
  77938. */
  77939. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77940. /**
  77941. * Called by the particle System when the position is computed for the created particle.
  77942. * @param worldMatrix is the world matrix of the particle system
  77943. * @param positionToUpdate is the position vector to update with the result
  77944. * @param particle is the particle we are computed the position for
  77945. */
  77946. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77947. /**
  77948. * Clones the current emitter and returns a copy of it
  77949. * @returns the new emitter
  77950. */
  77951. clone(): IParticleEmitterType;
  77952. /**
  77953. * Called by the GPUParticleSystem to setup the update shader
  77954. * @param effect defines the update shader
  77955. */
  77956. applyToShader(effect: Effect): void;
  77957. /**
  77958. * Returns a string to use to update the GPU particles update shader
  77959. * @returns the effect defines string
  77960. */
  77961. getEffectDefines(): string;
  77962. /**
  77963. * Returns a string representing the class name
  77964. * @returns a string containing the class name
  77965. */
  77966. getClassName(): string;
  77967. /**
  77968. * Serializes the particle system to a JSON object.
  77969. * @returns the JSON object
  77970. */
  77971. serialize(): any;
  77972. /**
  77973. * Parse properties from a JSON object
  77974. * @param serializationObject defines the JSON object
  77975. */
  77976. parse(serializationObject: any): void;
  77977. }
  77978. }
  77979. declare module BABYLON {
  77980. /**
  77981. * Particle emitter emitting particles from the inside of a box.
  77982. * It emits the particles randomly between 2 given directions.
  77983. */
  77984. export class BoxParticleEmitter implements IParticleEmitterType {
  77985. /**
  77986. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77987. */
  77988. direction1: Vector3;
  77989. /**
  77990. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77991. */
  77992. direction2: Vector3;
  77993. /**
  77994. * 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.
  77995. */
  77996. minEmitBox: Vector3;
  77997. /**
  77998. * 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.
  77999. */
  78000. maxEmitBox: Vector3;
  78001. /**
  78002. * Creates a new instance BoxParticleEmitter
  78003. */
  78004. constructor();
  78005. /**
  78006. * Called by the particle System when the direction is computed for the created particle.
  78007. * @param worldMatrix is the world matrix of the particle system
  78008. * @param directionToUpdate is the direction vector to update with the result
  78009. * @param particle is the particle we are computed the direction for
  78010. */
  78011. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78012. /**
  78013. * Called by the particle System when the position is computed for the created particle.
  78014. * @param worldMatrix is the world matrix of the particle system
  78015. * @param positionToUpdate is the position vector to update with the result
  78016. * @param particle is the particle we are computed the position for
  78017. */
  78018. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78019. /**
  78020. * Clones the current emitter and returns a copy of it
  78021. * @returns the new emitter
  78022. */
  78023. clone(): BoxParticleEmitter;
  78024. /**
  78025. * Called by the GPUParticleSystem to setup the update shader
  78026. * @param effect defines the update shader
  78027. */
  78028. applyToShader(effect: Effect): void;
  78029. /**
  78030. * Returns a string to use to update the GPU particles update shader
  78031. * @returns a string containng the defines string
  78032. */
  78033. getEffectDefines(): string;
  78034. /**
  78035. * Returns the string "BoxParticleEmitter"
  78036. * @returns a string containing the class name
  78037. */
  78038. getClassName(): string;
  78039. /**
  78040. * Serializes the particle system to a JSON object.
  78041. * @returns the JSON object
  78042. */
  78043. serialize(): any;
  78044. /**
  78045. * Parse properties from a JSON object
  78046. * @param serializationObject defines the JSON object
  78047. */
  78048. parse(serializationObject: any): void;
  78049. }
  78050. }
  78051. declare module BABYLON {
  78052. /**
  78053. * Particle emitter emitting particles from the inside of a cone.
  78054. * It emits the particles alongside the cone volume from the base to the particle.
  78055. * The emission direction might be randomized.
  78056. */
  78057. export class ConeParticleEmitter implements IParticleEmitterType {
  78058. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  78059. directionRandomizer: number;
  78060. private _radius;
  78061. private _angle;
  78062. private _height;
  78063. /**
  78064. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  78065. */
  78066. radiusRange: number;
  78067. /**
  78068. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  78069. */
  78070. heightRange: number;
  78071. /**
  78072. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  78073. */
  78074. emitFromSpawnPointOnly: boolean;
  78075. /**
  78076. * Gets or sets the radius of the emission cone
  78077. */
  78078. radius: number;
  78079. /**
  78080. * Gets or sets the angle of the emission cone
  78081. */
  78082. angle: number;
  78083. private _buildHeight;
  78084. /**
  78085. * Creates a new instance ConeParticleEmitter
  78086. * @param radius the radius of the emission cone (1 by default)
  78087. * @param angle the cone base angle (PI by default)
  78088. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  78089. */
  78090. constructor(radius?: number, angle?: number,
  78091. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  78092. directionRandomizer?: number);
  78093. /**
  78094. * Called by the particle System when the direction is computed for the created particle.
  78095. * @param worldMatrix is the world matrix of the particle system
  78096. * @param directionToUpdate is the direction vector to update with the result
  78097. * @param particle is the particle we are computed the direction for
  78098. */
  78099. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78100. /**
  78101. * Called by the particle System when the position is computed for the created particle.
  78102. * @param worldMatrix is the world matrix of the particle system
  78103. * @param positionToUpdate is the position vector to update with the result
  78104. * @param particle is the particle we are computed the position for
  78105. */
  78106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78107. /**
  78108. * Clones the current emitter and returns a copy of it
  78109. * @returns the new emitter
  78110. */
  78111. clone(): ConeParticleEmitter;
  78112. /**
  78113. * Called by the GPUParticleSystem to setup the update shader
  78114. * @param effect defines the update shader
  78115. */
  78116. applyToShader(effect: Effect): void;
  78117. /**
  78118. * Returns a string to use to update the GPU particles update shader
  78119. * @returns a string containng the defines string
  78120. */
  78121. getEffectDefines(): string;
  78122. /**
  78123. * Returns the string "ConeParticleEmitter"
  78124. * @returns a string containing the class name
  78125. */
  78126. getClassName(): string;
  78127. /**
  78128. * Serializes the particle system to a JSON object.
  78129. * @returns the JSON object
  78130. */
  78131. serialize(): any;
  78132. /**
  78133. * Parse properties from a JSON object
  78134. * @param serializationObject defines the JSON object
  78135. */
  78136. parse(serializationObject: any): void;
  78137. }
  78138. }
  78139. declare module BABYLON {
  78140. /**
  78141. * Particle emitter emitting particles from the inside of a cylinder.
  78142. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  78143. */
  78144. export class CylinderParticleEmitter implements IParticleEmitterType {
  78145. /**
  78146. * The radius of the emission cylinder.
  78147. */
  78148. radius: number;
  78149. /**
  78150. * The height of the emission cylinder.
  78151. */
  78152. height: number;
  78153. /**
  78154. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78155. */
  78156. radiusRange: number;
  78157. /**
  78158. * How much to randomize the particle direction [0-1].
  78159. */
  78160. directionRandomizer: number;
  78161. /**
  78162. * Creates a new instance CylinderParticleEmitter
  78163. * @param radius the radius of the emission cylinder (1 by default)
  78164. * @param height the height of the emission cylinder (1 by default)
  78165. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78166. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78167. */
  78168. constructor(
  78169. /**
  78170. * The radius of the emission cylinder.
  78171. */
  78172. radius?: number,
  78173. /**
  78174. * The height of the emission cylinder.
  78175. */
  78176. height?: number,
  78177. /**
  78178. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78179. */
  78180. radiusRange?: number,
  78181. /**
  78182. * How much to randomize the particle direction [0-1].
  78183. */
  78184. directionRandomizer?: number);
  78185. /**
  78186. * Called by the particle System when the direction is computed for the created particle.
  78187. * @param worldMatrix is the world matrix of the particle system
  78188. * @param directionToUpdate is the direction vector to update with the result
  78189. * @param particle is the particle we are computed the direction for
  78190. */
  78191. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78192. /**
  78193. * Called by the particle System when the position is computed for the created particle.
  78194. * @param worldMatrix is the world matrix of the particle system
  78195. * @param positionToUpdate is the position vector to update with the result
  78196. * @param particle is the particle we are computed the position for
  78197. */
  78198. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78199. /**
  78200. * Clones the current emitter and returns a copy of it
  78201. * @returns the new emitter
  78202. */
  78203. clone(): CylinderParticleEmitter;
  78204. /**
  78205. * Called by the GPUParticleSystem to setup the update shader
  78206. * @param effect defines the update shader
  78207. */
  78208. applyToShader(effect: Effect): void;
  78209. /**
  78210. * Returns a string to use to update the GPU particles update shader
  78211. * @returns a string containng the defines string
  78212. */
  78213. getEffectDefines(): string;
  78214. /**
  78215. * Returns the string "CylinderParticleEmitter"
  78216. * @returns a string containing the class name
  78217. */
  78218. getClassName(): string;
  78219. /**
  78220. * Serializes the particle system to a JSON object.
  78221. * @returns the JSON object
  78222. */
  78223. serialize(): any;
  78224. /**
  78225. * Parse properties from a JSON object
  78226. * @param serializationObject defines the JSON object
  78227. */
  78228. parse(serializationObject: any): void;
  78229. }
  78230. /**
  78231. * Particle emitter emitting particles from the inside of a cylinder.
  78232. * It emits the particles randomly between two vectors.
  78233. */
  78234. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  78235. /**
  78236. * The min limit of the emission direction.
  78237. */
  78238. direction1: Vector3;
  78239. /**
  78240. * The max limit of the emission direction.
  78241. */
  78242. direction2: Vector3;
  78243. /**
  78244. * Creates a new instance CylinderDirectedParticleEmitter
  78245. * @param radius the radius of the emission cylinder (1 by default)
  78246. * @param height the height of the emission cylinder (1 by default)
  78247. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78248. * @param direction1 the min limit of the emission direction (up vector by default)
  78249. * @param direction2 the max limit of the emission direction (up vector by default)
  78250. */
  78251. constructor(radius?: number, height?: number, radiusRange?: number,
  78252. /**
  78253. * The min limit of the emission direction.
  78254. */
  78255. direction1?: Vector3,
  78256. /**
  78257. * The max limit of the emission direction.
  78258. */
  78259. direction2?: Vector3);
  78260. /**
  78261. * Called by the particle System when the direction is computed for the created particle.
  78262. * @param worldMatrix is the world matrix of the particle system
  78263. * @param directionToUpdate is the direction vector to update with the result
  78264. * @param particle is the particle we are computed the direction for
  78265. */
  78266. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78267. /**
  78268. * Clones the current emitter and returns a copy of it
  78269. * @returns the new emitter
  78270. */
  78271. clone(): CylinderDirectedParticleEmitter;
  78272. /**
  78273. * Called by the GPUParticleSystem to setup the update shader
  78274. * @param effect defines the update shader
  78275. */
  78276. applyToShader(effect: Effect): void;
  78277. /**
  78278. * Returns a string to use to update the GPU particles update shader
  78279. * @returns a string containng the defines string
  78280. */
  78281. getEffectDefines(): string;
  78282. /**
  78283. * Returns the string "CylinderDirectedParticleEmitter"
  78284. * @returns a string containing the class name
  78285. */
  78286. getClassName(): string;
  78287. /**
  78288. * Serializes the particle system to a JSON object.
  78289. * @returns the JSON object
  78290. */
  78291. serialize(): any;
  78292. /**
  78293. * Parse properties from a JSON object
  78294. * @param serializationObject defines the JSON object
  78295. */
  78296. parse(serializationObject: any): void;
  78297. }
  78298. }
  78299. declare module BABYLON {
  78300. /**
  78301. * Particle emitter emitting particles from the inside of a hemisphere.
  78302. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  78303. */
  78304. export class HemisphericParticleEmitter implements IParticleEmitterType {
  78305. /**
  78306. * The radius of the emission hemisphere.
  78307. */
  78308. radius: number;
  78309. /**
  78310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78311. */
  78312. radiusRange: number;
  78313. /**
  78314. * How much to randomize the particle direction [0-1].
  78315. */
  78316. directionRandomizer: number;
  78317. /**
  78318. * Creates a new instance HemisphericParticleEmitter
  78319. * @param radius the radius of the emission hemisphere (1 by default)
  78320. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78321. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78322. */
  78323. constructor(
  78324. /**
  78325. * The radius of the emission hemisphere.
  78326. */
  78327. radius?: number,
  78328. /**
  78329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78330. */
  78331. radiusRange?: number,
  78332. /**
  78333. * How much to randomize the particle direction [0-1].
  78334. */
  78335. directionRandomizer?: number);
  78336. /**
  78337. * Called by the particle System when the direction is computed for the created particle.
  78338. * @param worldMatrix is the world matrix of the particle system
  78339. * @param directionToUpdate is the direction vector to update with the result
  78340. * @param particle is the particle we are computed the direction for
  78341. */
  78342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78343. /**
  78344. * Called by the particle System when the position is computed for the created particle.
  78345. * @param worldMatrix is the world matrix of the particle system
  78346. * @param positionToUpdate is the position vector to update with the result
  78347. * @param particle is the particle we are computed the position for
  78348. */
  78349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78350. /**
  78351. * Clones the current emitter and returns a copy of it
  78352. * @returns the new emitter
  78353. */
  78354. clone(): HemisphericParticleEmitter;
  78355. /**
  78356. * Called by the GPUParticleSystem to setup the update shader
  78357. * @param effect defines the update shader
  78358. */
  78359. applyToShader(effect: Effect): void;
  78360. /**
  78361. * Returns a string to use to update the GPU particles update shader
  78362. * @returns a string containng the defines string
  78363. */
  78364. getEffectDefines(): string;
  78365. /**
  78366. * Returns the string "HemisphericParticleEmitter"
  78367. * @returns a string containing the class name
  78368. */
  78369. getClassName(): string;
  78370. /**
  78371. * Serializes the particle system to a JSON object.
  78372. * @returns the JSON object
  78373. */
  78374. serialize(): any;
  78375. /**
  78376. * Parse properties from a JSON object
  78377. * @param serializationObject defines the JSON object
  78378. */
  78379. parse(serializationObject: any): void;
  78380. }
  78381. }
  78382. declare module BABYLON {
  78383. /**
  78384. * Particle emitter emitting particles from a point.
  78385. * It emits the particles randomly between 2 given directions.
  78386. */
  78387. export class PointParticleEmitter implements IParticleEmitterType {
  78388. /**
  78389. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  78390. */
  78391. direction1: Vector3;
  78392. /**
  78393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  78394. */
  78395. direction2: Vector3;
  78396. /**
  78397. * Creates a new instance PointParticleEmitter
  78398. */
  78399. constructor();
  78400. /**
  78401. * Called by the particle System when the direction is computed for the created particle.
  78402. * @param worldMatrix is the world matrix of the particle system
  78403. * @param directionToUpdate is the direction vector to update with the result
  78404. * @param particle is the particle we are computed the direction for
  78405. */
  78406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78407. /**
  78408. * Called by the particle System when the position is computed for the created particle.
  78409. * @param worldMatrix is the world matrix of the particle system
  78410. * @param positionToUpdate is the position vector to update with the result
  78411. * @param particle is the particle we are computed the position for
  78412. */
  78413. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78414. /**
  78415. * Clones the current emitter and returns a copy of it
  78416. * @returns the new emitter
  78417. */
  78418. clone(): PointParticleEmitter;
  78419. /**
  78420. * Called by the GPUParticleSystem to setup the update shader
  78421. * @param effect defines the update shader
  78422. */
  78423. applyToShader(effect: Effect): void;
  78424. /**
  78425. * Returns a string to use to update the GPU particles update shader
  78426. * @returns a string containng the defines string
  78427. */
  78428. getEffectDefines(): string;
  78429. /**
  78430. * Returns the string "PointParticleEmitter"
  78431. * @returns a string containing the class name
  78432. */
  78433. getClassName(): string;
  78434. /**
  78435. * Serializes the particle system to a JSON object.
  78436. * @returns the JSON object
  78437. */
  78438. serialize(): any;
  78439. /**
  78440. * Parse properties from a JSON object
  78441. * @param serializationObject defines the JSON object
  78442. */
  78443. parse(serializationObject: any): void;
  78444. }
  78445. }
  78446. declare module BABYLON {
  78447. /**
  78448. * Particle emitter emitting particles from the inside of a sphere.
  78449. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  78450. */
  78451. export class SphereParticleEmitter implements IParticleEmitterType {
  78452. /**
  78453. * The radius of the emission sphere.
  78454. */
  78455. radius: number;
  78456. /**
  78457. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78458. */
  78459. radiusRange: number;
  78460. /**
  78461. * How much to randomize the particle direction [0-1].
  78462. */
  78463. directionRandomizer: number;
  78464. /**
  78465. * Creates a new instance SphereParticleEmitter
  78466. * @param radius the radius of the emission sphere (1 by default)
  78467. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78468. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78469. */
  78470. constructor(
  78471. /**
  78472. * The radius of the emission sphere.
  78473. */
  78474. radius?: number,
  78475. /**
  78476. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78477. */
  78478. radiusRange?: number,
  78479. /**
  78480. * How much to randomize the particle direction [0-1].
  78481. */
  78482. directionRandomizer?: number);
  78483. /**
  78484. * Called by the particle System when the direction is computed for the created particle.
  78485. * @param worldMatrix is the world matrix of the particle system
  78486. * @param directionToUpdate is the direction vector to update with the result
  78487. * @param particle is the particle we are computed the direction for
  78488. */
  78489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78490. /**
  78491. * Called by the particle System when the position is computed for the created particle.
  78492. * @param worldMatrix is the world matrix of the particle system
  78493. * @param positionToUpdate is the position vector to update with the result
  78494. * @param particle is the particle we are computed the position for
  78495. */
  78496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78497. /**
  78498. * Clones the current emitter and returns a copy of it
  78499. * @returns the new emitter
  78500. */
  78501. clone(): SphereParticleEmitter;
  78502. /**
  78503. * Called by the GPUParticleSystem to setup the update shader
  78504. * @param effect defines the update shader
  78505. */
  78506. applyToShader(effect: Effect): void;
  78507. /**
  78508. * Returns a string to use to update the GPU particles update shader
  78509. * @returns a string containng the defines string
  78510. */
  78511. getEffectDefines(): string;
  78512. /**
  78513. * Returns the string "SphereParticleEmitter"
  78514. * @returns a string containing the class name
  78515. */
  78516. getClassName(): string;
  78517. /**
  78518. * Serializes the particle system to a JSON object.
  78519. * @returns the JSON object
  78520. */
  78521. serialize(): any;
  78522. /**
  78523. * Parse properties from a JSON object
  78524. * @param serializationObject defines the JSON object
  78525. */
  78526. parse(serializationObject: any): void;
  78527. }
  78528. /**
  78529. * Particle emitter emitting particles from the inside of a sphere.
  78530. * It emits the particles randomly between two vectors.
  78531. */
  78532. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  78533. /**
  78534. * The min limit of the emission direction.
  78535. */
  78536. direction1: Vector3;
  78537. /**
  78538. * The max limit of the emission direction.
  78539. */
  78540. direction2: Vector3;
  78541. /**
  78542. * Creates a new instance SphereDirectedParticleEmitter
  78543. * @param radius the radius of the emission sphere (1 by default)
  78544. * @param direction1 the min limit of the emission direction (up vector by default)
  78545. * @param direction2 the max limit of the emission direction (up vector by default)
  78546. */
  78547. constructor(radius?: number,
  78548. /**
  78549. * The min limit of the emission direction.
  78550. */
  78551. direction1?: Vector3,
  78552. /**
  78553. * The max limit of the emission direction.
  78554. */
  78555. direction2?: Vector3);
  78556. /**
  78557. * Called by the particle System when the direction is computed for the created particle.
  78558. * @param worldMatrix is the world matrix of the particle system
  78559. * @param directionToUpdate is the direction vector to update with the result
  78560. * @param particle is the particle we are computed the direction for
  78561. */
  78562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78563. /**
  78564. * Clones the current emitter and returns a copy of it
  78565. * @returns the new emitter
  78566. */
  78567. clone(): SphereDirectedParticleEmitter;
  78568. /**
  78569. * Called by the GPUParticleSystem to setup the update shader
  78570. * @param effect defines the update shader
  78571. */
  78572. applyToShader(effect: Effect): void;
  78573. /**
  78574. * Returns a string to use to update the GPU particles update shader
  78575. * @returns a string containng the defines string
  78576. */
  78577. getEffectDefines(): string;
  78578. /**
  78579. * Returns the string "SphereDirectedParticleEmitter"
  78580. * @returns a string containing the class name
  78581. */
  78582. getClassName(): string;
  78583. /**
  78584. * Serializes the particle system to a JSON object.
  78585. * @returns the JSON object
  78586. */
  78587. serialize(): any;
  78588. /**
  78589. * Parse properties from a JSON object
  78590. * @param serializationObject defines the JSON object
  78591. */
  78592. parse(serializationObject: any): void;
  78593. }
  78594. }
  78595. declare module BABYLON {
  78596. /**
  78597. * Interface representing a particle system in Babylon.js.
  78598. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  78599. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  78600. */
  78601. export interface IParticleSystem {
  78602. /**
  78603. * List of animations used by the particle system.
  78604. */
  78605. animations: Animation[];
  78606. /**
  78607. * The id of the Particle system.
  78608. */
  78609. id: string;
  78610. /**
  78611. * The name of the Particle system.
  78612. */
  78613. name: string;
  78614. /**
  78615. * The emitter represents the Mesh or position we are attaching the particle system to.
  78616. */
  78617. emitter: Nullable<AbstractMesh | Vector3>;
  78618. /**
  78619. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  78620. */
  78621. isBillboardBased: boolean;
  78622. /**
  78623. * The rendering group used by the Particle system to chose when to render.
  78624. */
  78625. renderingGroupId: number;
  78626. /**
  78627. * The layer mask we are rendering the particles through.
  78628. */
  78629. layerMask: number;
  78630. /**
  78631. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  78632. */
  78633. updateSpeed: number;
  78634. /**
  78635. * The amount of time the particle system is running (depends of the overall update speed).
  78636. */
  78637. targetStopDuration: number;
  78638. /**
  78639. * The texture used to render each particle. (this can be a spritesheet)
  78640. */
  78641. particleTexture: Nullable<Texture>;
  78642. /**
  78643. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  78644. */
  78645. blendMode: number;
  78646. /**
  78647. * Minimum life time of emitting particles.
  78648. */
  78649. minLifeTime: number;
  78650. /**
  78651. * Maximum life time of emitting particles.
  78652. */
  78653. maxLifeTime: number;
  78654. /**
  78655. * Minimum Size of emitting particles.
  78656. */
  78657. minSize: number;
  78658. /**
  78659. * Maximum Size of emitting particles.
  78660. */
  78661. maxSize: number;
  78662. /**
  78663. * Minimum scale of emitting particles on X axis.
  78664. */
  78665. minScaleX: number;
  78666. /**
  78667. * Maximum scale of emitting particles on X axis.
  78668. */
  78669. maxScaleX: number;
  78670. /**
  78671. * Minimum scale of emitting particles on Y axis.
  78672. */
  78673. minScaleY: number;
  78674. /**
  78675. * Maximum scale of emitting particles on Y axis.
  78676. */
  78677. maxScaleY: number;
  78678. /**
  78679. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78680. */
  78681. color1: Color4;
  78682. /**
  78683. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78684. */
  78685. color2: Color4;
  78686. /**
  78687. * Color the particle will have at the end of its lifetime.
  78688. */
  78689. colorDead: Color4;
  78690. /**
  78691. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  78692. */
  78693. emitRate: number;
  78694. /**
  78695. * You can use gravity if you want to give an orientation to your particles.
  78696. */
  78697. gravity: Vector3;
  78698. /**
  78699. * Minimum power of emitting particles.
  78700. */
  78701. minEmitPower: number;
  78702. /**
  78703. * Maximum power of emitting particles.
  78704. */
  78705. maxEmitPower: number;
  78706. /**
  78707. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  78708. */
  78709. minAngularSpeed: number;
  78710. /**
  78711. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  78712. */
  78713. maxAngularSpeed: number;
  78714. /**
  78715. * Gets or sets the minimal initial rotation in radians.
  78716. */
  78717. minInitialRotation: number;
  78718. /**
  78719. * Gets or sets the maximal initial rotation in radians.
  78720. */
  78721. maxInitialRotation: number;
  78722. /**
  78723. * The particle emitter type defines the emitter used by the particle system.
  78724. * It can be for example box, sphere, or cone...
  78725. */
  78726. particleEmitterType: Nullable<IParticleEmitterType>;
  78727. /**
  78728. * Defines the delay in milliseconds before starting the system (0 by default)
  78729. */
  78730. startDelay: number;
  78731. /**
  78732. * 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
  78733. */
  78734. preWarmCycles: number;
  78735. /**
  78736. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  78737. */
  78738. preWarmStepOffset: number;
  78739. /**
  78740. * 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)
  78741. */
  78742. spriteCellChangeSpeed: number;
  78743. /**
  78744. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  78745. */
  78746. startSpriteCellID: number;
  78747. /**
  78748. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  78749. */
  78750. endSpriteCellID: number;
  78751. /**
  78752. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  78753. */
  78754. spriteCellWidth: number;
  78755. /**
  78756. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  78757. */
  78758. spriteCellHeight: number;
  78759. /**
  78760. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  78761. */
  78762. spriteRandomStartCell: boolean;
  78763. /**
  78764. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  78765. */
  78766. isAnimationSheetEnabled: boolean;
  78767. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  78768. translationPivot: Vector2;
  78769. /**
  78770. * Gets or sets a texture used to add random noise to particle positions
  78771. */
  78772. noiseTexture: Nullable<BaseTexture>;
  78773. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  78774. noiseStrength: Vector3;
  78775. /**
  78776. * Gets or sets the billboard mode to use when isBillboardBased = true.
  78777. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  78778. */
  78779. billboardMode: number;
  78780. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  78781. limitVelocityDamping: number;
  78782. /**
  78783. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  78784. */
  78785. beginAnimationOnStart: boolean;
  78786. /**
  78787. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  78788. */
  78789. beginAnimationFrom: number;
  78790. /**
  78791. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  78792. */
  78793. beginAnimationTo: number;
  78794. /**
  78795. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  78796. */
  78797. beginAnimationLoop: boolean;
  78798. /**
  78799. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  78800. */
  78801. disposeOnStop: boolean;
  78802. /**
  78803. * Gets the maximum number of particles active at the same time.
  78804. * @returns The max number of active particles.
  78805. */
  78806. getCapacity(): number;
  78807. /**
  78808. * Gets if the system has been started. (Note: this will still be true after stop is called)
  78809. * @returns True if it has been started, otherwise false.
  78810. */
  78811. isStarted(): boolean;
  78812. /**
  78813. * Animates the particle system for this frame.
  78814. */
  78815. animate(): void;
  78816. /**
  78817. * Renders the particle system in its current state.
  78818. * @returns the current number of particles
  78819. */
  78820. render(): number;
  78821. /**
  78822. * Dispose the particle system and frees its associated resources.
  78823. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  78824. */
  78825. dispose(disposeTexture?: boolean): void;
  78826. /**
  78827. * Clones the particle system.
  78828. * @param name The name of the cloned object
  78829. * @param newEmitter The new emitter to use
  78830. * @returns the cloned particle system
  78831. */
  78832. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  78833. /**
  78834. * Serializes the particle system to a JSON object.
  78835. * @returns the JSON object
  78836. */
  78837. serialize(): any;
  78838. /**
  78839. * Rebuild the particle system
  78840. */
  78841. rebuild(): void;
  78842. /**
  78843. * Starts the particle system and begins to emit
  78844. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  78845. */
  78846. start(delay?: number): void;
  78847. /**
  78848. * Stops the particle system.
  78849. */
  78850. stop(): void;
  78851. /**
  78852. * Remove all active particles
  78853. */
  78854. reset(): void;
  78855. /**
  78856. * Is this system ready to be used/rendered
  78857. * @return true if the system is ready
  78858. */
  78859. isReady(): boolean;
  78860. /**
  78861. * Adds a new color gradient
  78862. * @param gradient defines the gradient to use (between 0 and 1)
  78863. * @param color1 defines the color to affect to the specified gradient
  78864. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  78865. * @returns the current particle system
  78866. */
  78867. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  78868. /**
  78869. * Remove a specific color gradient
  78870. * @param gradient defines the gradient to remove
  78871. * @returns the current particle system
  78872. */
  78873. removeColorGradient(gradient: number): IParticleSystem;
  78874. /**
  78875. * Adds a new size gradient
  78876. * @param gradient defines the gradient to use (between 0 and 1)
  78877. * @param factor defines the size factor to affect to the specified gradient
  78878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78879. * @returns the current particle system
  78880. */
  78881. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78882. /**
  78883. * Remove a specific size gradient
  78884. * @param gradient defines the gradient to remove
  78885. * @returns the current particle system
  78886. */
  78887. removeSizeGradient(gradient: number): IParticleSystem;
  78888. /**
  78889. * Gets the current list of color gradients.
  78890. * You must use addColorGradient and removeColorGradient to udpate this list
  78891. * @returns the list of color gradients
  78892. */
  78893. getColorGradients(): Nullable<Array<ColorGradient>>;
  78894. /**
  78895. * Gets the current list of size gradients.
  78896. * You must use addSizeGradient and removeSizeGradient to udpate this list
  78897. * @returns the list of size gradients
  78898. */
  78899. getSizeGradients(): Nullable<Array<FactorGradient>>;
  78900. /**
  78901. * Gets the current list of angular speed gradients.
  78902. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  78903. * @returns the list of angular speed gradients
  78904. */
  78905. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  78906. /**
  78907. * Adds a new angular speed gradient
  78908. * @param gradient defines the gradient to use (between 0 and 1)
  78909. * @param factor defines the angular speed to affect to the specified gradient
  78910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78911. * @returns the current particle system
  78912. */
  78913. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78914. /**
  78915. * Remove a specific angular speed gradient
  78916. * @param gradient defines the gradient to remove
  78917. * @returns the current particle system
  78918. */
  78919. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  78920. /**
  78921. * Gets the current list of velocity gradients.
  78922. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  78923. * @returns the list of velocity gradients
  78924. */
  78925. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  78926. /**
  78927. * Adds a new velocity gradient
  78928. * @param gradient defines the gradient to use (between 0 and 1)
  78929. * @param factor defines the velocity to affect to the specified gradient
  78930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78931. * @returns the current particle system
  78932. */
  78933. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78934. /**
  78935. * Remove a specific velocity gradient
  78936. * @param gradient defines the gradient to remove
  78937. * @returns the current particle system
  78938. */
  78939. removeVelocityGradient(gradient: number): IParticleSystem;
  78940. /**
  78941. * Gets the current list of limit velocity gradients.
  78942. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  78943. * @returns the list of limit velocity gradients
  78944. */
  78945. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  78946. /**
  78947. * Adds a new limit velocity gradient
  78948. * @param gradient defines the gradient to use (between 0 and 1)
  78949. * @param factor defines the limit velocity to affect to the specified gradient
  78950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78951. * @returns the current particle system
  78952. */
  78953. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78954. /**
  78955. * Remove a specific limit velocity gradient
  78956. * @param gradient defines the gradient to remove
  78957. * @returns the current particle system
  78958. */
  78959. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  78960. /**
  78961. * Adds a new drag gradient
  78962. * @param gradient defines the gradient to use (between 0 and 1)
  78963. * @param factor defines the drag to affect to the specified gradient
  78964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78965. * @returns the current particle system
  78966. */
  78967. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78968. /**
  78969. * Remove a specific drag gradient
  78970. * @param gradient defines the gradient to remove
  78971. * @returns the current particle system
  78972. */
  78973. removeDragGradient(gradient: number): IParticleSystem;
  78974. /**
  78975. * Gets the current list of drag gradients.
  78976. * You must use addDragGradient and removeDragGradient to udpate this list
  78977. * @returns the list of drag gradients
  78978. */
  78979. getDragGradients(): Nullable<Array<FactorGradient>>;
  78980. /**
  78981. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  78982. * @param gradient defines the gradient to use (between 0 and 1)
  78983. * @param factor defines the emit rate to affect to the specified gradient
  78984. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78985. * @returns the current particle system
  78986. */
  78987. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78988. /**
  78989. * Remove a specific emit rate gradient
  78990. * @param gradient defines the gradient to remove
  78991. * @returns the current particle system
  78992. */
  78993. removeEmitRateGradient(gradient: number): IParticleSystem;
  78994. /**
  78995. * Gets the current list of emit rate gradients.
  78996. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  78997. * @returns the list of emit rate gradients
  78998. */
  78999. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  79000. /**
  79001. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  79002. * @param gradient defines the gradient to use (between 0 and 1)
  79003. * @param factor defines the start size to affect to the specified gradient
  79004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  79005. * @returns the current particle system
  79006. */
  79007. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  79008. /**
  79009. * Remove a specific start size gradient
  79010. * @param gradient defines the gradient to remove
  79011. * @returns the current particle system
  79012. */
  79013. removeStartSizeGradient(gradient: number): IParticleSystem;
  79014. /**
  79015. * Gets the current list of start size gradients.
  79016. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  79017. * @returns the list of start size gradients
  79018. */
  79019. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  79020. /**
  79021. * Adds a new life time gradient
  79022. * @param gradient defines the gradient to use (between 0 and 1)
  79023. * @param factor defines the life time factor to affect to the specified gradient
  79024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  79025. * @returns the current particle system
  79026. */
  79027. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  79028. /**
  79029. * Remove a specific life time gradient
  79030. * @param gradient defines the gradient to remove
  79031. * @returns the current particle system
  79032. */
  79033. removeLifeTimeGradient(gradient: number): IParticleSystem;
  79034. /**
  79035. * Gets the current list of life time gradients.
  79036. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  79037. * @returns the list of life time gradients
  79038. */
  79039. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  79040. /**
  79041. * Gets the current list of color gradients.
  79042. * You must use addColorGradient and removeColorGradient to udpate this list
  79043. * @returns the list of color gradients
  79044. */
  79045. getColorGradients(): Nullable<Array<ColorGradient>>;
  79046. /**
  79047. * Adds a new ramp gradient used to remap particle colors
  79048. * @param gradient defines the gradient to use (between 0 and 1)
  79049. * @param color defines the color to affect to the specified gradient
  79050. * @returns the current particle system
  79051. */
  79052. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  79053. /**
  79054. * Gets the current list of ramp gradients.
  79055. * You must use addRampGradient and removeRampGradient to udpate this list
  79056. * @returns the list of ramp gradients
  79057. */
  79058. getRampGradients(): Nullable<Array<Color3Gradient>>;
  79059. /** Gets or sets a boolean indicating that ramp gradients must be used
  79060. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  79061. */
  79062. useRampGradients: boolean;
  79063. /**
  79064. * Adds a new color remap gradient
  79065. * @param gradient defines the gradient to use (between 0 and 1)
  79066. * @param min defines the color remap minimal range
  79067. * @param max defines the color remap maximal range
  79068. * @returns the current particle system
  79069. */
  79070. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  79071. /**
  79072. * Gets the current list of color remap gradients.
  79073. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  79074. * @returns the list of color remap gradients
  79075. */
  79076. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  79077. /**
  79078. * Adds a new alpha remap gradient
  79079. * @param gradient defines the gradient to use (between 0 and 1)
  79080. * @param min defines the alpha remap minimal range
  79081. * @param max defines the alpha remap maximal range
  79082. * @returns the current particle system
  79083. */
  79084. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  79085. /**
  79086. * Gets the current list of alpha remap gradients.
  79087. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  79088. * @returns the list of alpha remap gradients
  79089. */
  79090. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  79091. /**
  79092. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  79093. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79094. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79095. * @returns the emitter
  79096. */
  79097. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  79098. /**
  79099. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  79100. * @param radius The radius of the hemisphere to emit from
  79101. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79102. * @returns the emitter
  79103. */
  79104. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  79105. /**
  79106. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  79107. * @param radius The radius of the sphere to emit from
  79108. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  79109. * @returns the emitter
  79110. */
  79111. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  79112. /**
  79113. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  79114. * @param radius The radius of the sphere to emit from
  79115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  79116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  79117. * @returns the emitter
  79118. */
  79119. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  79120. /**
  79121. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  79122. * @param radius The radius of the emission cylinder
  79123. * @param height The height of the emission cylinder
  79124. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  79125. * @param directionRandomizer How much to randomize the particle direction [0-1]
  79126. * @returns the emitter
  79127. */
  79128. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  79129. /**
  79130. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  79131. * @param radius The radius of the cylinder to emit from
  79132. * @param height The height of the emission cylinder
  79133. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  79134. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  79135. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  79136. * @returns the emitter
  79137. */
  79138. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  79139. /**
  79140. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  79141. * @param radius The radius of the cone to emit from
  79142. * @param angle The base angle of the cone
  79143. * @returns the emitter
  79144. */
  79145. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  79146. /**
  79147. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  79148. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  79149. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  79150. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79151. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  79152. * @returns the emitter
  79153. */
  79154. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  79155. /**
  79156. * Get hosting scene
  79157. * @returns the scene
  79158. */
  79159. getScene(): Scene;
  79160. }
  79161. }
  79162. declare module BABYLON {
  79163. /**
  79164. * Creates an instance based on a source mesh.
  79165. */
  79166. export class InstancedMesh extends AbstractMesh {
  79167. private _sourceMesh;
  79168. private _currentLOD;
  79169. /** @hidden */
  79170. _indexInSourceMeshInstanceArray: number;
  79171. constructor(name: string, source: Mesh);
  79172. /**
  79173. * Returns the string "InstancedMesh".
  79174. */
  79175. getClassName(): string;
  79176. /** Gets the list of lights affecting that mesh */
  79177. readonly lightSources: Light[];
  79178. _resyncLightSources(): void;
  79179. _resyncLighSource(light: Light): void;
  79180. _removeLightSource(light: Light): void;
  79181. /**
  79182. * If the source mesh receives shadows
  79183. */
  79184. readonly receiveShadows: boolean;
  79185. /**
  79186. * The material of the source mesh
  79187. */
  79188. readonly material: Nullable<Material>;
  79189. /**
  79190. * Visibility of the source mesh
  79191. */
  79192. readonly visibility: number;
  79193. /**
  79194. * Skeleton of the source mesh
  79195. */
  79196. readonly skeleton: Nullable<Skeleton>;
  79197. /**
  79198. * Rendering ground id of the source mesh
  79199. */
  79200. renderingGroupId: number;
  79201. /**
  79202. * Returns the total number of vertices (integer).
  79203. */
  79204. getTotalVertices(): number;
  79205. /**
  79206. * Returns a positive integer : the total number of indices in this mesh geometry.
  79207. * @returns the numner of indices or zero if the mesh has no geometry.
  79208. */
  79209. getTotalIndices(): number;
  79210. /**
  79211. * The source mesh of the instance
  79212. */
  79213. readonly sourceMesh: Mesh;
  79214. /**
  79215. * Is this node ready to be used/rendered
  79216. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  79217. * @return {boolean} is it ready
  79218. */
  79219. isReady(completeCheck?: boolean): boolean;
  79220. /**
  79221. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  79222. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  79223. * @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.
  79224. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  79225. */
  79226. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  79227. /**
  79228. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79229. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79230. * The `data` are either a numeric array either a Float32Array.
  79231. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  79232. * 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).
  79233. * Note that a new underlying VertexBuffer object is created each call.
  79234. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79235. *
  79236. * Possible `kind` values :
  79237. * - VertexBuffer.PositionKind
  79238. * - VertexBuffer.UVKind
  79239. * - VertexBuffer.UV2Kind
  79240. * - VertexBuffer.UV3Kind
  79241. * - VertexBuffer.UV4Kind
  79242. * - VertexBuffer.UV5Kind
  79243. * - VertexBuffer.UV6Kind
  79244. * - VertexBuffer.ColorKind
  79245. * - VertexBuffer.MatricesIndicesKind
  79246. * - VertexBuffer.MatricesIndicesExtraKind
  79247. * - VertexBuffer.MatricesWeightsKind
  79248. * - VertexBuffer.MatricesWeightsExtraKind
  79249. *
  79250. * Returns the Mesh.
  79251. */
  79252. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  79253. /**
  79254. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79255. * If the mesh has no geometry, it is simply returned as it is.
  79256. * The `data` are either a numeric array either a Float32Array.
  79257. * No new underlying VertexBuffer object is created.
  79258. * 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.
  79259. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  79260. *
  79261. * Possible `kind` values :
  79262. * - VertexBuffer.PositionKind
  79263. * - VertexBuffer.UVKind
  79264. * - VertexBuffer.UV2Kind
  79265. * - VertexBuffer.UV3Kind
  79266. * - VertexBuffer.UV4Kind
  79267. * - VertexBuffer.UV5Kind
  79268. * - VertexBuffer.UV6Kind
  79269. * - VertexBuffer.ColorKind
  79270. * - VertexBuffer.MatricesIndicesKind
  79271. * - VertexBuffer.MatricesIndicesExtraKind
  79272. * - VertexBuffer.MatricesWeightsKind
  79273. * - VertexBuffer.MatricesWeightsExtraKind
  79274. *
  79275. * Returns the Mesh.
  79276. */
  79277. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79278. /**
  79279. * Sets the mesh indices.
  79280. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  79281. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79282. * This method creates a new index buffer each call.
  79283. * Returns the Mesh.
  79284. */
  79285. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  79286. /**
  79287. * Boolean : True if the mesh owns the requested kind of data.
  79288. */
  79289. isVerticesDataPresent(kind: string): boolean;
  79290. /**
  79291. * Returns an array of indices (IndicesArray).
  79292. */
  79293. getIndices(): Nullable<IndicesArray>;
  79294. readonly _positions: Nullable<Vector3[]>;
  79295. /**
  79296. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79297. * This means the mesh underlying bounding box and sphere are recomputed.
  79298. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79299. * @returns the current mesh
  79300. */
  79301. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  79302. /** @hidden */
  79303. _preActivate(): InstancedMesh;
  79304. /** @hidden */
  79305. _activate(renderId: number, intermediateRendering: boolean): boolean;
  79306. /** @hidden */
  79307. _postActivate(): void;
  79308. getWorldMatrix(): Matrix;
  79309. readonly isAnInstance: boolean;
  79310. /**
  79311. * Returns the current associated LOD AbstractMesh.
  79312. */
  79313. getLOD(camera: Camera): AbstractMesh;
  79314. /** @hidden */
  79315. _syncSubMeshes(): InstancedMesh;
  79316. /** @hidden */
  79317. _generatePointsArray(): boolean;
  79318. /**
  79319. * Creates a new InstancedMesh from the current mesh.
  79320. * - name (string) : the cloned mesh name
  79321. * - newParent (optional Node) : the optional Node to parent the clone to.
  79322. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  79323. *
  79324. * Returns the clone.
  79325. */
  79326. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  79327. /**
  79328. * Disposes the InstancedMesh.
  79329. * Returns nothing.
  79330. */
  79331. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79332. }
  79333. }
  79334. declare module BABYLON {
  79335. /**
  79336. * Defines the options associated with the creation of a shader material.
  79337. */
  79338. export interface IShaderMaterialOptions {
  79339. /**
  79340. * Does the material work in alpha blend mode
  79341. */
  79342. needAlphaBlending: boolean;
  79343. /**
  79344. * Does the material work in alpha test mode
  79345. */
  79346. needAlphaTesting: boolean;
  79347. /**
  79348. * The list of attribute names used in the shader
  79349. */
  79350. attributes: string[];
  79351. /**
  79352. * The list of unifrom names used in the shader
  79353. */
  79354. uniforms: string[];
  79355. /**
  79356. * The list of UBO names used in the shader
  79357. */
  79358. uniformBuffers: string[];
  79359. /**
  79360. * The list of sampler names used in the shader
  79361. */
  79362. samplers: string[];
  79363. /**
  79364. * The list of defines used in the shader
  79365. */
  79366. defines: string[];
  79367. }
  79368. /**
  79369. * 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.
  79370. *
  79371. * This returned material effects how the mesh will look based on the code in the shaders.
  79372. *
  79373. * @see http://doc.babylonjs.com/how_to/shader_material
  79374. */
  79375. export class ShaderMaterial extends Material {
  79376. private _shaderPath;
  79377. private _options;
  79378. private _textures;
  79379. private _textureArrays;
  79380. private _floats;
  79381. private _ints;
  79382. private _floatsArrays;
  79383. private _colors3;
  79384. private _colors3Arrays;
  79385. private _colors4;
  79386. private _vectors2;
  79387. private _vectors3;
  79388. private _vectors4;
  79389. private _matrices;
  79390. private _matrices3x3;
  79391. private _matrices2x2;
  79392. private _vectors2Arrays;
  79393. private _vectors3Arrays;
  79394. private _cachedWorldViewMatrix;
  79395. private _cachedWorldViewProjectionMatrix;
  79396. private _renderId;
  79397. /**
  79398. * Instantiate a new shader material.
  79399. * 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.
  79400. * This returned material effects how the mesh will look based on the code in the shaders.
  79401. * @see http://doc.babylonjs.com/how_to/shader_material
  79402. * @param name Define the name of the material in the scene
  79403. * @param scene Define the scene the material belongs to
  79404. * @param shaderPath Defines the route to the shader code in one of three ways:
  79405. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  79406. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  79407. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  79408. * @param options Define the options used to create the shader
  79409. */
  79410. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  79411. /**
  79412. * Gets the options used to compile the shader.
  79413. * They can be modified to trigger a new compilation
  79414. */
  79415. readonly options: IShaderMaterialOptions;
  79416. /**
  79417. * Gets the current class name of the material e.g. "ShaderMaterial"
  79418. * Mainly use in serialization.
  79419. * @returns the class name
  79420. */
  79421. getClassName(): string;
  79422. /**
  79423. * Specifies if the material will require alpha blending
  79424. * @returns a boolean specifying if alpha blending is needed
  79425. */
  79426. needAlphaBlending(): boolean;
  79427. /**
  79428. * Specifies if this material should be rendered in alpha test mode
  79429. * @returns a boolean specifying if an alpha test is needed.
  79430. */
  79431. needAlphaTesting(): boolean;
  79432. private _checkUniform;
  79433. /**
  79434. * Set a texture in the shader.
  79435. * @param name Define the name of the uniform samplers as defined in the shader
  79436. * @param texture Define the texture to bind to this sampler
  79437. * @return the material itself allowing "fluent" like uniform updates
  79438. */
  79439. setTexture(name: string, texture: Texture): ShaderMaterial;
  79440. /**
  79441. * Set a texture array in the shader.
  79442. * @param name Define the name of the uniform sampler array as defined in the shader
  79443. * @param textures Define the list of textures to bind to this sampler
  79444. * @return the material itself allowing "fluent" like uniform updates
  79445. */
  79446. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  79447. /**
  79448. * Set a float in the shader.
  79449. * @param name Define the name of the uniform as defined in the shader
  79450. * @param value Define the value to give to the uniform
  79451. * @return the material itself allowing "fluent" like uniform updates
  79452. */
  79453. setFloat(name: string, value: number): ShaderMaterial;
  79454. /**
  79455. * Set a int in the shader.
  79456. * @param name Define the name of the uniform as defined in the shader
  79457. * @param value Define the value to give to the uniform
  79458. * @return the material itself allowing "fluent" like uniform updates
  79459. */
  79460. setInt(name: string, value: number): ShaderMaterial;
  79461. /**
  79462. * Set an array of floats in the shader.
  79463. * @param name Define the name of the uniform as defined in the shader
  79464. * @param value Define the value to give to the uniform
  79465. * @return the material itself allowing "fluent" like uniform updates
  79466. */
  79467. setFloats(name: string, value: number[]): ShaderMaterial;
  79468. /**
  79469. * Set a vec3 in the shader from a Color3.
  79470. * @param name Define the name of the uniform as defined in the shader
  79471. * @param value Define the value to give to the uniform
  79472. * @return the material itself allowing "fluent" like uniform updates
  79473. */
  79474. setColor3(name: string, value: Color3): ShaderMaterial;
  79475. /**
  79476. * Set a vec3 array in the shader from a Color3 array.
  79477. * @param name Define the name of the uniform as defined in the shader
  79478. * @param value Define the value to give to the uniform
  79479. * @return the material itself allowing "fluent" like uniform updates
  79480. */
  79481. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  79482. /**
  79483. * Set a vec4 in the shader from a Color4.
  79484. * @param name Define the name of the uniform as defined in the shader
  79485. * @param value Define the value to give to the uniform
  79486. * @return the material itself allowing "fluent" like uniform updates
  79487. */
  79488. setColor4(name: string, value: Color4): ShaderMaterial;
  79489. /**
  79490. * Set a vec2 in the shader from a Vector2.
  79491. * @param name Define the name of the uniform as defined in the shader
  79492. * @param value Define the value to give to the uniform
  79493. * @return the material itself allowing "fluent" like uniform updates
  79494. */
  79495. setVector2(name: string, value: Vector2): ShaderMaterial;
  79496. /**
  79497. * Set a vec3 in the shader from a Vector3.
  79498. * @param name Define the name of the uniform as defined in the shader
  79499. * @param value Define the value to give to the uniform
  79500. * @return the material itself allowing "fluent" like uniform updates
  79501. */
  79502. setVector3(name: string, value: Vector3): ShaderMaterial;
  79503. /**
  79504. * Set a vec4 in the shader from a Vector4.
  79505. * @param name Define the name of the uniform as defined in the shader
  79506. * @param value Define the value to give to the uniform
  79507. * @return the material itself allowing "fluent" like uniform updates
  79508. */
  79509. setVector4(name: string, value: Vector4): ShaderMaterial;
  79510. /**
  79511. * Set a mat4 in the shader from a Matrix.
  79512. * @param name Define the name of the uniform as defined in the shader
  79513. * @param value Define the value to give to the uniform
  79514. * @return the material itself allowing "fluent" like uniform updates
  79515. */
  79516. setMatrix(name: string, value: Matrix): ShaderMaterial;
  79517. /**
  79518. * Set a mat3 in the shader from a Float32Array.
  79519. * @param name Define the name of the uniform as defined in the shader
  79520. * @param value Define the value to give to the uniform
  79521. * @return the material itself allowing "fluent" like uniform updates
  79522. */
  79523. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  79524. /**
  79525. * Set a mat2 in the shader from a Float32Array.
  79526. * @param name Define the name of the uniform as defined in the shader
  79527. * @param value Define the value to give to the uniform
  79528. * @return the material itself allowing "fluent" like uniform updates
  79529. */
  79530. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  79531. /**
  79532. * Set a vec2 array in the shader from a number array.
  79533. * @param name Define the name of the uniform as defined in the shader
  79534. * @param value Define the value to give to the uniform
  79535. * @return the material itself allowing "fluent" like uniform updates
  79536. */
  79537. setArray2(name: string, value: number[]): ShaderMaterial;
  79538. /**
  79539. * Set a vec3 array in the shader from a number array.
  79540. * @param name Define the name of the uniform as defined in the shader
  79541. * @param value Define the value to give to the uniform
  79542. * @return the material itself allowing "fluent" like uniform updates
  79543. */
  79544. setArray3(name: string, value: number[]): ShaderMaterial;
  79545. private _checkCache;
  79546. /**
  79547. * Specifies that the submesh is ready to be used
  79548. * @param mesh defines the mesh to check
  79549. * @param subMesh defines which submesh to check
  79550. * @param useInstances specifies that instances should be used
  79551. * @returns a boolean indicating that the submesh is ready or not
  79552. */
  79553. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79554. /**
  79555. * Checks if the material is ready to render the requested mesh
  79556. * @param mesh Define the mesh to render
  79557. * @param useInstances Define whether or not the material is used with instances
  79558. * @returns true if ready, otherwise false
  79559. */
  79560. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79561. /**
  79562. * Binds the world matrix to the material
  79563. * @param world defines the world transformation matrix
  79564. */
  79565. bindOnlyWorldMatrix(world: Matrix): void;
  79566. /**
  79567. * Binds the material to the mesh
  79568. * @param world defines the world transformation matrix
  79569. * @param mesh defines the mesh to bind the material to
  79570. */
  79571. bind(world: Matrix, mesh?: Mesh): void;
  79572. /**
  79573. * Gets the active textures from the material
  79574. * @returns an array of textures
  79575. */
  79576. getActiveTextures(): BaseTexture[];
  79577. /**
  79578. * Specifies if the material uses a texture
  79579. * @param texture defines the texture to check against the material
  79580. * @returns a boolean specifying if the material uses the texture
  79581. */
  79582. hasTexture(texture: BaseTexture): boolean;
  79583. /**
  79584. * Makes a duplicate of the material, and gives it a new name
  79585. * @param name defines the new name for the duplicated material
  79586. * @returns the cloned material
  79587. */
  79588. clone(name: string): ShaderMaterial;
  79589. /**
  79590. * Disposes the material
  79591. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79592. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79593. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79594. */
  79595. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79596. /**
  79597. * Serializes this material in a JSON representation
  79598. * @returns the serialized material object
  79599. */
  79600. serialize(): any;
  79601. /**
  79602. * Creates a shader material from parsed shader material data
  79603. * @param source defines the JSON represnetation of the material
  79604. * @param scene defines the hosting scene
  79605. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79606. * @returns a new material
  79607. */
  79608. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  79609. }
  79610. }
  79611. declare module BABYLON {
  79612. /** @hidden */
  79613. export var colorPixelShader: {
  79614. name: string;
  79615. shader: string;
  79616. };
  79617. }
  79618. declare module BABYLON {
  79619. /** @hidden */
  79620. export var colorVertexShader: {
  79621. name: string;
  79622. shader: string;
  79623. };
  79624. }
  79625. declare module BABYLON {
  79626. /**
  79627. * Line mesh
  79628. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  79629. */
  79630. export class LinesMesh extends Mesh {
  79631. /**
  79632. * If vertex color should be applied to the mesh
  79633. */
  79634. readonly useVertexColor?: boolean | undefined;
  79635. /**
  79636. * If vertex alpha should be applied to the mesh
  79637. */
  79638. readonly useVertexAlpha?: boolean | undefined;
  79639. /**
  79640. * Color of the line (Default: White)
  79641. */
  79642. color: Color3;
  79643. /**
  79644. * Alpha of the line (Default: 1)
  79645. */
  79646. alpha: number;
  79647. /**
  79648. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79649. * This margin is expressed in world space coordinates, so its value may vary.
  79650. * Default value is 0.1
  79651. */
  79652. intersectionThreshold: number;
  79653. private _colorShader;
  79654. private color4;
  79655. /**
  79656. * Creates a new LinesMesh
  79657. * @param name defines the name
  79658. * @param scene defines the hosting scene
  79659. * @param parent defines the parent mesh if any
  79660. * @param source defines the optional source LinesMesh used to clone data from
  79661. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79662. * When false, achieved by calling a clone(), also passing False.
  79663. * This will make creation of children, recursive.
  79664. * @param useVertexColor defines if this LinesMesh supports vertex color
  79665. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  79666. */
  79667. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  79668. /**
  79669. * If vertex color should be applied to the mesh
  79670. */
  79671. useVertexColor?: boolean | undefined,
  79672. /**
  79673. * If vertex alpha should be applied to the mesh
  79674. */
  79675. useVertexAlpha?: boolean | undefined);
  79676. private _addClipPlaneDefine;
  79677. private _removeClipPlaneDefine;
  79678. isReady(): boolean;
  79679. /**
  79680. * Returns the string "LineMesh"
  79681. */
  79682. getClassName(): string;
  79683. /**
  79684. * @hidden
  79685. */
  79686. /**
  79687. * @hidden
  79688. */
  79689. material: Material;
  79690. /**
  79691. * @hidden
  79692. */
  79693. readonly checkCollisions: boolean;
  79694. /** @hidden */
  79695. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  79696. /** @hidden */
  79697. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  79698. /**
  79699. * Disposes of the line mesh
  79700. * @param doNotRecurse If children should be disposed
  79701. */
  79702. dispose(doNotRecurse?: boolean): void;
  79703. /**
  79704. * Returns a new LineMesh object cloned from the current one.
  79705. */
  79706. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  79707. /**
  79708. * Creates a new InstancedLinesMesh object from the mesh model.
  79709. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79710. * @param name defines the name of the new instance
  79711. * @returns a new InstancedLinesMesh
  79712. */
  79713. createInstance(name: string): InstancedLinesMesh;
  79714. }
  79715. /**
  79716. * Creates an instance based on a source LinesMesh
  79717. */
  79718. export class InstancedLinesMesh extends InstancedMesh {
  79719. /**
  79720. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79721. * This margin is expressed in world space coordinates, so its value may vary.
  79722. * Initilized with the intersectionThreshold value of the source LinesMesh
  79723. */
  79724. intersectionThreshold: number;
  79725. constructor(name: string, source: LinesMesh);
  79726. /**
  79727. * Returns the string "InstancedLinesMesh".
  79728. */
  79729. getClassName(): string;
  79730. }
  79731. }
  79732. declare module BABYLON {
  79733. /** @hidden */
  79734. export var linePixelShader: {
  79735. name: string;
  79736. shader: string;
  79737. };
  79738. }
  79739. declare module BABYLON {
  79740. /** @hidden */
  79741. export var lineVertexShader: {
  79742. name: string;
  79743. shader: string;
  79744. };
  79745. }
  79746. declare module BABYLON {
  79747. interface AbstractMesh {
  79748. /**
  79749. * Gets the edgesRenderer associated with the mesh
  79750. */
  79751. edgesRenderer: Nullable<EdgesRenderer>;
  79752. }
  79753. interface LinesMesh {
  79754. /**
  79755. * Enables the edge rendering mode on the mesh.
  79756. * This mode makes the mesh edges visible
  79757. * @param epsilon defines the maximal distance between two angles to detect a face
  79758. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79759. * @returns the currentAbstractMesh
  79760. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79761. */
  79762. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  79763. }
  79764. interface InstancedLinesMesh {
  79765. /**
  79766. * Enables the edge rendering mode on the mesh.
  79767. * This mode makes the mesh edges visible
  79768. * @param epsilon defines the maximal distance between two angles to detect a face
  79769. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79770. * @returns the current InstancedLinesMesh
  79771. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79772. */
  79773. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  79774. }
  79775. /**
  79776. * Defines the minimum contract an Edges renderer should follow.
  79777. */
  79778. export interface IEdgesRenderer extends IDisposable {
  79779. /**
  79780. * Gets or sets a boolean indicating if the edgesRenderer is active
  79781. */
  79782. isEnabled: boolean;
  79783. /**
  79784. * Renders the edges of the attached mesh,
  79785. */
  79786. render(): void;
  79787. /**
  79788. * Checks wether or not the edges renderer is ready to render.
  79789. * @return true if ready, otherwise false.
  79790. */
  79791. isReady(): boolean;
  79792. }
  79793. /**
  79794. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  79795. */
  79796. export class EdgesRenderer implements IEdgesRenderer {
  79797. /**
  79798. * Define the size of the edges with an orthographic camera
  79799. */
  79800. edgesWidthScalerForOrthographic: number;
  79801. /**
  79802. * Define the size of the edges with a perspective camera
  79803. */
  79804. edgesWidthScalerForPerspective: number;
  79805. protected _source: AbstractMesh;
  79806. protected _linesPositions: number[];
  79807. protected _linesNormals: number[];
  79808. protected _linesIndices: number[];
  79809. protected _epsilon: number;
  79810. protected _indicesCount: number;
  79811. protected _lineShader: ShaderMaterial;
  79812. protected _ib: DataBuffer;
  79813. protected _buffers: {
  79814. [key: string]: Nullable<VertexBuffer>;
  79815. };
  79816. protected _checkVerticesInsteadOfIndices: boolean;
  79817. private _meshRebuildObserver;
  79818. private _meshDisposeObserver;
  79819. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  79820. isEnabled: boolean;
  79821. /**
  79822. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  79823. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  79824. * @param source Mesh used to create edges
  79825. * @param epsilon sum of angles in adjacency to check for edge
  79826. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  79827. * @param generateEdgesLines - should generate Lines or only prepare resources.
  79828. */
  79829. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  79830. protected _prepareRessources(): void;
  79831. /** @hidden */
  79832. _rebuild(): void;
  79833. /**
  79834. * Releases the required resources for the edges renderer
  79835. */
  79836. dispose(): void;
  79837. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  79838. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  79839. /**
  79840. * Checks if the pair of p0 and p1 is en edge
  79841. * @param faceIndex
  79842. * @param edge
  79843. * @param faceNormals
  79844. * @param p0
  79845. * @param p1
  79846. * @private
  79847. */
  79848. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  79849. /**
  79850. * push line into the position, normal and index buffer
  79851. * @protected
  79852. */
  79853. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  79854. /**
  79855. * Generates lines edges from adjacencjes
  79856. * @private
  79857. */
  79858. _generateEdgesLines(): void;
  79859. /**
  79860. * Checks wether or not the edges renderer is ready to render.
  79861. * @return true if ready, otherwise false.
  79862. */
  79863. isReady(): boolean;
  79864. /**
  79865. * Renders the edges of the attached mesh,
  79866. */
  79867. render(): void;
  79868. }
  79869. /**
  79870. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  79871. */
  79872. export class LineEdgesRenderer extends EdgesRenderer {
  79873. /**
  79874. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  79875. * @param source LineMesh used to generate edges
  79876. * @param epsilon not important (specified angle for edge detection)
  79877. * @param checkVerticesInsteadOfIndices not important for LineMesh
  79878. */
  79879. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  79880. /**
  79881. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  79882. */
  79883. _generateEdgesLines(): void;
  79884. }
  79885. }
  79886. declare module BABYLON {
  79887. /**
  79888. * This represents the object necessary to create a rendering group.
  79889. * This is exclusively used and created by the rendering manager.
  79890. * To modify the behavior, you use the available helpers in your scene or meshes.
  79891. * @hidden
  79892. */
  79893. export class RenderingGroup {
  79894. index: number;
  79895. private static _zeroVector;
  79896. private _scene;
  79897. private _opaqueSubMeshes;
  79898. private _transparentSubMeshes;
  79899. private _alphaTestSubMeshes;
  79900. private _depthOnlySubMeshes;
  79901. private _particleSystems;
  79902. private _spriteManagers;
  79903. private _opaqueSortCompareFn;
  79904. private _alphaTestSortCompareFn;
  79905. private _transparentSortCompareFn;
  79906. private _renderOpaque;
  79907. private _renderAlphaTest;
  79908. private _renderTransparent;
  79909. /** @hidden */
  79910. _edgesRenderers: SmartArray<IEdgesRenderer>;
  79911. onBeforeTransparentRendering: () => void;
  79912. /**
  79913. * Set the opaque sort comparison function.
  79914. * If null the sub meshes will be render in the order they were created
  79915. */
  79916. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79917. /**
  79918. * Set the alpha test sort comparison function.
  79919. * If null the sub meshes will be render in the order they were created
  79920. */
  79921. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79922. /**
  79923. * Set the transparent sort comparison function.
  79924. * If null the sub meshes will be render in the order they were created
  79925. */
  79926. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79927. /**
  79928. * Creates a new rendering group.
  79929. * @param index The rendering group index
  79930. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  79931. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  79932. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  79933. */
  79934. 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>);
  79935. /**
  79936. * Render all the sub meshes contained in the group.
  79937. * @param customRenderFunction Used to override the default render behaviour of the group.
  79938. * @returns true if rendered some submeshes.
  79939. */
  79940. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  79941. /**
  79942. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  79943. * @param subMeshes The submeshes to render
  79944. */
  79945. private renderOpaqueSorted;
  79946. /**
  79947. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  79948. * @param subMeshes The submeshes to render
  79949. */
  79950. private renderAlphaTestSorted;
  79951. /**
  79952. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  79953. * @param subMeshes The submeshes to render
  79954. */
  79955. private renderTransparentSorted;
  79956. /**
  79957. * Renders the submeshes in a specified order.
  79958. * @param subMeshes The submeshes to sort before render
  79959. * @param sortCompareFn The comparison function use to sort
  79960. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  79961. * @param transparent Specifies to activate blending if true
  79962. */
  79963. private static renderSorted;
  79964. /**
  79965. * Renders the submeshes in the order they were dispatched (no sort applied).
  79966. * @param subMeshes The submeshes to render
  79967. */
  79968. private static renderUnsorted;
  79969. /**
  79970. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79971. * are rendered back to front if in the same alpha index.
  79972. *
  79973. * @param a The first submesh
  79974. * @param b The second submesh
  79975. * @returns The result of the comparison
  79976. */
  79977. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  79978. /**
  79979. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79980. * are rendered back to front.
  79981. *
  79982. * @param a The first submesh
  79983. * @param b The second submesh
  79984. * @returns The result of the comparison
  79985. */
  79986. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  79987. /**
  79988. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79989. * are rendered front to back (prevent overdraw).
  79990. *
  79991. * @param a The first submesh
  79992. * @param b The second submesh
  79993. * @returns The result of the comparison
  79994. */
  79995. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  79996. /**
  79997. * Resets the different lists of submeshes to prepare a new frame.
  79998. */
  79999. prepare(): void;
  80000. dispose(): void;
  80001. /**
  80002. * Inserts the submesh in its correct queue depending on its material.
  80003. * @param subMesh The submesh to dispatch
  80004. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  80005. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  80006. */
  80007. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  80008. dispatchSprites(spriteManager: ISpriteManager): void;
  80009. dispatchParticles(particleSystem: IParticleSystem): void;
  80010. private _renderParticles;
  80011. private _renderSprites;
  80012. }
  80013. }
  80014. declare module BABYLON {
  80015. /**
  80016. * Interface describing the different options available in the rendering manager
  80017. * regarding Auto Clear between groups.
  80018. */
  80019. export interface IRenderingManagerAutoClearSetup {
  80020. /**
  80021. * Defines whether or not autoclear is enable.
  80022. */
  80023. autoClear: boolean;
  80024. /**
  80025. * Defines whether or not to autoclear the depth buffer.
  80026. */
  80027. depth: boolean;
  80028. /**
  80029. * Defines whether or not to autoclear the stencil buffer.
  80030. */
  80031. stencil: boolean;
  80032. }
  80033. /**
  80034. * This class is used by the onRenderingGroupObservable
  80035. */
  80036. export class RenderingGroupInfo {
  80037. /**
  80038. * The Scene that being rendered
  80039. */
  80040. scene: Scene;
  80041. /**
  80042. * The camera currently used for the rendering pass
  80043. */
  80044. camera: Nullable<Camera>;
  80045. /**
  80046. * The ID of the renderingGroup being processed
  80047. */
  80048. renderingGroupId: number;
  80049. }
  80050. /**
  80051. * This is the manager responsible of all the rendering for meshes sprites and particles.
  80052. * It is enable to manage the different groups as well as the different necessary sort functions.
  80053. * This should not be used directly aside of the few static configurations
  80054. */
  80055. export class RenderingManager {
  80056. /**
  80057. * The max id used for rendering groups (not included)
  80058. */
  80059. static MAX_RENDERINGGROUPS: number;
  80060. /**
  80061. * The min id used for rendering groups (included)
  80062. */
  80063. static MIN_RENDERINGGROUPS: number;
  80064. /**
  80065. * Used to globally prevent autoclearing scenes.
  80066. */
  80067. static AUTOCLEAR: boolean;
  80068. /**
  80069. * @hidden
  80070. */
  80071. _useSceneAutoClearSetup: boolean;
  80072. private _scene;
  80073. private _renderingGroups;
  80074. private _depthStencilBufferAlreadyCleaned;
  80075. private _autoClearDepthStencil;
  80076. private _customOpaqueSortCompareFn;
  80077. private _customAlphaTestSortCompareFn;
  80078. private _customTransparentSortCompareFn;
  80079. private _renderingGroupInfo;
  80080. /**
  80081. * Instantiates a new rendering group for a particular scene
  80082. * @param scene Defines the scene the groups belongs to
  80083. */
  80084. constructor(scene: Scene);
  80085. private _clearDepthStencilBuffer;
  80086. /**
  80087. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  80088. * @hidden
  80089. */
  80090. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  80091. /**
  80092. * Resets the different information of the group to prepare a new frame
  80093. * @hidden
  80094. */
  80095. reset(): void;
  80096. /**
  80097. * Dispose and release the group and its associated resources.
  80098. * @hidden
  80099. */
  80100. dispose(): void;
  80101. /**
  80102. * Clear the info related to rendering groups preventing retention points during dispose.
  80103. */
  80104. freeRenderingGroups(): void;
  80105. private _prepareRenderingGroup;
  80106. /**
  80107. * Add a sprite manager to the rendering manager in order to render it this frame.
  80108. * @param spriteManager Define the sprite manager to render
  80109. */
  80110. dispatchSprites(spriteManager: ISpriteManager): void;
  80111. /**
  80112. * Add a particle system to the rendering manager in order to render it this frame.
  80113. * @param particleSystem Define the particle system to render
  80114. */
  80115. dispatchParticles(particleSystem: IParticleSystem): void;
  80116. /**
  80117. * Add a submesh to the manager in order to render it this frame
  80118. * @param subMesh The submesh to dispatch
  80119. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  80120. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  80121. */
  80122. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  80123. /**
  80124. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80125. * This allowed control for front to back rendering or reversly depending of the special needs.
  80126. *
  80127. * @param renderingGroupId The rendering group id corresponding to its index
  80128. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80129. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80130. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80131. */
  80132. 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;
  80133. /**
  80134. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80135. *
  80136. * @param renderingGroupId The rendering group id corresponding to its index
  80137. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80138. * @param depth Automatically clears depth between groups if true and autoClear is true.
  80139. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  80140. */
  80141. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  80142. /**
  80143. * Gets the current auto clear configuration for one rendering group of the rendering
  80144. * manager.
  80145. * @param index the rendering group index to get the information for
  80146. * @returns The auto clear setup for the requested rendering group
  80147. */
  80148. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  80149. }
  80150. }
  80151. declare module BABYLON {
  80152. /**
  80153. * This Helps creating a texture that will be created from a camera in your scene.
  80154. * It is basically a dynamic texture that could be used to create special effects for instance.
  80155. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  80156. */
  80157. export class RenderTargetTexture extends Texture {
  80158. isCube: boolean;
  80159. /**
  80160. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  80161. */
  80162. static readonly REFRESHRATE_RENDER_ONCE: number;
  80163. /**
  80164. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  80165. */
  80166. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  80167. /**
  80168. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  80169. * the central point of your effect and can save a lot of performances.
  80170. */
  80171. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  80172. /**
  80173. * Use this predicate to dynamically define the list of mesh you want to render.
  80174. * If set, the renderList property will be overwritten.
  80175. */
  80176. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  80177. private _renderList;
  80178. /**
  80179. * Use this list to define the list of mesh you want to render.
  80180. */
  80181. renderList: Nullable<Array<AbstractMesh>>;
  80182. private _hookArray;
  80183. /**
  80184. * Define if particles should be rendered in your texture.
  80185. */
  80186. renderParticles: boolean;
  80187. /**
  80188. * Define if sprites should be rendered in your texture.
  80189. */
  80190. renderSprites: boolean;
  80191. /**
  80192. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  80193. */
  80194. coordinatesMode: number;
  80195. /**
  80196. * Define the camera used to render the texture.
  80197. */
  80198. activeCamera: Nullable<Camera>;
  80199. /**
  80200. * Override the render function of the texture with your own one.
  80201. */
  80202. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  80203. /**
  80204. * Define if camera post processes should be use while rendering the texture.
  80205. */
  80206. useCameraPostProcesses: boolean;
  80207. /**
  80208. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  80209. */
  80210. ignoreCameraViewport: boolean;
  80211. private _postProcessManager;
  80212. private _postProcesses;
  80213. private _resizeObserver;
  80214. /**
  80215. * An event triggered when the texture is unbind.
  80216. */
  80217. onBeforeBindObservable: Observable<RenderTargetTexture>;
  80218. /**
  80219. * An event triggered when the texture is unbind.
  80220. */
  80221. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  80222. private _onAfterUnbindObserver;
  80223. /**
  80224. * Set a after unbind callback in the texture.
  80225. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  80226. */
  80227. onAfterUnbind: () => void;
  80228. /**
  80229. * An event triggered before rendering the texture
  80230. */
  80231. onBeforeRenderObservable: Observable<number>;
  80232. private _onBeforeRenderObserver;
  80233. /**
  80234. * Set a before render callback in the texture.
  80235. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  80236. */
  80237. onBeforeRender: (faceIndex: number) => void;
  80238. /**
  80239. * An event triggered after rendering the texture
  80240. */
  80241. onAfterRenderObservable: Observable<number>;
  80242. private _onAfterRenderObserver;
  80243. /**
  80244. * Set a after render callback in the texture.
  80245. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  80246. */
  80247. onAfterRender: (faceIndex: number) => void;
  80248. /**
  80249. * An event triggered after the texture clear
  80250. */
  80251. onClearObservable: Observable<Engine>;
  80252. private _onClearObserver;
  80253. /**
  80254. * Set a clear callback in the texture.
  80255. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  80256. */
  80257. onClear: (Engine: Engine) => void;
  80258. /**
  80259. * Define the clear color of the Render Target if it should be different from the scene.
  80260. */
  80261. clearColor: Color4;
  80262. protected _size: number | {
  80263. width: number;
  80264. height: number;
  80265. };
  80266. protected _initialSizeParameter: number | {
  80267. width: number;
  80268. height: number;
  80269. } | {
  80270. ratio: number;
  80271. };
  80272. protected _sizeRatio: Nullable<number>;
  80273. /** @hidden */
  80274. _generateMipMaps: boolean;
  80275. protected _renderingManager: RenderingManager;
  80276. /** @hidden */
  80277. _waitingRenderList: string[];
  80278. protected _doNotChangeAspectRatio: boolean;
  80279. protected _currentRefreshId: number;
  80280. protected _refreshRate: number;
  80281. protected _textureMatrix: Matrix;
  80282. protected _samples: number;
  80283. protected _renderTargetOptions: RenderTargetCreationOptions;
  80284. /**
  80285. * Gets render target creation options that were used.
  80286. */
  80287. readonly renderTargetOptions: RenderTargetCreationOptions;
  80288. protected _engine: Engine;
  80289. protected _onRatioRescale(): void;
  80290. /**
  80291. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  80292. * It must define where the camera used to render the texture is set
  80293. */
  80294. boundingBoxPosition: Vector3;
  80295. private _boundingBoxSize;
  80296. /**
  80297. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  80298. * When defined, the cubemap will switch to local mode
  80299. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80300. * @example https://www.babylonjs-playground.com/#RNASML
  80301. */
  80302. boundingBoxSize: Vector3;
  80303. /**
  80304. * In case the RTT has been created with a depth texture, get the associated
  80305. * depth texture.
  80306. * Otherwise, return null.
  80307. */
  80308. depthStencilTexture: Nullable<InternalTexture>;
  80309. /**
  80310. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  80311. * or used a shadow, depth texture...
  80312. * @param name The friendly name of the texture
  80313. * @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)
  80314. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  80315. * @param generateMipMaps True if mip maps need to be generated after render.
  80316. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  80317. * @param type The type of the buffer in the RTT (int, half float, float...)
  80318. * @param isCube True if a cube texture needs to be created
  80319. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  80320. * @param generateDepthBuffer True to generate a depth buffer
  80321. * @param generateStencilBuffer True to generate a stencil buffer
  80322. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  80323. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  80324. * @param delayAllocation if the texture allocation should be delayed (default: false)
  80325. */
  80326. constructor(name: string, size: number | {
  80327. width: number;
  80328. height: number;
  80329. } | {
  80330. ratio: number;
  80331. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  80332. /**
  80333. * Creates a depth stencil texture.
  80334. * This is only available in WebGL 2 or with the depth texture extension available.
  80335. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  80336. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  80337. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  80338. */
  80339. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  80340. private _processSizeParameter;
  80341. /**
  80342. * Define the number of samples to use in case of MSAA.
  80343. * It defaults to one meaning no MSAA has been enabled.
  80344. */
  80345. samples: number;
  80346. /**
  80347. * Resets the refresh counter of the texture and start bak from scratch.
  80348. * Could be useful to regenerate the texture if it is setup to render only once.
  80349. */
  80350. resetRefreshCounter(): void;
  80351. /**
  80352. * Define the refresh rate of the texture or the rendering frequency.
  80353. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  80354. */
  80355. refreshRate: number;
  80356. /**
  80357. * Adds a post process to the render target rendering passes.
  80358. * @param postProcess define the post process to add
  80359. */
  80360. addPostProcess(postProcess: PostProcess): void;
  80361. /**
  80362. * Clear all the post processes attached to the render target
  80363. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  80364. */
  80365. clearPostProcesses(dispose?: boolean): void;
  80366. /**
  80367. * Remove one of the post process from the list of attached post processes to the texture
  80368. * @param postProcess define the post process to remove from the list
  80369. */
  80370. removePostProcess(postProcess: PostProcess): void;
  80371. /** @hidden */
  80372. _shouldRender(): boolean;
  80373. /**
  80374. * Gets the actual render size of the texture.
  80375. * @returns the width of the render size
  80376. */
  80377. getRenderSize(): number;
  80378. /**
  80379. * Gets the actual render width of the texture.
  80380. * @returns the width of the render size
  80381. */
  80382. getRenderWidth(): number;
  80383. /**
  80384. * Gets the actual render height of the texture.
  80385. * @returns the height of the render size
  80386. */
  80387. getRenderHeight(): number;
  80388. /**
  80389. * Get if the texture can be rescaled or not.
  80390. */
  80391. readonly canRescale: boolean;
  80392. /**
  80393. * Resize the texture using a ratio.
  80394. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  80395. */
  80396. scale(ratio: number): void;
  80397. /**
  80398. * Get the texture reflection matrix used to rotate/transform the reflection.
  80399. * @returns the reflection matrix
  80400. */
  80401. getReflectionTextureMatrix(): Matrix;
  80402. /**
  80403. * Resize the texture to a new desired size.
  80404. * Be carrefull as it will recreate all the data in the new texture.
  80405. * @param size Define the new size. It can be:
  80406. * - a number for squared texture,
  80407. * - an object containing { width: number, height: number }
  80408. * - or an object containing a ratio { ratio: number }
  80409. */
  80410. resize(size: number | {
  80411. width: number;
  80412. height: number;
  80413. } | {
  80414. ratio: number;
  80415. }): void;
  80416. /**
  80417. * Renders all the objects from the render list into the texture.
  80418. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  80419. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  80420. */
  80421. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  80422. private _bestReflectionRenderTargetDimension;
  80423. /**
  80424. * @hidden
  80425. * @param faceIndex face index to bind to if this is a cubetexture
  80426. */
  80427. _bindFrameBuffer(faceIndex?: number): void;
  80428. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  80429. private renderToTarget;
  80430. /**
  80431. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80432. * This allowed control for front to back rendering or reversly depending of the special needs.
  80433. *
  80434. * @param renderingGroupId The rendering group id corresponding to its index
  80435. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80436. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80437. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80438. */
  80439. 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;
  80440. /**
  80441. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80442. *
  80443. * @param renderingGroupId The rendering group id corresponding to its index
  80444. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80445. */
  80446. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  80447. /**
  80448. * Clones the texture.
  80449. * @returns the cloned texture
  80450. */
  80451. clone(): RenderTargetTexture;
  80452. /**
  80453. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80454. * @returns The JSON representation of the texture
  80455. */
  80456. serialize(): any;
  80457. /**
  80458. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  80459. */
  80460. disposeFramebufferObjects(): void;
  80461. /**
  80462. * Dispose the texture and release its associated resources.
  80463. */
  80464. dispose(): void;
  80465. /** @hidden */
  80466. _rebuild(): void;
  80467. /**
  80468. * Clear the info related to rendering groups preventing retention point in material dispose.
  80469. */
  80470. freeRenderingGroups(): void;
  80471. /**
  80472. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80473. * @returns the view count
  80474. */
  80475. getViewCount(): number;
  80476. }
  80477. }
  80478. declare module BABYLON {
  80479. /**
  80480. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80481. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80482. * You can then easily use it as a reflectionTexture on a flat surface.
  80483. * In case the surface is not a plane, please consider relying on reflection probes.
  80484. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80485. */
  80486. export class MirrorTexture extends RenderTargetTexture {
  80487. private scene;
  80488. /**
  80489. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80490. * 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.
  80491. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80492. */
  80493. mirrorPlane: Plane;
  80494. /**
  80495. * Define the blur ratio used to blur the reflection if needed.
  80496. */
  80497. blurRatio: number;
  80498. /**
  80499. * Define the adaptive blur kernel used to blur the reflection if needed.
  80500. * This will autocompute the closest best match for the `blurKernel`
  80501. */
  80502. adaptiveBlurKernel: number;
  80503. /**
  80504. * Define the blur kernel used to blur the reflection if needed.
  80505. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80506. */
  80507. blurKernel: number;
  80508. /**
  80509. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80510. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80511. */
  80512. blurKernelX: number;
  80513. /**
  80514. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80515. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80516. */
  80517. blurKernelY: number;
  80518. private _autoComputeBlurKernel;
  80519. protected _onRatioRescale(): void;
  80520. private _updateGammaSpace;
  80521. private _imageProcessingConfigChangeObserver;
  80522. private _transformMatrix;
  80523. private _mirrorMatrix;
  80524. private _savedViewMatrix;
  80525. private _blurX;
  80526. private _blurY;
  80527. private _adaptiveBlurKernel;
  80528. private _blurKernelX;
  80529. private _blurKernelY;
  80530. private _blurRatio;
  80531. /**
  80532. * Instantiates a Mirror Texture.
  80533. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80534. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80535. * You can then easily use it as a reflectionTexture on a flat surface.
  80536. * In case the surface is not a plane, please consider relying on reflection probes.
  80537. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80538. * @param name
  80539. * @param size
  80540. * @param scene
  80541. * @param generateMipMaps
  80542. * @param type
  80543. * @param samplingMode
  80544. * @param generateDepthBuffer
  80545. */
  80546. constructor(name: string, size: number | {
  80547. width: number;
  80548. height: number;
  80549. } | {
  80550. ratio: number;
  80551. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80552. private _preparePostProcesses;
  80553. /**
  80554. * Clone the mirror texture.
  80555. * @returns the cloned texture
  80556. */
  80557. clone(): MirrorTexture;
  80558. /**
  80559. * Serialize the texture to a JSON representation you could use in Parse later on
  80560. * @returns the serialized JSON representation
  80561. */
  80562. serialize(): any;
  80563. /**
  80564. * Dispose the texture and release its associated resources.
  80565. */
  80566. dispose(): void;
  80567. }
  80568. }
  80569. declare module BABYLON {
  80570. /**
  80571. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80572. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80573. */
  80574. export class Texture extends BaseTexture {
  80575. /** @hidden */
  80576. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80577. /** @hidden */
  80578. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80579. /** @hidden */
  80580. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80581. /** nearest is mag = nearest and min = nearest and mip = linear */
  80582. static readonly NEAREST_SAMPLINGMODE: number;
  80583. /** nearest is mag = nearest and min = nearest and mip = linear */
  80584. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80586. static readonly BILINEAR_SAMPLINGMODE: number;
  80587. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80588. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80589. /** Trilinear is mag = linear and min = linear and mip = linear */
  80590. static readonly TRILINEAR_SAMPLINGMODE: number;
  80591. /** Trilinear is mag = linear and min = linear and mip = linear */
  80592. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80593. /** mag = nearest and min = nearest and mip = nearest */
  80594. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80595. /** mag = nearest and min = linear and mip = nearest */
  80596. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80597. /** mag = nearest and min = linear and mip = linear */
  80598. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80599. /** mag = nearest and min = linear and mip = none */
  80600. static readonly NEAREST_LINEAR: number;
  80601. /** mag = nearest and min = nearest and mip = none */
  80602. static readonly NEAREST_NEAREST: number;
  80603. /** mag = linear and min = nearest and mip = nearest */
  80604. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80605. /** mag = linear and min = nearest and mip = linear */
  80606. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80607. /** mag = linear and min = linear and mip = none */
  80608. static readonly LINEAR_LINEAR: number;
  80609. /** mag = linear and min = nearest and mip = none */
  80610. static readonly LINEAR_NEAREST: number;
  80611. /** Explicit coordinates mode */
  80612. static readonly EXPLICIT_MODE: number;
  80613. /** Spherical coordinates mode */
  80614. static readonly SPHERICAL_MODE: number;
  80615. /** Planar coordinates mode */
  80616. static readonly PLANAR_MODE: number;
  80617. /** Cubic coordinates mode */
  80618. static readonly CUBIC_MODE: number;
  80619. /** Projection coordinates mode */
  80620. static readonly PROJECTION_MODE: number;
  80621. /** Inverse Cubic coordinates mode */
  80622. static readonly SKYBOX_MODE: number;
  80623. /** Inverse Cubic coordinates mode */
  80624. static readonly INVCUBIC_MODE: number;
  80625. /** Equirectangular coordinates mode */
  80626. static readonly EQUIRECTANGULAR_MODE: number;
  80627. /** Equirectangular Fixed coordinates mode */
  80628. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80629. /** Equirectangular Fixed Mirrored coordinates mode */
  80630. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80631. /** Texture is not repeating outside of 0..1 UVs */
  80632. static readonly CLAMP_ADDRESSMODE: number;
  80633. /** Texture is repeating outside of 0..1 UVs */
  80634. static readonly WRAP_ADDRESSMODE: number;
  80635. /** Texture is repeating and mirrored */
  80636. static readonly MIRROR_ADDRESSMODE: number;
  80637. /**
  80638. * 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
  80639. */
  80640. static UseSerializedUrlIfAny: boolean;
  80641. /**
  80642. * Define the url of the texture.
  80643. */
  80644. url: Nullable<string>;
  80645. /**
  80646. * Define an offset on the texture to offset the u coordinates of the UVs
  80647. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80648. */
  80649. uOffset: number;
  80650. /**
  80651. * Define an offset on the texture to offset the v coordinates of the UVs
  80652. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80653. */
  80654. vOffset: number;
  80655. /**
  80656. * Define an offset on the texture to scale the u coordinates of the UVs
  80657. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80658. */
  80659. uScale: number;
  80660. /**
  80661. * Define an offset on the texture to scale the v coordinates of the UVs
  80662. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80663. */
  80664. vScale: number;
  80665. /**
  80666. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80667. * @see http://doc.babylonjs.com/how_to/more_materials
  80668. */
  80669. uAng: number;
  80670. /**
  80671. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80672. * @see http://doc.babylonjs.com/how_to/more_materials
  80673. */
  80674. vAng: number;
  80675. /**
  80676. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80677. * @see http://doc.babylonjs.com/how_to/more_materials
  80678. */
  80679. wAng: number;
  80680. /**
  80681. * Defines the center of rotation (U)
  80682. */
  80683. uRotationCenter: number;
  80684. /**
  80685. * Defines the center of rotation (V)
  80686. */
  80687. vRotationCenter: number;
  80688. /**
  80689. * Defines the center of rotation (W)
  80690. */
  80691. wRotationCenter: number;
  80692. /**
  80693. * Are mip maps generated for this texture or not.
  80694. */
  80695. readonly noMipmap: boolean;
  80696. /**
  80697. * List of inspectable custom properties (used by the Inspector)
  80698. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80699. */
  80700. inspectableCustomProperties: Nullable<IInspectable[]>;
  80701. private _noMipmap;
  80702. /** @hidden */
  80703. _invertY: boolean;
  80704. private _rowGenerationMatrix;
  80705. private _cachedTextureMatrix;
  80706. private _projectionModeMatrix;
  80707. private _t0;
  80708. private _t1;
  80709. private _t2;
  80710. private _cachedUOffset;
  80711. private _cachedVOffset;
  80712. private _cachedUScale;
  80713. private _cachedVScale;
  80714. private _cachedUAng;
  80715. private _cachedVAng;
  80716. private _cachedWAng;
  80717. private _cachedProjectionMatrixId;
  80718. private _cachedCoordinatesMode;
  80719. /** @hidden */
  80720. protected _initialSamplingMode: number;
  80721. /** @hidden */
  80722. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80723. private _deleteBuffer;
  80724. protected _format: Nullable<number>;
  80725. private _delayedOnLoad;
  80726. private _delayedOnError;
  80727. /**
  80728. * Observable triggered once the texture has been loaded.
  80729. */
  80730. onLoadObservable: Observable<Texture>;
  80731. protected _isBlocking: boolean;
  80732. /**
  80733. * Is the texture preventing material to render while loading.
  80734. * If false, a default texture will be used instead of the loading one during the preparation step.
  80735. */
  80736. isBlocking: boolean;
  80737. /**
  80738. * Get the current sampling mode associated with the texture.
  80739. */
  80740. readonly samplingMode: number;
  80741. /**
  80742. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80743. */
  80744. readonly invertY: boolean;
  80745. /**
  80746. * Instantiates a new texture.
  80747. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80748. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80749. * @param url define the url of the picture to load as a texture
  80750. * @param scene define the scene the texture will belong to
  80751. * @param noMipmap define if the texture will require mip maps or not
  80752. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80753. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80754. * @param onLoad define a callback triggered when the texture has been loaded
  80755. * @param onError define a callback triggered when an error occurred during the loading session
  80756. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80757. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80758. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80759. */
  80760. 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);
  80761. /**
  80762. * Update the url (and optional buffer) of this texture if url was null during construction.
  80763. * @param url the url of the texture
  80764. * @param buffer the buffer of the texture (defaults to null)
  80765. * @param onLoad callback called when the texture is loaded (defaults to null)
  80766. */
  80767. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80768. /**
  80769. * Finish the loading sequence of a texture flagged as delayed load.
  80770. * @hidden
  80771. */
  80772. delayLoad(): void;
  80773. private _prepareRowForTextureGeneration;
  80774. /**
  80775. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80776. * @returns the transform matrix of the texture.
  80777. */
  80778. getTextureMatrix(): Matrix;
  80779. /**
  80780. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80781. * @returns The reflection texture transform
  80782. */
  80783. getReflectionTextureMatrix(): Matrix;
  80784. /**
  80785. * Clones the texture.
  80786. * @returns the cloned texture
  80787. */
  80788. clone(): Texture;
  80789. /**
  80790. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80791. * @returns The JSON representation of the texture
  80792. */
  80793. serialize(): any;
  80794. /**
  80795. * Get the current class name of the texture useful for serialization or dynamic coding.
  80796. * @returns "Texture"
  80797. */
  80798. getClassName(): string;
  80799. /**
  80800. * Dispose the texture and release its associated resources.
  80801. */
  80802. dispose(): void;
  80803. /**
  80804. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80805. * @param parsedTexture Define the JSON representation of the texture
  80806. * @param scene Define the scene the parsed texture should be instantiated in
  80807. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80808. * @returns The parsed texture if successful
  80809. */
  80810. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80811. /**
  80812. * Creates a texture from its base 64 representation.
  80813. * @param data Define the base64 payload without the data: prefix
  80814. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80815. * @param scene Define the scene the texture should belong to
  80816. * @param noMipmap Forces the texture to not create mip map information if true
  80817. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80818. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80819. * @param onLoad define a callback triggered when the texture has been loaded
  80820. * @param onError define a callback triggered when an error occurred during the loading session
  80821. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80822. * @returns the created texture
  80823. */
  80824. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80825. /**
  80826. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80827. * @param data Define the base64 payload without the data: prefix
  80828. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80829. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80830. * @param scene Define the scene the texture should belong to
  80831. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80832. * @param noMipmap Forces the texture to not create mip map information if true
  80833. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80834. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80835. * @param onLoad define a callback triggered when the texture has been loaded
  80836. * @param onError define a callback triggered when an error occurred during the loading session
  80837. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80838. * @returns the created texture
  80839. */
  80840. 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;
  80841. }
  80842. }
  80843. declare module BABYLON {
  80844. interface Engine {
  80845. /**
  80846. * Creates a raw texture
  80847. * @param data defines the data to store in the texture
  80848. * @param width defines the width of the texture
  80849. * @param height defines the height of the texture
  80850. * @param format defines the format of the data
  80851. * @param generateMipMaps defines if the engine should generate the mip levels
  80852. * @param invertY defines if data must be stored with Y axis inverted
  80853. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80854. * @param compression defines the compression used (null by default)
  80855. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80856. * @returns the raw texture inside an InternalTexture
  80857. */
  80858. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80859. /**
  80860. * Update a raw texture
  80861. * @param texture defines the texture to update
  80862. * @param data defines the data to store in the texture
  80863. * @param format defines the format of the data
  80864. * @param invertY defines if data must be stored with Y axis inverted
  80865. */
  80866. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80867. /**
  80868. * Update a raw texture
  80869. * @param texture defines the texture to update
  80870. * @param data defines the data to store in the texture
  80871. * @param format defines the format of the data
  80872. * @param invertY defines if data must be stored with Y axis inverted
  80873. * @param compression defines the compression used (null by default)
  80874. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80875. */
  80876. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80877. /**
  80878. * Creates a new raw cube texture
  80879. * @param data defines the array of data to use to create each face
  80880. * @param size defines the size of the textures
  80881. * @param format defines the format of the data
  80882. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80883. * @param generateMipMaps defines if the engine should generate the mip levels
  80884. * @param invertY defines if data must be stored with Y axis inverted
  80885. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80886. * @param compression defines the compression used (null by default)
  80887. * @returns the cube texture as an InternalTexture
  80888. */
  80889. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80890. /**
  80891. * Update a raw cube texture
  80892. * @param texture defines the texture to udpdate
  80893. * @param data defines the data to store
  80894. * @param format defines the data format
  80895. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80896. * @param invertY defines if data must be stored with Y axis inverted
  80897. */
  80898. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80899. /**
  80900. * Update a raw cube texture
  80901. * @param texture defines the texture to udpdate
  80902. * @param data defines the data to store
  80903. * @param format defines the data format
  80904. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80905. * @param invertY defines if data must be stored with Y axis inverted
  80906. * @param compression defines the compression used (null by default)
  80907. */
  80908. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80909. /**
  80910. * Update a raw cube texture
  80911. * @param texture defines the texture to udpdate
  80912. * @param data defines the data to store
  80913. * @param format defines the data format
  80914. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80915. * @param invertY defines if data must be stored with Y axis inverted
  80916. * @param compression defines the compression used (null by default)
  80917. * @param level defines which level of the texture to update
  80918. */
  80919. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80920. /**
  80921. * Creates a new raw cube texture from a specified url
  80922. * @param url defines the url where the data is located
  80923. * @param scene defines the current scene
  80924. * @param size defines the size of the textures
  80925. * @param format defines the format of the data
  80926. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80927. * @param noMipmap defines if the engine should avoid generating the mip levels
  80928. * @param callback defines a callback used to extract texture data from loaded data
  80929. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80930. * @param onLoad defines a callback called when texture is loaded
  80931. * @param onError defines a callback called if there is an error
  80932. * @returns the cube texture as an InternalTexture
  80933. */
  80934. 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>): InternalTexture;
  80935. /**
  80936. * Creates a new raw cube texture from a specified url
  80937. * @param url defines the url where the data is located
  80938. * @param scene defines the current scene
  80939. * @param size defines the size of the textures
  80940. * @param format defines the format of the data
  80941. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80942. * @param noMipmap defines if the engine should avoid generating the mip levels
  80943. * @param callback defines a callback used to extract texture data from loaded data
  80944. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80945. * @param onLoad defines a callback called when texture is loaded
  80946. * @param onError defines a callback called if there is an error
  80947. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80948. * @param invertY defines if data must be stored with Y axis inverted
  80949. * @returns the cube texture as an InternalTexture
  80950. */
  80951. 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;
  80952. /**
  80953. * Creates a new raw 3D texture
  80954. * @param data defines the data used to create the texture
  80955. * @param width defines the width of the texture
  80956. * @param height defines the height of the texture
  80957. * @param depth defines the depth of the texture
  80958. * @param format defines the format of the texture
  80959. * @param generateMipMaps defines if the engine must generate mip levels
  80960. * @param invertY defines if data must be stored with Y axis inverted
  80961. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80962. * @param compression defines the compressed used (can be null)
  80963. * @param textureType defines the compressed used (can be null)
  80964. * @returns a new raw 3D texture (stored in an InternalTexture)
  80965. */
  80966. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80967. /**
  80968. * Update a raw 3D texture
  80969. * @param texture defines the texture to update
  80970. * @param data defines the data to store
  80971. * @param format defines the data format
  80972. * @param invertY defines if data must be stored with Y axis inverted
  80973. */
  80974. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80975. /**
  80976. * Update a raw 3D texture
  80977. * @param texture defines the texture to update
  80978. * @param data defines the data to store
  80979. * @param format defines the data format
  80980. * @param invertY defines if data must be stored with Y axis inverted
  80981. * @param compression defines the used compression (can be null)
  80982. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80983. */
  80984. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80985. }
  80986. }
  80987. declare module BABYLON {
  80988. /**
  80989. * Raw texture can help creating a texture directly from an array of data.
  80990. * This can be super useful if you either get the data from an uncompressed source or
  80991. * if you wish to create your texture pixel by pixel.
  80992. */
  80993. export class RawTexture extends Texture {
  80994. /**
  80995. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80996. */
  80997. format: number;
  80998. private _engine;
  80999. /**
  81000. * Instantiates a new RawTexture.
  81001. * Raw texture can help creating a texture directly from an array of data.
  81002. * This can be super useful if you either get the data from an uncompressed source or
  81003. * if you wish to create your texture pixel by pixel.
  81004. * @param data define the array of data to use to create the texture
  81005. * @param width define the width of the texture
  81006. * @param height define the height of the texture
  81007. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81008. * @param scene define the scene the texture belongs to
  81009. * @param generateMipMaps define whether mip maps should be generated or not
  81010. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81011. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81012. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81013. */
  81014. constructor(data: ArrayBufferView, width: number, height: number,
  81015. /**
  81016. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81017. */
  81018. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81019. /**
  81020. * Updates the texture underlying data.
  81021. * @param data Define the new data of the texture
  81022. */
  81023. update(data: ArrayBufferView): void;
  81024. /**
  81025. * Creates a luminance texture from some data.
  81026. * @param data Define the texture data
  81027. * @param width Define the width of the texture
  81028. * @param height Define the height of the texture
  81029. * @param scene Define the scene the texture belongs to
  81030. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81031. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81032. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81033. * @returns the luminance texture
  81034. */
  81035. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81036. /**
  81037. * Creates a luminance alpha texture from some data.
  81038. * @param data Define the texture data
  81039. * @param width Define the width of the texture
  81040. * @param height Define the height of the texture
  81041. * @param scene Define the scene the texture belongs to
  81042. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81043. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81044. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81045. * @returns the luminance alpha texture
  81046. */
  81047. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81048. /**
  81049. * Creates an alpha texture from some data.
  81050. * @param data Define the texture data
  81051. * @param width Define the width of the texture
  81052. * @param height Define the height of the texture
  81053. * @param scene Define the scene the texture belongs to
  81054. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81055. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81056. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81057. * @returns the alpha texture
  81058. */
  81059. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81060. /**
  81061. * Creates a RGB texture from some data.
  81062. * @param data Define the texture data
  81063. * @param width Define the width of the texture
  81064. * @param height Define the height of the texture
  81065. * @param scene Define the scene the texture belongs to
  81066. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81067. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81068. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81069. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81070. * @returns the RGB alpha texture
  81071. */
  81072. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81073. /**
  81074. * Creates a RGBA texture from some data.
  81075. * @param data Define the texture data
  81076. * @param width Define the width of the texture
  81077. * @param height Define the height of the texture
  81078. * @param scene Define the scene the texture belongs to
  81079. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81080. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81081. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81082. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81083. * @returns the RGBA texture
  81084. */
  81085. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81086. /**
  81087. * Creates a R texture from some data.
  81088. * @param data Define the texture data
  81089. * @param width Define the width of the texture
  81090. * @param height Define the height of the texture
  81091. * @param scene Define the scene the texture belongs to
  81092. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81093. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81094. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81095. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81096. * @returns the R texture
  81097. */
  81098. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81099. }
  81100. }
  81101. declare module BABYLON {
  81102. /**
  81103. * Defines a runtime animation
  81104. */
  81105. export class RuntimeAnimation {
  81106. private _events;
  81107. /**
  81108. * The current frame of the runtime animation
  81109. */
  81110. private _currentFrame;
  81111. /**
  81112. * The animation used by the runtime animation
  81113. */
  81114. private _animation;
  81115. /**
  81116. * The target of the runtime animation
  81117. */
  81118. private _target;
  81119. /**
  81120. * The initiating animatable
  81121. */
  81122. private _host;
  81123. /**
  81124. * The original value of the runtime animation
  81125. */
  81126. private _originalValue;
  81127. /**
  81128. * The original blend value of the runtime animation
  81129. */
  81130. private _originalBlendValue;
  81131. /**
  81132. * The offsets cache of the runtime animation
  81133. */
  81134. private _offsetsCache;
  81135. /**
  81136. * The high limits cache of the runtime animation
  81137. */
  81138. private _highLimitsCache;
  81139. /**
  81140. * Specifies if the runtime animation has been stopped
  81141. */
  81142. private _stopped;
  81143. /**
  81144. * The blending factor of the runtime animation
  81145. */
  81146. private _blendingFactor;
  81147. /**
  81148. * The BabylonJS scene
  81149. */
  81150. private _scene;
  81151. /**
  81152. * The current value of the runtime animation
  81153. */
  81154. private _currentValue;
  81155. /** @hidden */
  81156. _animationState: _IAnimationState;
  81157. /**
  81158. * The active target of the runtime animation
  81159. */
  81160. private _activeTargets;
  81161. private _currentActiveTarget;
  81162. private _directTarget;
  81163. /**
  81164. * The target path of the runtime animation
  81165. */
  81166. private _targetPath;
  81167. /**
  81168. * The weight of the runtime animation
  81169. */
  81170. private _weight;
  81171. /**
  81172. * The ratio offset of the runtime animation
  81173. */
  81174. private _ratioOffset;
  81175. /**
  81176. * The previous delay of the runtime animation
  81177. */
  81178. private _previousDelay;
  81179. /**
  81180. * The previous ratio of the runtime animation
  81181. */
  81182. private _previousRatio;
  81183. private _enableBlending;
  81184. private _keys;
  81185. private _minFrame;
  81186. private _maxFrame;
  81187. private _minValue;
  81188. private _maxValue;
  81189. private _targetIsArray;
  81190. /**
  81191. * Gets the current frame of the runtime animation
  81192. */
  81193. readonly currentFrame: number;
  81194. /**
  81195. * Gets the weight of the runtime animation
  81196. */
  81197. readonly weight: number;
  81198. /**
  81199. * Gets the current value of the runtime animation
  81200. */
  81201. readonly currentValue: any;
  81202. /**
  81203. * Gets the target path of the runtime animation
  81204. */
  81205. readonly targetPath: string;
  81206. /**
  81207. * Gets the actual target of the runtime animation
  81208. */
  81209. readonly target: any;
  81210. /** @hidden */
  81211. _onLoop: () => void;
  81212. /**
  81213. * Create a new RuntimeAnimation object
  81214. * @param target defines the target of the animation
  81215. * @param animation defines the source animation object
  81216. * @param scene defines the hosting scene
  81217. * @param host defines the initiating Animatable
  81218. */
  81219. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81220. private _preparePath;
  81221. /**
  81222. * Gets the animation from the runtime animation
  81223. */
  81224. readonly animation: Animation;
  81225. /**
  81226. * Resets the runtime animation to the beginning
  81227. * @param restoreOriginal defines whether to restore the target property to the original value
  81228. */
  81229. reset(restoreOriginal?: boolean): void;
  81230. /**
  81231. * Specifies if the runtime animation is stopped
  81232. * @returns Boolean specifying if the runtime animation is stopped
  81233. */
  81234. isStopped(): boolean;
  81235. /**
  81236. * Disposes of the runtime animation
  81237. */
  81238. dispose(): void;
  81239. /**
  81240. * Apply the interpolated value to the target
  81241. * @param currentValue defines the value computed by the animation
  81242. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81243. */
  81244. setValue(currentValue: any, weight: number): void;
  81245. private _getOriginalValues;
  81246. private _setValue;
  81247. /**
  81248. * Gets the loop pmode of the runtime animation
  81249. * @returns Loop Mode
  81250. */
  81251. private _getCorrectLoopMode;
  81252. /**
  81253. * Move the current animation to a given frame
  81254. * @param frame defines the frame to move to
  81255. */
  81256. goToFrame(frame: number): void;
  81257. /**
  81258. * @hidden Internal use only
  81259. */
  81260. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81261. /**
  81262. * Execute the current animation
  81263. * @param delay defines the delay to add to the current frame
  81264. * @param from defines the lower bound of the animation range
  81265. * @param to defines the upper bound of the animation range
  81266. * @param loop defines if the current animation must loop
  81267. * @param speedRatio defines the current speed ratio
  81268. * @param weight defines the weight of the animation (default is -1 so no weight)
  81269. * @param onLoop optional callback called when animation loops
  81270. * @returns a boolean indicating if the animation is running
  81271. */
  81272. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81273. }
  81274. }
  81275. declare module BABYLON {
  81276. /**
  81277. * Class used to store an actual running animation
  81278. */
  81279. export class Animatable {
  81280. /** defines the target object */
  81281. target: any;
  81282. /** defines the starting frame number (default is 0) */
  81283. fromFrame: number;
  81284. /** defines the ending frame number (default is 100) */
  81285. toFrame: number;
  81286. /** defines if the animation must loop (default is false) */
  81287. loopAnimation: boolean;
  81288. /** defines a callback to call when animation ends if it is not looping */
  81289. onAnimationEnd?: (() => void) | null | undefined;
  81290. /** defines a callback to call when animation loops */
  81291. onAnimationLoop?: (() => void) | null | undefined;
  81292. private _localDelayOffset;
  81293. private _pausedDelay;
  81294. private _runtimeAnimations;
  81295. private _paused;
  81296. private _scene;
  81297. private _speedRatio;
  81298. private _weight;
  81299. private _syncRoot;
  81300. /**
  81301. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81302. * This will only apply for non looping animation (default is true)
  81303. */
  81304. disposeOnEnd: boolean;
  81305. /**
  81306. * Gets a boolean indicating if the animation has started
  81307. */
  81308. animationStarted: boolean;
  81309. /**
  81310. * Observer raised when the animation ends
  81311. */
  81312. onAnimationEndObservable: Observable<Animatable>;
  81313. /**
  81314. * Observer raised when the animation loops
  81315. */
  81316. onAnimationLoopObservable: Observable<Animatable>;
  81317. /**
  81318. * Gets the root Animatable used to synchronize and normalize animations
  81319. */
  81320. readonly syncRoot: Nullable<Animatable>;
  81321. /**
  81322. * Gets the current frame of the first RuntimeAnimation
  81323. * Used to synchronize Animatables
  81324. */
  81325. readonly masterFrame: number;
  81326. /**
  81327. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81328. */
  81329. weight: number;
  81330. /**
  81331. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81332. */
  81333. speedRatio: number;
  81334. /**
  81335. * Creates a new Animatable
  81336. * @param scene defines the hosting scene
  81337. * @param target defines the target object
  81338. * @param fromFrame defines the starting frame number (default is 0)
  81339. * @param toFrame defines the ending frame number (default is 100)
  81340. * @param loopAnimation defines if the animation must loop (default is false)
  81341. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81342. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81343. * @param animations defines a group of animation to add to the new Animatable
  81344. * @param onAnimationLoop defines a callback to call when animation loops
  81345. */
  81346. constructor(scene: Scene,
  81347. /** defines the target object */
  81348. target: any,
  81349. /** defines the starting frame number (default is 0) */
  81350. fromFrame?: number,
  81351. /** defines the ending frame number (default is 100) */
  81352. toFrame?: number,
  81353. /** defines if the animation must loop (default is false) */
  81354. loopAnimation?: boolean, speedRatio?: number,
  81355. /** defines a callback to call when animation ends if it is not looping */
  81356. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81357. /** defines a callback to call when animation loops */
  81358. onAnimationLoop?: (() => void) | null | undefined);
  81359. /**
  81360. * Synchronize and normalize current Animatable with a source Animatable
  81361. * This is useful when using animation weights and when animations are not of the same length
  81362. * @param root defines the root Animatable to synchronize with
  81363. * @returns the current Animatable
  81364. */
  81365. syncWith(root: Animatable): Animatable;
  81366. /**
  81367. * Gets the list of runtime animations
  81368. * @returns an array of RuntimeAnimation
  81369. */
  81370. getAnimations(): RuntimeAnimation[];
  81371. /**
  81372. * Adds more animations to the current animatable
  81373. * @param target defines the target of the animations
  81374. * @param animations defines the new animations to add
  81375. */
  81376. appendAnimations(target: any, animations: Animation[]): void;
  81377. /**
  81378. * Gets the source animation for a specific property
  81379. * @param property defines the propertyu to look for
  81380. * @returns null or the source animation for the given property
  81381. */
  81382. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81383. /**
  81384. * Gets the runtime animation for a specific property
  81385. * @param property defines the propertyu to look for
  81386. * @returns null or the runtime animation for the given property
  81387. */
  81388. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81389. /**
  81390. * Resets the animatable to its original state
  81391. */
  81392. reset(): void;
  81393. /**
  81394. * Allows the animatable to blend with current running animations
  81395. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81396. * @param blendingSpeed defines the blending speed to use
  81397. */
  81398. enableBlending(blendingSpeed: number): void;
  81399. /**
  81400. * Disable animation blending
  81401. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81402. */
  81403. disableBlending(): void;
  81404. /**
  81405. * Jump directly to a given frame
  81406. * @param frame defines the frame to jump to
  81407. */
  81408. goToFrame(frame: number): void;
  81409. /**
  81410. * Pause the animation
  81411. */
  81412. pause(): void;
  81413. /**
  81414. * Restart the animation
  81415. */
  81416. restart(): void;
  81417. private _raiseOnAnimationEnd;
  81418. /**
  81419. * Stop and delete the current animation
  81420. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81421. * @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)
  81422. */
  81423. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81424. /**
  81425. * Wait asynchronously for the animation to end
  81426. * @returns a promise which will be fullfilled when the animation ends
  81427. */
  81428. waitAsync(): Promise<Animatable>;
  81429. /** @hidden */
  81430. _animate(delay: number): boolean;
  81431. }
  81432. interface Scene {
  81433. /** @hidden */
  81434. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81435. /** @hidden */
  81436. _processLateAnimationBindingsForMatrices(holder: {
  81437. totalWeight: number;
  81438. animations: RuntimeAnimation[];
  81439. originalValue: Matrix;
  81440. }): any;
  81441. /** @hidden */
  81442. _processLateAnimationBindingsForQuaternions(holder: {
  81443. totalWeight: number;
  81444. animations: RuntimeAnimation[];
  81445. originalValue: Quaternion;
  81446. }, refQuaternion: Quaternion): Quaternion;
  81447. /** @hidden */
  81448. _processLateAnimationBindings(): void;
  81449. /**
  81450. * Will start the animation sequence of a given target
  81451. * @param target defines the target
  81452. * @param from defines from which frame should animation start
  81453. * @param to defines until which frame should animation run.
  81454. * @param weight defines the weight to apply to the animation (1.0 by default)
  81455. * @param loop defines if the animation loops
  81456. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81457. * @param onAnimationEnd defines the function to be executed when the animation ends
  81458. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81459. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81460. * @param onAnimationLoop defines the callback to call when an animation loops
  81461. * @returns the animatable object created for this animation
  81462. */
  81463. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81464. /**
  81465. * Will start the animation sequence of a given target
  81466. * @param target defines the target
  81467. * @param from defines from which frame should animation start
  81468. * @param to defines until which frame should animation run.
  81469. * @param loop defines if the animation loops
  81470. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81471. * @param onAnimationEnd defines the function to be executed when the animation ends
  81472. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81473. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81474. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81475. * @param onAnimationLoop defines the callback to call when an animation loops
  81476. * @returns the animatable object created for this animation
  81477. */
  81478. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81479. /**
  81480. * Will start the animation sequence of a given target and its hierarchy
  81481. * @param target defines the target
  81482. * @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.
  81483. * @param from defines from which frame should animation start
  81484. * @param to defines until which frame should animation run.
  81485. * @param loop defines if the animation loops
  81486. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81487. * @param onAnimationEnd defines the function to be executed when the animation ends
  81488. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81489. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81490. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81491. * @param onAnimationLoop defines the callback to call when an animation loops
  81492. * @returns the list of created animatables
  81493. */
  81494. 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[];
  81495. /**
  81496. * Begin a new animation on a given node
  81497. * @param target defines the target where the animation will take place
  81498. * @param animations defines the list of animations to start
  81499. * @param from defines the initial value
  81500. * @param to defines the final value
  81501. * @param loop defines if you want animation to loop (off by default)
  81502. * @param speedRatio defines the speed ratio to apply to all animations
  81503. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81504. * @param onAnimationLoop defines the callback to call when an animation loops
  81505. * @returns the list of created animatables
  81506. */
  81507. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81508. /**
  81509. * Begin a new animation on a given node and its hierarchy
  81510. * @param target defines the root node where the animation will take place
  81511. * @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.
  81512. * @param animations defines the list of animations to start
  81513. * @param from defines the initial value
  81514. * @param to defines the final value
  81515. * @param loop defines if you want animation to loop (off by default)
  81516. * @param speedRatio defines the speed ratio to apply to all animations
  81517. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81518. * @param onAnimationLoop defines the callback to call when an animation loops
  81519. * @returns the list of animatables created for all nodes
  81520. */
  81521. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81522. /**
  81523. * Gets the animatable associated with a specific target
  81524. * @param target defines the target of the animatable
  81525. * @returns the required animatable if found
  81526. */
  81527. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81528. /**
  81529. * Gets all animatables associated with a given target
  81530. * @param target defines the target to look animatables for
  81531. * @returns an array of Animatables
  81532. */
  81533. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81534. /**
  81535. * Stops and removes all animations that have been applied to the scene
  81536. */
  81537. stopAllAnimations(): void;
  81538. }
  81539. interface Bone {
  81540. /**
  81541. * Copy an animation range from another bone
  81542. * @param source defines the source bone
  81543. * @param rangeName defines the range name to copy
  81544. * @param frameOffset defines the frame offset
  81545. * @param rescaleAsRequired defines if rescaling must be applied if required
  81546. * @param skelDimensionsRatio defines the scaling ratio
  81547. * @returns true if operation was successful
  81548. */
  81549. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81550. }
  81551. }
  81552. declare module BABYLON {
  81553. /**
  81554. * Class used to handle skinning animations
  81555. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81556. */
  81557. export class Skeleton implements IAnimatable {
  81558. /** defines the skeleton name */
  81559. name: string;
  81560. /** defines the skeleton Id */
  81561. id: string;
  81562. /**
  81563. * Defines the list of child bones
  81564. */
  81565. bones: Bone[];
  81566. /**
  81567. * Defines an estimate of the dimension of the skeleton at rest
  81568. */
  81569. dimensionsAtRest: Vector3;
  81570. /**
  81571. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81572. */
  81573. needInitialSkinMatrix: boolean;
  81574. /**
  81575. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81576. */
  81577. overrideMesh: Nullable<AbstractMesh>;
  81578. /**
  81579. * Gets the list of animations attached to this skeleton
  81580. */
  81581. animations: Array<Animation>;
  81582. private _scene;
  81583. private _isDirty;
  81584. private _transformMatrices;
  81585. private _transformMatrixTexture;
  81586. private _meshesWithPoseMatrix;
  81587. private _animatables;
  81588. private _identity;
  81589. private _synchronizedWithMesh;
  81590. private _ranges;
  81591. private _lastAbsoluteTransformsUpdateId;
  81592. private _canUseTextureForBones;
  81593. private _uniqueId;
  81594. /** @hidden */
  81595. _numBonesWithLinkedTransformNode: number;
  81596. /** @hidden */
  81597. _hasWaitingData: Nullable<boolean>;
  81598. /**
  81599. * Specifies if the skeleton should be serialized
  81600. */
  81601. doNotSerialize: boolean;
  81602. private _useTextureToStoreBoneMatrices;
  81603. /**
  81604. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81605. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  81606. */
  81607. useTextureToStoreBoneMatrices: boolean;
  81608. private _animationPropertiesOverride;
  81609. /**
  81610. * Gets or sets the animation properties override
  81611. */
  81612. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81613. /**
  81614. * List of inspectable custom properties (used by the Inspector)
  81615. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81616. */
  81617. inspectableCustomProperties: IInspectable[];
  81618. /**
  81619. * An observable triggered before computing the skeleton's matrices
  81620. */
  81621. onBeforeComputeObservable: Observable<Skeleton>;
  81622. /**
  81623. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81624. */
  81625. readonly isUsingTextureForMatrices: boolean;
  81626. /**
  81627. * Gets the unique ID of this skeleton
  81628. */
  81629. readonly uniqueId: number;
  81630. /**
  81631. * Creates a new skeleton
  81632. * @param name defines the skeleton name
  81633. * @param id defines the skeleton Id
  81634. * @param scene defines the hosting scene
  81635. */
  81636. constructor(
  81637. /** defines the skeleton name */
  81638. name: string,
  81639. /** defines the skeleton Id */
  81640. id: string, scene: Scene);
  81641. /**
  81642. * Gets the current object class name.
  81643. * @return the class name
  81644. */
  81645. getClassName(): string;
  81646. /**
  81647. * Returns an array containing the root bones
  81648. * @returns an array containing the root bones
  81649. */
  81650. getChildren(): Array<Bone>;
  81651. /**
  81652. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81653. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81654. * @returns a Float32Array containing matrices data
  81655. */
  81656. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81657. /**
  81658. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81659. * @returns a raw texture containing the data
  81660. */
  81661. getTransformMatrixTexture(): Nullable<RawTexture>;
  81662. /**
  81663. * Gets the current hosting scene
  81664. * @returns a scene object
  81665. */
  81666. getScene(): Scene;
  81667. /**
  81668. * Gets a string representing the current skeleton data
  81669. * @param fullDetails defines a boolean indicating if we want a verbose version
  81670. * @returns a string representing the current skeleton data
  81671. */
  81672. toString(fullDetails?: boolean): string;
  81673. /**
  81674. * Get bone's index searching by name
  81675. * @param name defines bone's name to search for
  81676. * @return the indice of the bone. Returns -1 if not found
  81677. */
  81678. getBoneIndexByName(name: string): number;
  81679. /**
  81680. * Creater a new animation range
  81681. * @param name defines the name of the range
  81682. * @param from defines the start key
  81683. * @param to defines the end key
  81684. */
  81685. createAnimationRange(name: string, from: number, to: number): void;
  81686. /**
  81687. * Delete a specific animation range
  81688. * @param name defines the name of the range
  81689. * @param deleteFrames defines if frames must be removed as well
  81690. */
  81691. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81692. /**
  81693. * Gets a specific animation range
  81694. * @param name defines the name of the range to look for
  81695. * @returns the requested animation range or null if not found
  81696. */
  81697. getAnimationRange(name: string): Nullable<AnimationRange>;
  81698. /**
  81699. * Gets the list of all animation ranges defined on this skeleton
  81700. * @returns an array
  81701. */
  81702. getAnimationRanges(): Nullable<AnimationRange>[];
  81703. /**
  81704. * Copy animation range from a source skeleton.
  81705. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81706. * @param source defines the source skeleton
  81707. * @param name defines the name of the range to copy
  81708. * @param rescaleAsRequired defines if rescaling must be applied if required
  81709. * @returns true if operation was successful
  81710. */
  81711. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81712. /**
  81713. * Forces the skeleton to go to rest pose
  81714. */
  81715. returnToRest(): void;
  81716. private _getHighestAnimationFrame;
  81717. /**
  81718. * Begin a specific animation range
  81719. * @param name defines the name of the range to start
  81720. * @param loop defines if looping must be turned on (false by default)
  81721. * @param speedRatio defines the speed ratio to apply (1 by default)
  81722. * @param onAnimationEnd defines a callback which will be called when animation will end
  81723. * @returns a new animatable
  81724. */
  81725. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81726. /** @hidden */
  81727. _markAsDirty(): void;
  81728. /** @hidden */
  81729. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81730. /** @hidden */
  81731. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81732. private _computeTransformMatrices;
  81733. /**
  81734. * Build all resources required to render a skeleton
  81735. */
  81736. prepare(): void;
  81737. /**
  81738. * Gets the list of animatables currently running for this skeleton
  81739. * @returns an array of animatables
  81740. */
  81741. getAnimatables(): IAnimatable[];
  81742. /**
  81743. * Clone the current skeleton
  81744. * @param name defines the name of the new skeleton
  81745. * @param id defines the id of the new skeleton
  81746. * @returns the new skeleton
  81747. */
  81748. clone(name: string, id: string): Skeleton;
  81749. /**
  81750. * Enable animation blending for this skeleton
  81751. * @param blendingSpeed defines the blending speed to apply
  81752. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81753. */
  81754. enableBlending(blendingSpeed?: number): void;
  81755. /**
  81756. * Releases all resources associated with the current skeleton
  81757. */
  81758. dispose(): void;
  81759. /**
  81760. * Serialize the skeleton in a JSON object
  81761. * @returns a JSON object
  81762. */
  81763. serialize(): any;
  81764. /**
  81765. * Creates a new skeleton from serialized data
  81766. * @param parsedSkeleton defines the serialized data
  81767. * @param scene defines the hosting scene
  81768. * @returns a new skeleton
  81769. */
  81770. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81771. /**
  81772. * Compute all node absolute transforms
  81773. * @param forceUpdate defines if computation must be done even if cache is up to date
  81774. */
  81775. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81776. /**
  81777. * Gets the root pose matrix
  81778. * @returns a matrix
  81779. */
  81780. getPoseMatrix(): Nullable<Matrix>;
  81781. /**
  81782. * Sorts bones per internal index
  81783. */
  81784. sortBones(): void;
  81785. private _sortBones;
  81786. }
  81787. }
  81788. declare module BABYLON {
  81789. /**
  81790. * Defines a target to use with MorphTargetManager
  81791. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81792. */
  81793. export class MorphTarget implements IAnimatable {
  81794. /** defines the name of the target */
  81795. name: string;
  81796. /**
  81797. * Gets or sets the list of animations
  81798. */
  81799. animations: Animation[];
  81800. private _scene;
  81801. private _positions;
  81802. private _normals;
  81803. private _tangents;
  81804. private _influence;
  81805. /**
  81806. * Observable raised when the influence changes
  81807. */
  81808. onInfluenceChanged: Observable<boolean>;
  81809. /** @hidden */
  81810. _onDataLayoutChanged: Observable<void>;
  81811. /**
  81812. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  81813. */
  81814. influence: number;
  81815. /**
  81816. * Gets or sets the id of the morph Target
  81817. */
  81818. id: string;
  81819. private _animationPropertiesOverride;
  81820. /**
  81821. * Gets or sets the animation properties override
  81822. */
  81823. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81824. /**
  81825. * Creates a new MorphTarget
  81826. * @param name defines the name of the target
  81827. * @param influence defines the influence to use
  81828. * @param scene defines the scene the morphtarget belongs to
  81829. */
  81830. constructor(
  81831. /** defines the name of the target */
  81832. name: string, influence?: number, scene?: Nullable<Scene>);
  81833. /**
  81834. * Gets a boolean defining if the target contains position data
  81835. */
  81836. readonly hasPositions: boolean;
  81837. /**
  81838. * Gets a boolean defining if the target contains normal data
  81839. */
  81840. readonly hasNormals: boolean;
  81841. /**
  81842. * Gets a boolean defining if the target contains tangent data
  81843. */
  81844. readonly hasTangents: boolean;
  81845. /**
  81846. * Affects position data to this target
  81847. * @param data defines the position data to use
  81848. */
  81849. setPositions(data: Nullable<FloatArray>): void;
  81850. /**
  81851. * Gets the position data stored in this target
  81852. * @returns a FloatArray containing the position data (or null if not present)
  81853. */
  81854. getPositions(): Nullable<FloatArray>;
  81855. /**
  81856. * Affects normal data to this target
  81857. * @param data defines the normal data to use
  81858. */
  81859. setNormals(data: Nullable<FloatArray>): void;
  81860. /**
  81861. * Gets the normal data stored in this target
  81862. * @returns a FloatArray containing the normal data (or null if not present)
  81863. */
  81864. getNormals(): Nullable<FloatArray>;
  81865. /**
  81866. * Affects tangent data to this target
  81867. * @param data defines the tangent data to use
  81868. */
  81869. setTangents(data: Nullable<FloatArray>): void;
  81870. /**
  81871. * Gets the tangent data stored in this target
  81872. * @returns a FloatArray containing the tangent data (or null if not present)
  81873. */
  81874. getTangents(): Nullable<FloatArray>;
  81875. /**
  81876. * Serializes the current target into a Serialization object
  81877. * @returns the serialized object
  81878. */
  81879. serialize(): any;
  81880. /**
  81881. * Returns the string "MorphTarget"
  81882. * @returns "MorphTarget"
  81883. */
  81884. getClassName(): string;
  81885. /**
  81886. * Creates a new target from serialized data
  81887. * @param serializationObject defines the serialized data to use
  81888. * @returns a new MorphTarget
  81889. */
  81890. static Parse(serializationObject: any): MorphTarget;
  81891. /**
  81892. * Creates a MorphTarget from mesh data
  81893. * @param mesh defines the source mesh
  81894. * @param name defines the name to use for the new target
  81895. * @param influence defines the influence to attach to the target
  81896. * @returns a new MorphTarget
  81897. */
  81898. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  81899. }
  81900. }
  81901. declare module BABYLON {
  81902. /**
  81903. * This class is used to deform meshes using morphing between different targets
  81904. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81905. */
  81906. export class MorphTargetManager {
  81907. private _targets;
  81908. private _targetInfluenceChangedObservers;
  81909. private _targetDataLayoutChangedObservers;
  81910. private _activeTargets;
  81911. private _scene;
  81912. private _influences;
  81913. private _supportsNormals;
  81914. private _supportsTangents;
  81915. private _vertexCount;
  81916. private _uniqueId;
  81917. private _tempInfluences;
  81918. /**
  81919. * Creates a new MorphTargetManager
  81920. * @param scene defines the current scene
  81921. */
  81922. constructor(scene?: Nullable<Scene>);
  81923. /**
  81924. * Gets the unique ID of this manager
  81925. */
  81926. readonly uniqueId: number;
  81927. /**
  81928. * Gets the number of vertices handled by this manager
  81929. */
  81930. readonly vertexCount: number;
  81931. /**
  81932. * Gets a boolean indicating if this manager supports morphing of normals
  81933. */
  81934. readonly supportsNormals: boolean;
  81935. /**
  81936. * Gets a boolean indicating if this manager supports morphing of tangents
  81937. */
  81938. readonly supportsTangents: boolean;
  81939. /**
  81940. * Gets the number of targets stored in this manager
  81941. */
  81942. readonly numTargets: number;
  81943. /**
  81944. * Gets the number of influencers (ie. the number of targets with influences > 0)
  81945. */
  81946. readonly numInfluencers: number;
  81947. /**
  81948. * Gets the list of influences (one per target)
  81949. */
  81950. readonly influences: Float32Array;
  81951. /**
  81952. * Gets the active target at specified index. An active target is a target with an influence > 0
  81953. * @param index defines the index to check
  81954. * @returns the requested target
  81955. */
  81956. getActiveTarget(index: number): MorphTarget;
  81957. /**
  81958. * Gets the target at specified index
  81959. * @param index defines the index to check
  81960. * @returns the requested target
  81961. */
  81962. getTarget(index: number): MorphTarget;
  81963. /**
  81964. * Add a new target to this manager
  81965. * @param target defines the target to add
  81966. */
  81967. addTarget(target: MorphTarget): void;
  81968. /**
  81969. * Removes a target from the manager
  81970. * @param target defines the target to remove
  81971. */
  81972. removeTarget(target: MorphTarget): void;
  81973. /**
  81974. * Serializes the current manager into a Serialization object
  81975. * @returns the serialized object
  81976. */
  81977. serialize(): any;
  81978. private _syncActiveTargets;
  81979. /**
  81980. * Syncrhonize the targets with all the meshes using this morph target manager
  81981. */
  81982. synchronize(): void;
  81983. /**
  81984. * Creates a new MorphTargetManager from serialized data
  81985. * @param serializationObject defines the serialized data
  81986. * @param scene defines the hosting scene
  81987. * @returns the new MorphTargetManager
  81988. */
  81989. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  81990. }
  81991. }
  81992. declare module BABYLON {
  81993. /**
  81994. * Class used to represent a specific level of detail of a mesh
  81995. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  81996. */
  81997. export class MeshLODLevel {
  81998. /** Defines the distance where this level should star being displayed */
  81999. distance: number;
  82000. /** Defines the mesh to use to render this level */
  82001. mesh: Nullable<Mesh>;
  82002. /**
  82003. * Creates a new LOD level
  82004. * @param distance defines the distance where this level should star being displayed
  82005. * @param mesh defines the mesh to use to render this level
  82006. */
  82007. constructor(
  82008. /** Defines the distance where this level should star being displayed */
  82009. distance: number,
  82010. /** Defines the mesh to use to render this level */
  82011. mesh: Nullable<Mesh>);
  82012. }
  82013. }
  82014. declare module BABYLON {
  82015. /**
  82016. * Mesh representing the gorund
  82017. */
  82018. export class GroundMesh extends Mesh {
  82019. /** If octree should be generated */
  82020. generateOctree: boolean;
  82021. private _heightQuads;
  82022. /** @hidden */
  82023. _subdivisionsX: number;
  82024. /** @hidden */
  82025. _subdivisionsY: number;
  82026. /** @hidden */
  82027. _width: number;
  82028. /** @hidden */
  82029. _height: number;
  82030. /** @hidden */
  82031. _minX: number;
  82032. /** @hidden */
  82033. _maxX: number;
  82034. /** @hidden */
  82035. _minZ: number;
  82036. /** @hidden */
  82037. _maxZ: number;
  82038. constructor(name: string, scene: Scene);
  82039. /**
  82040. * "GroundMesh"
  82041. * @returns "GroundMesh"
  82042. */
  82043. getClassName(): string;
  82044. /**
  82045. * The minimum of x and y subdivisions
  82046. */
  82047. readonly subdivisions: number;
  82048. /**
  82049. * X subdivisions
  82050. */
  82051. readonly subdivisionsX: number;
  82052. /**
  82053. * Y subdivisions
  82054. */
  82055. readonly subdivisionsY: number;
  82056. /**
  82057. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  82058. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  82059. * @param chunksCount the number of subdivisions for x and y
  82060. * @param octreeBlocksSize (Default: 32)
  82061. */
  82062. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  82063. /**
  82064. * Returns a height (y) value in the Worl system :
  82065. * the ground altitude at the coordinates (x, z) expressed in the World system.
  82066. * @param x x coordinate
  82067. * @param z z coordinate
  82068. * @returns the ground y position if (x, z) are outside the ground surface.
  82069. */
  82070. getHeightAtCoordinates(x: number, z: number): number;
  82071. /**
  82072. * Returns a normalized vector (Vector3) orthogonal to the ground
  82073. * at the ground coordinates (x, z) expressed in the World system.
  82074. * @param x x coordinate
  82075. * @param z z coordinate
  82076. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  82077. */
  82078. getNormalAtCoordinates(x: number, z: number): Vector3;
  82079. /**
  82080. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  82081. * at the ground coordinates (x, z) expressed in the World system.
  82082. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  82083. * @param x x coordinate
  82084. * @param z z coordinate
  82085. * @param ref vector to store the result
  82086. * @returns the GroundMesh.
  82087. */
  82088. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  82089. /**
  82090. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  82091. * if the ground has been updated.
  82092. * This can be used in the render loop.
  82093. * @returns the GroundMesh.
  82094. */
  82095. updateCoordinateHeights(): GroundMesh;
  82096. private _getFacetAt;
  82097. private _initHeightQuads;
  82098. private _computeHeightQuads;
  82099. /**
  82100. * Serializes this ground mesh
  82101. * @param serializationObject object to write serialization to
  82102. */
  82103. serialize(serializationObject: any): void;
  82104. /**
  82105. * Parses a serialized ground mesh
  82106. * @param parsedMesh the serialized mesh
  82107. * @param scene the scene to create the ground mesh in
  82108. * @returns the created ground mesh
  82109. */
  82110. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  82111. }
  82112. }
  82113. declare module BABYLON {
  82114. /**
  82115. * Interface for Physics-Joint data
  82116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82117. */
  82118. export interface PhysicsJointData {
  82119. /**
  82120. * The main pivot of the joint
  82121. */
  82122. mainPivot?: Vector3;
  82123. /**
  82124. * The connected pivot of the joint
  82125. */
  82126. connectedPivot?: Vector3;
  82127. /**
  82128. * The main axis of the joint
  82129. */
  82130. mainAxis?: Vector3;
  82131. /**
  82132. * The connected axis of the joint
  82133. */
  82134. connectedAxis?: Vector3;
  82135. /**
  82136. * The collision of the joint
  82137. */
  82138. collision?: boolean;
  82139. /**
  82140. * Native Oimo/Cannon/Energy data
  82141. */
  82142. nativeParams?: any;
  82143. }
  82144. /**
  82145. * This is a holder class for the physics joint created by the physics plugin
  82146. * It holds a set of functions to control the underlying joint
  82147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82148. */
  82149. export class PhysicsJoint {
  82150. /**
  82151. * The type of the physics joint
  82152. */
  82153. type: number;
  82154. /**
  82155. * The data for the physics joint
  82156. */
  82157. jointData: PhysicsJointData;
  82158. private _physicsJoint;
  82159. protected _physicsPlugin: IPhysicsEnginePlugin;
  82160. /**
  82161. * Initializes the physics joint
  82162. * @param type The type of the physics joint
  82163. * @param jointData The data for the physics joint
  82164. */
  82165. constructor(
  82166. /**
  82167. * The type of the physics joint
  82168. */
  82169. type: number,
  82170. /**
  82171. * The data for the physics joint
  82172. */
  82173. jointData: PhysicsJointData);
  82174. /**
  82175. * Gets the physics joint
  82176. */
  82177. /**
  82178. * Sets the physics joint
  82179. */
  82180. physicsJoint: any;
  82181. /**
  82182. * Sets the physics plugin
  82183. */
  82184. physicsPlugin: IPhysicsEnginePlugin;
  82185. /**
  82186. * Execute a function that is physics-plugin specific.
  82187. * @param {Function} func the function that will be executed.
  82188. * It accepts two parameters: the physics world and the physics joint
  82189. */
  82190. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  82191. /**
  82192. * Distance-Joint type
  82193. */
  82194. static DistanceJoint: number;
  82195. /**
  82196. * Hinge-Joint type
  82197. */
  82198. static HingeJoint: number;
  82199. /**
  82200. * Ball-and-Socket joint type
  82201. */
  82202. static BallAndSocketJoint: number;
  82203. /**
  82204. * Wheel-Joint type
  82205. */
  82206. static WheelJoint: number;
  82207. /**
  82208. * Slider-Joint type
  82209. */
  82210. static SliderJoint: number;
  82211. /**
  82212. * Prismatic-Joint type
  82213. */
  82214. static PrismaticJoint: number;
  82215. /**
  82216. * Universal-Joint type
  82217. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  82218. */
  82219. static UniversalJoint: number;
  82220. /**
  82221. * Hinge-Joint 2 type
  82222. */
  82223. static Hinge2Joint: number;
  82224. /**
  82225. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  82226. */
  82227. static PointToPointJoint: number;
  82228. /**
  82229. * Spring-Joint type
  82230. */
  82231. static SpringJoint: number;
  82232. /**
  82233. * Lock-Joint type
  82234. */
  82235. static LockJoint: number;
  82236. }
  82237. /**
  82238. * A class representing a physics distance joint
  82239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82240. */
  82241. export class DistanceJoint extends PhysicsJoint {
  82242. /**
  82243. *
  82244. * @param jointData The data for the Distance-Joint
  82245. */
  82246. constructor(jointData: DistanceJointData);
  82247. /**
  82248. * Update the predefined distance.
  82249. * @param maxDistance The maximum preferred distance
  82250. * @param minDistance The minimum preferred distance
  82251. */
  82252. updateDistance(maxDistance: number, minDistance?: number): void;
  82253. }
  82254. /**
  82255. * Represents a Motor-Enabled Joint
  82256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82257. */
  82258. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  82259. /**
  82260. * Initializes the Motor-Enabled Joint
  82261. * @param type The type of the joint
  82262. * @param jointData The physica joint data for the joint
  82263. */
  82264. constructor(type: number, jointData: PhysicsJointData);
  82265. /**
  82266. * Set the motor values.
  82267. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82268. * @param force the force to apply
  82269. * @param maxForce max force for this motor.
  82270. */
  82271. setMotor(force?: number, maxForce?: number): void;
  82272. /**
  82273. * Set the motor's limits.
  82274. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82275. * @param upperLimit The upper limit of the motor
  82276. * @param lowerLimit The lower limit of the motor
  82277. */
  82278. setLimit(upperLimit: number, lowerLimit?: number): void;
  82279. }
  82280. /**
  82281. * This class represents a single physics Hinge-Joint
  82282. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82283. */
  82284. export class HingeJoint extends MotorEnabledJoint {
  82285. /**
  82286. * Initializes the Hinge-Joint
  82287. * @param jointData The joint data for the Hinge-Joint
  82288. */
  82289. constructor(jointData: PhysicsJointData);
  82290. /**
  82291. * Set the motor values.
  82292. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82293. * @param {number} force the force to apply
  82294. * @param {number} maxForce max force for this motor.
  82295. */
  82296. setMotor(force?: number, maxForce?: number): void;
  82297. /**
  82298. * Set the motor's limits.
  82299. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82300. * @param upperLimit The upper limit of the motor
  82301. * @param lowerLimit The lower limit of the motor
  82302. */
  82303. setLimit(upperLimit: number, lowerLimit?: number): void;
  82304. }
  82305. /**
  82306. * This class represents a dual hinge physics joint (same as wheel joint)
  82307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82308. */
  82309. export class Hinge2Joint extends MotorEnabledJoint {
  82310. /**
  82311. * Initializes the Hinge2-Joint
  82312. * @param jointData The joint data for the Hinge2-Joint
  82313. */
  82314. constructor(jointData: PhysicsJointData);
  82315. /**
  82316. * Set the motor values.
  82317. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82318. * @param {number} targetSpeed the speed the motor is to reach
  82319. * @param {number} maxForce max force for this motor.
  82320. * @param {motorIndex} the motor's index, 0 or 1.
  82321. */
  82322. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  82323. /**
  82324. * Set the motor limits.
  82325. * Attention, this function is plugin specific. Engines won't react 100% the same.
  82326. * @param {number} upperLimit the upper limit
  82327. * @param {number} lowerLimit lower limit
  82328. * @param {motorIndex} the motor's index, 0 or 1.
  82329. */
  82330. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82331. }
  82332. /**
  82333. * Interface for a motor enabled joint
  82334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82335. */
  82336. export interface IMotorEnabledJoint {
  82337. /**
  82338. * Physics joint
  82339. */
  82340. physicsJoint: any;
  82341. /**
  82342. * Sets the motor of the motor-enabled joint
  82343. * @param force The force of the motor
  82344. * @param maxForce The maximum force of the motor
  82345. * @param motorIndex The index of the motor
  82346. */
  82347. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  82348. /**
  82349. * Sets the limit of the motor
  82350. * @param upperLimit The upper limit of the motor
  82351. * @param lowerLimit The lower limit of the motor
  82352. * @param motorIndex The index of the motor
  82353. */
  82354. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82355. }
  82356. /**
  82357. * Joint data for a Distance-Joint
  82358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82359. */
  82360. export interface DistanceJointData extends PhysicsJointData {
  82361. /**
  82362. * Max distance the 2 joint objects can be apart
  82363. */
  82364. maxDistance: number;
  82365. }
  82366. /**
  82367. * Joint data from a spring joint
  82368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82369. */
  82370. export interface SpringJointData extends PhysicsJointData {
  82371. /**
  82372. * Length of the spring
  82373. */
  82374. length: number;
  82375. /**
  82376. * Stiffness of the spring
  82377. */
  82378. stiffness: number;
  82379. /**
  82380. * Damping of the spring
  82381. */
  82382. damping: number;
  82383. /** this callback will be called when applying the force to the impostors. */
  82384. forceApplicationCallback: () => void;
  82385. }
  82386. }
  82387. declare module BABYLON {
  82388. /**
  82389. * Holds the data for the raycast result
  82390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82391. */
  82392. export class PhysicsRaycastResult {
  82393. private _hasHit;
  82394. private _hitDistance;
  82395. private _hitNormalWorld;
  82396. private _hitPointWorld;
  82397. private _rayFromWorld;
  82398. private _rayToWorld;
  82399. /**
  82400. * Gets if there was a hit
  82401. */
  82402. readonly hasHit: boolean;
  82403. /**
  82404. * Gets the distance from the hit
  82405. */
  82406. readonly hitDistance: number;
  82407. /**
  82408. * Gets the hit normal/direction in the world
  82409. */
  82410. readonly hitNormalWorld: Vector3;
  82411. /**
  82412. * Gets the hit point in the world
  82413. */
  82414. readonly hitPointWorld: Vector3;
  82415. /**
  82416. * Gets the ray "start point" of the ray in the world
  82417. */
  82418. readonly rayFromWorld: Vector3;
  82419. /**
  82420. * Gets the ray "end point" of the ray in the world
  82421. */
  82422. readonly rayToWorld: Vector3;
  82423. /**
  82424. * Sets the hit data (normal & point in world space)
  82425. * @param hitNormalWorld defines the normal in world space
  82426. * @param hitPointWorld defines the point in world space
  82427. */
  82428. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  82429. /**
  82430. * Sets the distance from the start point to the hit point
  82431. * @param distance
  82432. */
  82433. setHitDistance(distance: number): void;
  82434. /**
  82435. * Calculates the distance manually
  82436. */
  82437. calculateHitDistance(): void;
  82438. /**
  82439. * Resets all the values to default
  82440. * @param from The from point on world space
  82441. * @param to The to point on world space
  82442. */
  82443. reset(from?: Vector3, to?: Vector3): void;
  82444. }
  82445. /**
  82446. * Interface for the size containing width and height
  82447. */
  82448. interface IXYZ {
  82449. /**
  82450. * X
  82451. */
  82452. x: number;
  82453. /**
  82454. * Y
  82455. */
  82456. y: number;
  82457. /**
  82458. * Z
  82459. */
  82460. z: number;
  82461. }
  82462. }
  82463. declare module BABYLON {
  82464. /**
  82465. * Interface used to describe a physics joint
  82466. */
  82467. export interface PhysicsImpostorJoint {
  82468. /** Defines the main impostor to which the joint is linked */
  82469. mainImpostor: PhysicsImpostor;
  82470. /** Defines the impostor that is connected to the main impostor using this joint */
  82471. connectedImpostor: PhysicsImpostor;
  82472. /** Defines the joint itself */
  82473. joint: PhysicsJoint;
  82474. }
  82475. /** @hidden */
  82476. export interface IPhysicsEnginePlugin {
  82477. world: any;
  82478. name: string;
  82479. setGravity(gravity: Vector3): void;
  82480. setTimeStep(timeStep: number): void;
  82481. getTimeStep(): number;
  82482. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  82483. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82484. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82485. generatePhysicsBody(impostor: PhysicsImpostor): void;
  82486. removePhysicsBody(impostor: PhysicsImpostor): void;
  82487. generateJoint(joint: PhysicsImpostorJoint): void;
  82488. removeJoint(joint: PhysicsImpostorJoint): void;
  82489. isSupported(): boolean;
  82490. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  82491. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  82492. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82493. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82494. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82495. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82496. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  82497. getBodyMass(impostor: PhysicsImpostor): number;
  82498. getBodyFriction(impostor: PhysicsImpostor): number;
  82499. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  82500. getBodyRestitution(impostor: PhysicsImpostor): number;
  82501. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  82502. getBodyPressure?(impostor: PhysicsImpostor): number;
  82503. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  82504. getBodyStiffness?(impostor: PhysicsImpostor): number;
  82505. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  82506. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  82507. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  82508. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  82509. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  82510. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82511. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82512. sleepBody(impostor: PhysicsImpostor): void;
  82513. wakeUpBody(impostor: PhysicsImpostor): void;
  82514. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82515. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  82516. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  82517. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82518. getRadius(impostor: PhysicsImpostor): number;
  82519. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  82520. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  82521. dispose(): void;
  82522. }
  82523. /**
  82524. * Interface used to define a physics engine
  82525. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  82526. */
  82527. export interface IPhysicsEngine {
  82528. /**
  82529. * Gets the gravity vector used by the simulation
  82530. */
  82531. gravity: Vector3;
  82532. /**
  82533. * Sets the gravity vector used by the simulation
  82534. * @param gravity defines the gravity vector to use
  82535. */
  82536. setGravity(gravity: Vector3): void;
  82537. /**
  82538. * Set the time step of the physics engine.
  82539. * Default is 1/60.
  82540. * To slow it down, enter 1/600 for example.
  82541. * To speed it up, 1/30
  82542. * @param newTimeStep the new timestep to apply to this world.
  82543. */
  82544. setTimeStep(newTimeStep: number): void;
  82545. /**
  82546. * Get the time step of the physics engine.
  82547. * @returns the current time step
  82548. */
  82549. getTimeStep(): number;
  82550. /**
  82551. * Release all resources
  82552. */
  82553. dispose(): void;
  82554. /**
  82555. * Gets the name of the current physics plugin
  82556. * @returns the name of the plugin
  82557. */
  82558. getPhysicsPluginName(): string;
  82559. /**
  82560. * Adding a new impostor for the impostor tracking.
  82561. * This will be done by the impostor itself.
  82562. * @param impostor the impostor to add
  82563. */
  82564. addImpostor(impostor: PhysicsImpostor): void;
  82565. /**
  82566. * Remove an impostor from the engine.
  82567. * This impostor and its mesh will not longer be updated by the physics engine.
  82568. * @param impostor the impostor to remove
  82569. */
  82570. removeImpostor(impostor: PhysicsImpostor): void;
  82571. /**
  82572. * Add a joint to the physics engine
  82573. * @param mainImpostor defines the main impostor to which the joint is added.
  82574. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  82575. * @param joint defines the joint that will connect both impostors.
  82576. */
  82577. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82578. /**
  82579. * Removes a joint from the simulation
  82580. * @param mainImpostor defines the impostor used with the joint
  82581. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  82582. * @param joint defines the joint to remove
  82583. */
  82584. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82585. /**
  82586. * Gets the current plugin used to run the simulation
  82587. * @returns current plugin
  82588. */
  82589. getPhysicsPlugin(): IPhysicsEnginePlugin;
  82590. /**
  82591. * Gets the list of physic impostors
  82592. * @returns an array of PhysicsImpostor
  82593. */
  82594. getImpostors(): Array<PhysicsImpostor>;
  82595. /**
  82596. * Gets the impostor for a physics enabled object
  82597. * @param object defines the object impersonated by the impostor
  82598. * @returns the PhysicsImpostor or null if not found
  82599. */
  82600. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82601. /**
  82602. * Gets the impostor for a physics body object
  82603. * @param body defines physics body used by the impostor
  82604. * @returns the PhysicsImpostor or null if not found
  82605. */
  82606. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  82607. /**
  82608. * Does a raycast in the physics world
  82609. * @param from when should the ray start?
  82610. * @param to when should the ray end?
  82611. * @returns PhysicsRaycastResult
  82612. */
  82613. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82614. /**
  82615. * Called by the scene. No need to call it.
  82616. * @param delta defines the timespam between frames
  82617. */
  82618. _step(delta: number): void;
  82619. }
  82620. }
  82621. declare module BABYLON {
  82622. /**
  82623. * The interface for the physics imposter parameters
  82624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82625. */
  82626. export interface PhysicsImpostorParameters {
  82627. /**
  82628. * The mass of the physics imposter
  82629. */
  82630. mass: number;
  82631. /**
  82632. * The friction of the physics imposter
  82633. */
  82634. friction?: number;
  82635. /**
  82636. * The coefficient of restitution of the physics imposter
  82637. */
  82638. restitution?: number;
  82639. /**
  82640. * The native options of the physics imposter
  82641. */
  82642. nativeOptions?: any;
  82643. /**
  82644. * Specifies if the parent should be ignored
  82645. */
  82646. ignoreParent?: boolean;
  82647. /**
  82648. * Specifies if bi-directional transformations should be disabled
  82649. */
  82650. disableBidirectionalTransformation?: boolean;
  82651. /**
  82652. * The pressure inside the physics imposter, soft object only
  82653. */
  82654. pressure?: number;
  82655. /**
  82656. * The stiffness the physics imposter, soft object only
  82657. */
  82658. stiffness?: number;
  82659. /**
  82660. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  82661. */
  82662. velocityIterations?: number;
  82663. /**
  82664. * The number of iterations used in maintaining consistent vertex positions, soft object only
  82665. */
  82666. positionIterations?: number;
  82667. /**
  82668. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  82669. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  82670. * Add to fix multiple points
  82671. */
  82672. fixedPoints?: number;
  82673. /**
  82674. * The collision margin around a soft object
  82675. */
  82676. margin?: number;
  82677. /**
  82678. * The collision margin around a soft object
  82679. */
  82680. damping?: number;
  82681. /**
  82682. * The path for a rope based on an extrusion
  82683. */
  82684. path?: any;
  82685. /**
  82686. * The shape of an extrusion used for a rope based on an extrusion
  82687. */
  82688. shape?: any;
  82689. }
  82690. /**
  82691. * Interface for a physics-enabled object
  82692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82693. */
  82694. export interface IPhysicsEnabledObject {
  82695. /**
  82696. * The position of the physics-enabled object
  82697. */
  82698. position: Vector3;
  82699. /**
  82700. * The rotation of the physics-enabled object
  82701. */
  82702. rotationQuaternion: Nullable<Quaternion>;
  82703. /**
  82704. * The scale of the physics-enabled object
  82705. */
  82706. scaling: Vector3;
  82707. /**
  82708. * The rotation of the physics-enabled object
  82709. */
  82710. rotation?: Vector3;
  82711. /**
  82712. * The parent of the physics-enabled object
  82713. */
  82714. parent?: any;
  82715. /**
  82716. * The bounding info of the physics-enabled object
  82717. * @returns The bounding info of the physics-enabled object
  82718. */
  82719. getBoundingInfo(): BoundingInfo;
  82720. /**
  82721. * Computes the world matrix
  82722. * @param force Specifies if the world matrix should be computed by force
  82723. * @returns A world matrix
  82724. */
  82725. computeWorldMatrix(force: boolean): Matrix;
  82726. /**
  82727. * Gets the world matrix
  82728. * @returns A world matrix
  82729. */
  82730. getWorldMatrix?(): Matrix;
  82731. /**
  82732. * Gets the child meshes
  82733. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  82734. * @returns An array of abstract meshes
  82735. */
  82736. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  82737. /**
  82738. * Gets the vertex data
  82739. * @param kind The type of vertex data
  82740. * @returns A nullable array of numbers, or a float32 array
  82741. */
  82742. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  82743. /**
  82744. * Gets the indices from the mesh
  82745. * @returns A nullable array of index arrays
  82746. */
  82747. getIndices?(): Nullable<IndicesArray>;
  82748. /**
  82749. * Gets the scene from the mesh
  82750. * @returns the indices array or null
  82751. */
  82752. getScene?(): Scene;
  82753. /**
  82754. * Gets the absolute position from the mesh
  82755. * @returns the absolute position
  82756. */
  82757. getAbsolutePosition(): Vector3;
  82758. /**
  82759. * Gets the absolute pivot point from the mesh
  82760. * @returns the absolute pivot point
  82761. */
  82762. getAbsolutePivotPoint(): Vector3;
  82763. /**
  82764. * Rotates the mesh
  82765. * @param axis The axis of rotation
  82766. * @param amount The amount of rotation
  82767. * @param space The space of the rotation
  82768. * @returns The rotation transform node
  82769. */
  82770. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82771. /**
  82772. * Translates the mesh
  82773. * @param axis The axis of translation
  82774. * @param distance The distance of translation
  82775. * @param space The space of the translation
  82776. * @returns The transform node
  82777. */
  82778. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82779. /**
  82780. * Sets the absolute position of the mesh
  82781. * @param absolutePosition The absolute position of the mesh
  82782. * @returns The transform node
  82783. */
  82784. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82785. /**
  82786. * Gets the class name of the mesh
  82787. * @returns The class name
  82788. */
  82789. getClassName(): string;
  82790. }
  82791. /**
  82792. * Represents a physics imposter
  82793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82794. */
  82795. export class PhysicsImpostor {
  82796. /**
  82797. * The physics-enabled object used as the physics imposter
  82798. */
  82799. object: IPhysicsEnabledObject;
  82800. /**
  82801. * The type of the physics imposter
  82802. */
  82803. type: number;
  82804. private _options;
  82805. private _scene?;
  82806. /**
  82807. * The default object size of the imposter
  82808. */
  82809. static DEFAULT_OBJECT_SIZE: Vector3;
  82810. /**
  82811. * The identity quaternion of the imposter
  82812. */
  82813. static IDENTITY_QUATERNION: Quaternion;
  82814. /** @hidden */
  82815. _pluginData: any;
  82816. private _physicsEngine;
  82817. private _physicsBody;
  82818. private _bodyUpdateRequired;
  82819. private _onBeforePhysicsStepCallbacks;
  82820. private _onAfterPhysicsStepCallbacks;
  82821. /** @hidden */
  82822. _onPhysicsCollideCallbacks: Array<{
  82823. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  82824. otherImpostors: Array<PhysicsImpostor>;
  82825. }>;
  82826. private _deltaPosition;
  82827. private _deltaRotation;
  82828. private _deltaRotationConjugated;
  82829. /** @hidden */
  82830. _isFromLine: boolean;
  82831. private _parent;
  82832. private _isDisposed;
  82833. private static _tmpVecs;
  82834. private static _tmpQuat;
  82835. /**
  82836. * Specifies if the physics imposter is disposed
  82837. */
  82838. readonly isDisposed: boolean;
  82839. /**
  82840. * Gets the mass of the physics imposter
  82841. */
  82842. mass: number;
  82843. /**
  82844. * Gets the coefficient of friction
  82845. */
  82846. /**
  82847. * Sets the coefficient of friction
  82848. */
  82849. friction: number;
  82850. /**
  82851. * Gets the coefficient of restitution
  82852. */
  82853. /**
  82854. * Sets the coefficient of restitution
  82855. */
  82856. restitution: number;
  82857. /**
  82858. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  82859. */
  82860. /**
  82861. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  82862. */
  82863. pressure: number;
  82864. /**
  82865. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82866. */
  82867. /**
  82868. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82869. */
  82870. stiffness: number;
  82871. /**
  82872. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82873. */
  82874. /**
  82875. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82876. */
  82877. velocityIterations: number;
  82878. /**
  82879. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82880. */
  82881. /**
  82882. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82883. */
  82884. positionIterations: number;
  82885. /**
  82886. * The unique id of the physics imposter
  82887. * set by the physics engine when adding this impostor to the array
  82888. */
  82889. uniqueId: number;
  82890. /**
  82891. * @hidden
  82892. */
  82893. soft: boolean;
  82894. /**
  82895. * @hidden
  82896. */
  82897. segments: number;
  82898. private _joints;
  82899. /**
  82900. * Initializes the physics imposter
  82901. * @param object The physics-enabled object used as the physics imposter
  82902. * @param type The type of the physics imposter
  82903. * @param _options The options for the physics imposter
  82904. * @param _scene The Babylon scene
  82905. */
  82906. constructor(
  82907. /**
  82908. * The physics-enabled object used as the physics imposter
  82909. */
  82910. object: IPhysicsEnabledObject,
  82911. /**
  82912. * The type of the physics imposter
  82913. */
  82914. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  82915. /**
  82916. * This function will completly initialize this impostor.
  82917. * It will create a new body - but only if this mesh has no parent.
  82918. * If it has, this impostor will not be used other than to define the impostor
  82919. * of the child mesh.
  82920. * @hidden
  82921. */
  82922. _init(): void;
  82923. private _getPhysicsParent;
  82924. /**
  82925. * Should a new body be generated.
  82926. * @returns boolean specifying if body initialization is required
  82927. */
  82928. isBodyInitRequired(): boolean;
  82929. /**
  82930. * Sets the updated scaling
  82931. * @param updated Specifies if the scaling is updated
  82932. */
  82933. setScalingUpdated(): void;
  82934. /**
  82935. * Force a regeneration of this or the parent's impostor's body.
  82936. * Use under cautious - This will remove all joints already implemented.
  82937. */
  82938. forceUpdate(): void;
  82939. /**
  82940. * Gets the body that holds this impostor. Either its own, or its parent.
  82941. */
  82942. /**
  82943. * Set the physics body. Used mainly by the physics engine/plugin
  82944. */
  82945. physicsBody: any;
  82946. /**
  82947. * Get the parent of the physics imposter
  82948. * @returns Physics imposter or null
  82949. */
  82950. /**
  82951. * Sets the parent of the physics imposter
  82952. */
  82953. parent: Nullable<PhysicsImpostor>;
  82954. /**
  82955. * Resets the update flags
  82956. */
  82957. resetUpdateFlags(): void;
  82958. /**
  82959. * Gets the object extend size
  82960. * @returns the object extend size
  82961. */
  82962. getObjectExtendSize(): Vector3;
  82963. /**
  82964. * Gets the object center
  82965. * @returns The object center
  82966. */
  82967. getObjectCenter(): Vector3;
  82968. /**
  82969. * Get a specific parametes from the options parameter
  82970. * @param paramName The object parameter name
  82971. * @returns The object parameter
  82972. */
  82973. getParam(paramName: string): any;
  82974. /**
  82975. * Sets a specific parameter in the options given to the physics plugin
  82976. * @param paramName The parameter name
  82977. * @param value The value of the parameter
  82978. */
  82979. setParam(paramName: string, value: number): void;
  82980. /**
  82981. * Specifically change the body's mass option. Won't recreate the physics body object
  82982. * @param mass The mass of the physics imposter
  82983. */
  82984. setMass(mass: number): void;
  82985. /**
  82986. * Gets the linear velocity
  82987. * @returns linear velocity or null
  82988. */
  82989. getLinearVelocity(): Nullable<Vector3>;
  82990. /**
  82991. * Sets the linear velocity
  82992. * @param velocity linear velocity or null
  82993. */
  82994. setLinearVelocity(velocity: Nullable<Vector3>): void;
  82995. /**
  82996. * Gets the angular velocity
  82997. * @returns angular velocity or null
  82998. */
  82999. getAngularVelocity(): Nullable<Vector3>;
  83000. /**
  83001. * Sets the angular velocity
  83002. * @param velocity The velocity or null
  83003. */
  83004. setAngularVelocity(velocity: Nullable<Vector3>): void;
  83005. /**
  83006. * Execute a function with the physics plugin native code
  83007. * Provide a function the will have two variables - the world object and the physics body object
  83008. * @param func The function to execute with the physics plugin native code
  83009. */
  83010. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  83011. /**
  83012. * Register a function that will be executed before the physics world is stepping forward
  83013. * @param func The function to execute before the physics world is stepped forward
  83014. */
  83015. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  83016. /**
  83017. * Unregister a function that will be executed before the physics world is stepping forward
  83018. * @param func The function to execute before the physics world is stepped forward
  83019. */
  83020. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  83021. /**
  83022. * Register a function that will be executed after the physics step
  83023. * @param func The function to execute after physics step
  83024. */
  83025. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  83026. /**
  83027. * Unregisters a function that will be executed after the physics step
  83028. * @param func The function to execute after physics step
  83029. */
  83030. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  83031. /**
  83032. * register a function that will be executed when this impostor collides against a different body
  83033. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  83034. * @param func Callback that is executed on collision
  83035. */
  83036. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  83037. /**
  83038. * Unregisters the physics imposter on contact
  83039. * @param collideAgainst The physics object to collide against
  83040. * @param func Callback to execute on collision
  83041. */
  83042. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  83043. private _tmpQuat;
  83044. private _tmpQuat2;
  83045. /**
  83046. * Get the parent rotation
  83047. * @returns The parent rotation
  83048. */
  83049. getParentsRotation(): Quaternion;
  83050. /**
  83051. * this function is executed by the physics engine.
  83052. */
  83053. beforeStep: () => void;
  83054. /**
  83055. * this function is executed by the physics engine
  83056. */
  83057. afterStep: () => void;
  83058. /**
  83059. * Legacy collision detection event support
  83060. */
  83061. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  83062. /**
  83063. * event and body object due to cannon's event-based architecture.
  83064. */
  83065. onCollide: (e: {
  83066. body: any;
  83067. }) => void;
  83068. /**
  83069. * Apply a force
  83070. * @param force The force to apply
  83071. * @param contactPoint The contact point for the force
  83072. * @returns The physics imposter
  83073. */
  83074. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  83075. /**
  83076. * Apply an impulse
  83077. * @param force The impulse force
  83078. * @param contactPoint The contact point for the impulse force
  83079. * @returns The physics imposter
  83080. */
  83081. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  83082. /**
  83083. * A help function to create a joint
  83084. * @param otherImpostor A physics imposter used to create a joint
  83085. * @param jointType The type of joint
  83086. * @param jointData The data for the joint
  83087. * @returns The physics imposter
  83088. */
  83089. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  83090. /**
  83091. * Add a joint to this impostor with a different impostor
  83092. * @param otherImpostor A physics imposter used to add a joint
  83093. * @param joint The joint to add
  83094. * @returns The physics imposter
  83095. */
  83096. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  83097. /**
  83098. * Add an anchor to a cloth impostor
  83099. * @param otherImpostor rigid impostor to anchor to
  83100. * @param width ratio across width from 0 to 1
  83101. * @param height ratio up height from 0 to 1
  83102. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  83103. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  83104. * @returns impostor the soft imposter
  83105. */
  83106. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  83107. /**
  83108. * Add a hook to a rope impostor
  83109. * @param otherImpostor rigid impostor to anchor to
  83110. * @param length ratio across rope from 0 to 1
  83111. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  83112. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  83113. * @returns impostor the rope imposter
  83114. */
  83115. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  83116. /**
  83117. * Will keep this body still, in a sleep mode.
  83118. * @returns the physics imposter
  83119. */
  83120. sleep(): PhysicsImpostor;
  83121. /**
  83122. * Wake the body up.
  83123. * @returns The physics imposter
  83124. */
  83125. wakeUp(): PhysicsImpostor;
  83126. /**
  83127. * Clones the physics imposter
  83128. * @param newObject The physics imposter clones to this physics-enabled object
  83129. * @returns A nullable physics imposter
  83130. */
  83131. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  83132. /**
  83133. * Disposes the physics imposter
  83134. */
  83135. dispose(): void;
  83136. /**
  83137. * Sets the delta position
  83138. * @param position The delta position amount
  83139. */
  83140. setDeltaPosition(position: Vector3): void;
  83141. /**
  83142. * Sets the delta rotation
  83143. * @param rotation The delta rotation amount
  83144. */
  83145. setDeltaRotation(rotation: Quaternion): void;
  83146. /**
  83147. * Gets the box size of the physics imposter and stores the result in the input parameter
  83148. * @param result Stores the box size
  83149. * @returns The physics imposter
  83150. */
  83151. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  83152. /**
  83153. * Gets the radius of the physics imposter
  83154. * @returns Radius of the physics imposter
  83155. */
  83156. getRadius(): number;
  83157. /**
  83158. * Sync a bone with this impostor
  83159. * @param bone The bone to sync to the impostor.
  83160. * @param boneMesh The mesh that the bone is influencing.
  83161. * @param jointPivot The pivot of the joint / bone in local space.
  83162. * @param distToJoint Optional distance from the impostor to the joint.
  83163. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  83164. */
  83165. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  83166. /**
  83167. * Sync impostor to a bone
  83168. * @param bone The bone that the impostor will be synced to.
  83169. * @param boneMesh The mesh that the bone is influencing.
  83170. * @param jointPivot The pivot of the joint / bone in local space.
  83171. * @param distToJoint Optional distance from the impostor to the joint.
  83172. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  83173. * @param boneAxis Optional vector3 axis the bone is aligned with
  83174. */
  83175. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  83176. /**
  83177. * No-Imposter type
  83178. */
  83179. static NoImpostor: number;
  83180. /**
  83181. * Sphere-Imposter type
  83182. */
  83183. static SphereImpostor: number;
  83184. /**
  83185. * Box-Imposter type
  83186. */
  83187. static BoxImpostor: number;
  83188. /**
  83189. * Plane-Imposter type
  83190. */
  83191. static PlaneImpostor: number;
  83192. /**
  83193. * Mesh-imposter type
  83194. */
  83195. static MeshImpostor: number;
  83196. /**
  83197. * Cylinder-Imposter type
  83198. */
  83199. static CylinderImpostor: number;
  83200. /**
  83201. * Particle-Imposter type
  83202. */
  83203. static ParticleImpostor: number;
  83204. /**
  83205. * Heightmap-Imposter type
  83206. */
  83207. static HeightmapImpostor: number;
  83208. /**
  83209. * ConvexHull-Impostor type (Ammo.js plugin only)
  83210. */
  83211. static ConvexHullImpostor: number;
  83212. /**
  83213. * Rope-Imposter type
  83214. */
  83215. static RopeImpostor: number;
  83216. /**
  83217. * Cloth-Imposter type
  83218. */
  83219. static ClothImpostor: number;
  83220. /**
  83221. * Softbody-Imposter type
  83222. */
  83223. static SoftbodyImpostor: number;
  83224. }
  83225. }
  83226. declare module BABYLON {
  83227. /**
  83228. * @hidden
  83229. **/
  83230. export class _CreationDataStorage {
  83231. closePath?: boolean;
  83232. closeArray?: boolean;
  83233. idx: number[];
  83234. dashSize: number;
  83235. gapSize: number;
  83236. path3D: Path3D;
  83237. pathArray: Vector3[][];
  83238. arc: number;
  83239. radius: number;
  83240. cap: number;
  83241. tessellation: number;
  83242. }
  83243. /**
  83244. * @hidden
  83245. **/
  83246. class _InstanceDataStorage {
  83247. visibleInstances: any;
  83248. batchCache: _InstancesBatch;
  83249. instancesBufferSize: number;
  83250. instancesBuffer: Nullable<Buffer>;
  83251. instancesData: Float32Array;
  83252. overridenInstanceCount: number;
  83253. isFrozen: boolean;
  83254. previousBatch: _InstancesBatch;
  83255. hardwareInstancedRendering: boolean;
  83256. sideOrientation: number;
  83257. }
  83258. /**
  83259. * @hidden
  83260. **/
  83261. export class _InstancesBatch {
  83262. mustReturn: boolean;
  83263. visibleInstances: Nullable<InstancedMesh[]>[];
  83264. renderSelf: boolean[];
  83265. hardwareInstancedRendering: boolean[];
  83266. }
  83267. /**
  83268. * Class used to represent renderable models
  83269. */
  83270. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  83271. /**
  83272. * Mesh side orientation : usually the external or front surface
  83273. */
  83274. static readonly FRONTSIDE: number;
  83275. /**
  83276. * Mesh side orientation : usually the internal or back surface
  83277. */
  83278. static readonly BACKSIDE: number;
  83279. /**
  83280. * Mesh side orientation : both internal and external or front and back surfaces
  83281. */
  83282. static readonly DOUBLESIDE: number;
  83283. /**
  83284. * Mesh side orientation : by default, `FRONTSIDE`
  83285. */
  83286. static readonly DEFAULTSIDE: number;
  83287. /**
  83288. * Mesh cap setting : no cap
  83289. */
  83290. static readonly NO_CAP: number;
  83291. /**
  83292. * Mesh cap setting : one cap at the beginning of the mesh
  83293. */
  83294. static readonly CAP_START: number;
  83295. /**
  83296. * Mesh cap setting : one cap at the end of the mesh
  83297. */
  83298. static readonly CAP_END: number;
  83299. /**
  83300. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  83301. */
  83302. static readonly CAP_ALL: number;
  83303. /**
  83304. * Mesh pattern setting : no flip or rotate
  83305. */
  83306. static readonly NO_FLIP: number;
  83307. /**
  83308. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  83309. */
  83310. static readonly FLIP_TILE: number;
  83311. /**
  83312. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  83313. */
  83314. static readonly ROTATE_TILE: number;
  83315. /**
  83316. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  83317. */
  83318. static readonly FLIP_ROW: number;
  83319. /**
  83320. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  83321. */
  83322. static readonly ROTATE_ROW: number;
  83323. /**
  83324. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  83325. */
  83326. static readonly FLIP_N_ROTATE_TILE: number;
  83327. /**
  83328. * Mesh pattern setting : rotate pattern and rotate
  83329. */
  83330. static readonly FLIP_N_ROTATE_ROW: number;
  83331. /**
  83332. * Mesh tile positioning : part tiles same on left/right or top/bottom
  83333. */
  83334. static readonly CENTER: number;
  83335. /**
  83336. * Mesh tile positioning : part tiles on left
  83337. */
  83338. static readonly LEFT: number;
  83339. /**
  83340. * Mesh tile positioning : part tiles on right
  83341. */
  83342. static readonly RIGHT: number;
  83343. /**
  83344. * Mesh tile positioning : part tiles on top
  83345. */
  83346. static readonly TOP: number;
  83347. /**
  83348. * Mesh tile positioning : part tiles on bottom
  83349. */
  83350. static readonly BOTTOM: number;
  83351. /**
  83352. * Gets the default side orientation.
  83353. * @param orientation the orientation to value to attempt to get
  83354. * @returns the default orientation
  83355. * @hidden
  83356. */
  83357. static _GetDefaultSideOrientation(orientation?: number): number;
  83358. private _internalMeshDataInfo;
  83359. /**
  83360. * An event triggered before rendering the mesh
  83361. */
  83362. readonly onBeforeRenderObservable: Observable<Mesh>;
  83363. /**
  83364. * An event triggered before binding the mesh
  83365. */
  83366. readonly onBeforeBindObservable: Observable<Mesh>;
  83367. /**
  83368. * An event triggered after rendering the mesh
  83369. */
  83370. readonly onAfterRenderObservable: Observable<Mesh>;
  83371. /**
  83372. * An event triggered before drawing the mesh
  83373. */
  83374. readonly onBeforeDrawObservable: Observable<Mesh>;
  83375. private _onBeforeDrawObserver;
  83376. /**
  83377. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  83378. */
  83379. onBeforeDraw: () => void;
  83380. /**
  83381. * Gets the delay loading state of the mesh (when delay loading is turned on)
  83382. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  83383. */
  83384. delayLoadState: number;
  83385. /**
  83386. * Gets the list of instances created from this mesh
  83387. * it is not supposed to be modified manually.
  83388. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  83389. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83390. */
  83391. instances: InstancedMesh[];
  83392. /**
  83393. * Gets the file containing delay loading data for this mesh
  83394. */
  83395. delayLoadingFile: string;
  83396. /** @hidden */
  83397. _binaryInfo: any;
  83398. /**
  83399. * User defined function used to change how LOD level selection is done
  83400. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  83401. */
  83402. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  83403. /**
  83404. * Gets or sets the morph target manager
  83405. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  83406. */
  83407. morphTargetManager: Nullable<MorphTargetManager>;
  83408. /** @hidden */
  83409. _creationDataStorage: Nullable<_CreationDataStorage>;
  83410. /** @hidden */
  83411. _geometry: Nullable<Geometry>;
  83412. /** @hidden */
  83413. _delayInfo: Array<string>;
  83414. /** @hidden */
  83415. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  83416. /** @hidden */
  83417. _instanceDataStorage: _InstanceDataStorage;
  83418. private _effectiveMaterial;
  83419. /** @hidden */
  83420. _shouldGenerateFlatShading: boolean;
  83421. /** @hidden */
  83422. _originalBuilderSideOrientation: number;
  83423. /**
  83424. * Use this property to change the original side orientation defined at construction time
  83425. */
  83426. overrideMaterialSideOrientation: Nullable<number>;
  83427. /**
  83428. * Gets the source mesh (the one used to clone this one from)
  83429. */
  83430. readonly source: Nullable<Mesh>;
  83431. /**
  83432. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83433. */
  83434. isUnIndexed: boolean;
  83435. /**
  83436. * @constructor
  83437. * @param name The value used by scene.getMeshByName() to do a lookup.
  83438. * @param scene The scene to add this mesh to.
  83439. * @param parent The parent of this mesh, if it has one
  83440. * @param source An optional Mesh from which geometry is shared, cloned.
  83441. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83442. * When false, achieved by calling a clone(), also passing False.
  83443. * This will make creation of children, recursive.
  83444. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83445. */
  83446. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  83447. /**
  83448. * Gets the class name
  83449. * @returns the string "Mesh".
  83450. */
  83451. getClassName(): string;
  83452. /** @hidden */
  83453. readonly _isMesh: boolean;
  83454. /**
  83455. * Returns a description of this mesh
  83456. * @param fullDetails define if full details about this mesh must be used
  83457. * @returns a descriptive string representing this mesh
  83458. */
  83459. toString(fullDetails?: boolean): string;
  83460. /** @hidden */
  83461. _unBindEffect(): void;
  83462. /**
  83463. * Gets a boolean indicating if this mesh has LOD
  83464. */
  83465. readonly hasLODLevels: boolean;
  83466. /**
  83467. * Gets the list of MeshLODLevel associated with the current mesh
  83468. * @returns an array of MeshLODLevel
  83469. */
  83470. getLODLevels(): MeshLODLevel[];
  83471. private _sortLODLevels;
  83472. /**
  83473. * Add a mesh as LOD level triggered at the given distance.
  83474. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83475. * @param distance The distance from the center of the object to show this level
  83476. * @param mesh The mesh to be added as LOD level (can be null)
  83477. * @return This mesh (for chaining)
  83478. */
  83479. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  83480. /**
  83481. * Returns the LOD level mesh at the passed distance or null if not found.
  83482. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83483. * @param distance The distance from the center of the object to show this level
  83484. * @returns a Mesh or `null`
  83485. */
  83486. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  83487. /**
  83488. * Remove a mesh from the LOD array
  83489. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83490. * @param mesh defines the mesh to be removed
  83491. * @return This mesh (for chaining)
  83492. */
  83493. removeLODLevel(mesh: Mesh): Mesh;
  83494. /**
  83495. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  83496. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83497. * @param camera defines the camera to use to compute distance
  83498. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  83499. * @return This mesh (for chaining)
  83500. */
  83501. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  83502. /**
  83503. * Gets the mesh internal Geometry object
  83504. */
  83505. readonly geometry: Nullable<Geometry>;
  83506. /**
  83507. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  83508. * @returns the total number of vertices
  83509. */
  83510. getTotalVertices(): number;
  83511. /**
  83512. * Returns the content of an associated vertex buffer
  83513. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83514. * - VertexBuffer.PositionKind
  83515. * - VertexBuffer.UVKind
  83516. * - VertexBuffer.UV2Kind
  83517. * - VertexBuffer.UV3Kind
  83518. * - VertexBuffer.UV4Kind
  83519. * - VertexBuffer.UV5Kind
  83520. * - VertexBuffer.UV6Kind
  83521. * - VertexBuffer.ColorKind
  83522. * - VertexBuffer.MatricesIndicesKind
  83523. * - VertexBuffer.MatricesIndicesExtraKind
  83524. * - VertexBuffer.MatricesWeightsKind
  83525. * - VertexBuffer.MatricesWeightsExtraKind
  83526. * @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
  83527. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  83528. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  83529. */
  83530. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83531. /**
  83532. * Returns the mesh VertexBuffer object from the requested `kind`
  83533. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83534. * - VertexBuffer.PositionKind
  83535. * - VertexBuffer.NormalKind
  83536. * - VertexBuffer.UVKind
  83537. * - VertexBuffer.UV2Kind
  83538. * - VertexBuffer.UV3Kind
  83539. * - VertexBuffer.UV4Kind
  83540. * - VertexBuffer.UV5Kind
  83541. * - VertexBuffer.UV6Kind
  83542. * - VertexBuffer.ColorKind
  83543. * - VertexBuffer.MatricesIndicesKind
  83544. * - VertexBuffer.MatricesIndicesExtraKind
  83545. * - VertexBuffer.MatricesWeightsKind
  83546. * - VertexBuffer.MatricesWeightsExtraKind
  83547. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  83548. */
  83549. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  83550. /**
  83551. * Tests if a specific vertex buffer is associated with this mesh
  83552. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83553. * - VertexBuffer.PositionKind
  83554. * - VertexBuffer.NormalKind
  83555. * - VertexBuffer.UVKind
  83556. * - VertexBuffer.UV2Kind
  83557. * - VertexBuffer.UV3Kind
  83558. * - VertexBuffer.UV4Kind
  83559. * - VertexBuffer.UV5Kind
  83560. * - VertexBuffer.UV6Kind
  83561. * - VertexBuffer.ColorKind
  83562. * - VertexBuffer.MatricesIndicesKind
  83563. * - VertexBuffer.MatricesIndicesExtraKind
  83564. * - VertexBuffer.MatricesWeightsKind
  83565. * - VertexBuffer.MatricesWeightsExtraKind
  83566. * @returns a boolean
  83567. */
  83568. isVerticesDataPresent(kind: string): boolean;
  83569. /**
  83570. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  83571. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83572. * - VertexBuffer.PositionKind
  83573. * - VertexBuffer.UVKind
  83574. * - VertexBuffer.UV2Kind
  83575. * - VertexBuffer.UV3Kind
  83576. * - VertexBuffer.UV4Kind
  83577. * - VertexBuffer.UV5Kind
  83578. * - VertexBuffer.UV6Kind
  83579. * - VertexBuffer.ColorKind
  83580. * - VertexBuffer.MatricesIndicesKind
  83581. * - VertexBuffer.MatricesIndicesExtraKind
  83582. * - VertexBuffer.MatricesWeightsKind
  83583. * - VertexBuffer.MatricesWeightsExtraKind
  83584. * @returns a boolean
  83585. */
  83586. isVertexBufferUpdatable(kind: string): boolean;
  83587. /**
  83588. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  83589. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83590. * - VertexBuffer.PositionKind
  83591. * - VertexBuffer.NormalKind
  83592. * - VertexBuffer.UVKind
  83593. * - VertexBuffer.UV2Kind
  83594. * - VertexBuffer.UV3Kind
  83595. * - VertexBuffer.UV4Kind
  83596. * - VertexBuffer.UV5Kind
  83597. * - VertexBuffer.UV6Kind
  83598. * - VertexBuffer.ColorKind
  83599. * - VertexBuffer.MatricesIndicesKind
  83600. * - VertexBuffer.MatricesIndicesExtraKind
  83601. * - VertexBuffer.MatricesWeightsKind
  83602. * - VertexBuffer.MatricesWeightsExtraKind
  83603. * @returns an array of strings
  83604. */
  83605. getVerticesDataKinds(): string[];
  83606. /**
  83607. * Returns a positive integer : the total number of indices in this mesh geometry.
  83608. * @returns the numner of indices or zero if the mesh has no geometry.
  83609. */
  83610. getTotalIndices(): number;
  83611. /**
  83612. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83613. * @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.
  83614. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83615. * @returns the indices array or an empty array if the mesh has no geometry
  83616. */
  83617. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83618. readonly isBlocked: boolean;
  83619. /**
  83620. * Determine if the current mesh is ready to be rendered
  83621. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83622. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  83623. * @returns true if all associated assets are ready (material, textures, shaders)
  83624. */
  83625. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  83626. /**
  83627. * 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.
  83628. */
  83629. readonly areNormalsFrozen: boolean;
  83630. /**
  83631. * 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.
  83632. * @returns the current mesh
  83633. */
  83634. freezeNormals(): Mesh;
  83635. /**
  83636. * 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
  83637. * @returns the current mesh
  83638. */
  83639. unfreezeNormals(): Mesh;
  83640. /**
  83641. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  83642. */
  83643. overridenInstanceCount: number;
  83644. /** @hidden */
  83645. _preActivate(): Mesh;
  83646. /** @hidden */
  83647. _preActivateForIntermediateRendering(renderId: number): Mesh;
  83648. /** @hidden */
  83649. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  83650. /**
  83651. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83652. * This means the mesh underlying bounding box and sphere are recomputed.
  83653. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83654. * @returns the current mesh
  83655. */
  83656. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  83657. /** @hidden */
  83658. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  83659. /**
  83660. * This function will subdivide the mesh into multiple submeshes
  83661. * @param count defines the expected number of submeshes
  83662. */
  83663. subdivide(count: number): void;
  83664. /**
  83665. * Copy a FloatArray into a specific associated vertex buffer
  83666. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83667. * - VertexBuffer.PositionKind
  83668. * - VertexBuffer.UVKind
  83669. * - VertexBuffer.UV2Kind
  83670. * - VertexBuffer.UV3Kind
  83671. * - VertexBuffer.UV4Kind
  83672. * - VertexBuffer.UV5Kind
  83673. * - VertexBuffer.UV6Kind
  83674. * - VertexBuffer.ColorKind
  83675. * - VertexBuffer.MatricesIndicesKind
  83676. * - VertexBuffer.MatricesIndicesExtraKind
  83677. * - VertexBuffer.MatricesWeightsKind
  83678. * - VertexBuffer.MatricesWeightsExtraKind
  83679. * @param data defines the data source
  83680. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83681. * @param stride defines the data stride size (can be null)
  83682. * @returns the current mesh
  83683. */
  83684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83685. /**
  83686. * Flags an associated vertex buffer as updatable
  83687. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  83688. * - VertexBuffer.PositionKind
  83689. * - VertexBuffer.UVKind
  83690. * - VertexBuffer.UV2Kind
  83691. * - VertexBuffer.UV3Kind
  83692. * - VertexBuffer.UV4Kind
  83693. * - VertexBuffer.UV5Kind
  83694. * - VertexBuffer.UV6Kind
  83695. * - VertexBuffer.ColorKind
  83696. * - VertexBuffer.MatricesIndicesKind
  83697. * - VertexBuffer.MatricesIndicesExtraKind
  83698. * - VertexBuffer.MatricesWeightsKind
  83699. * - VertexBuffer.MatricesWeightsExtraKind
  83700. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83701. */
  83702. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  83703. /**
  83704. * Sets the mesh global Vertex Buffer
  83705. * @param buffer defines the buffer to use
  83706. * @returns the current mesh
  83707. */
  83708. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  83709. /**
  83710. * Update a specific associated vertex buffer
  83711. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83712. * - VertexBuffer.PositionKind
  83713. * - VertexBuffer.UVKind
  83714. * - VertexBuffer.UV2Kind
  83715. * - VertexBuffer.UV3Kind
  83716. * - VertexBuffer.UV4Kind
  83717. * - VertexBuffer.UV5Kind
  83718. * - VertexBuffer.UV6Kind
  83719. * - VertexBuffer.ColorKind
  83720. * - VertexBuffer.MatricesIndicesKind
  83721. * - VertexBuffer.MatricesIndicesExtraKind
  83722. * - VertexBuffer.MatricesWeightsKind
  83723. * - VertexBuffer.MatricesWeightsExtraKind
  83724. * @param data defines the data source
  83725. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83726. * @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)
  83727. * @returns the current mesh
  83728. */
  83729. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83730. /**
  83731. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  83732. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  83733. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  83734. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  83735. * @returns the current mesh
  83736. */
  83737. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  83738. /**
  83739. * Creates a un-shared specific occurence of the geometry for the mesh.
  83740. * @returns the current mesh
  83741. */
  83742. makeGeometryUnique(): Mesh;
  83743. /**
  83744. * Set the index buffer of this mesh
  83745. * @param indices defines the source data
  83746. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  83747. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  83748. * @returns the current mesh
  83749. */
  83750. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  83751. /**
  83752. * Update the current index buffer
  83753. * @param indices defines the source data
  83754. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83755. * @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)
  83756. * @returns the current mesh
  83757. */
  83758. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  83759. /**
  83760. * Invert the geometry to move from a right handed system to a left handed one.
  83761. * @returns the current mesh
  83762. */
  83763. toLeftHanded(): Mesh;
  83764. /** @hidden */
  83765. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  83766. /** @hidden */
  83767. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  83768. /**
  83769. * Registers for this mesh a javascript function called just before the rendering process
  83770. * @param func defines the function to call before rendering this mesh
  83771. * @returns the current mesh
  83772. */
  83773. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83774. /**
  83775. * Disposes a previously registered javascript function called before the rendering
  83776. * @param func defines the function to remove
  83777. * @returns the current mesh
  83778. */
  83779. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83780. /**
  83781. * Registers for this mesh a javascript function called just after the rendering is complete
  83782. * @param func defines the function to call after rendering this mesh
  83783. * @returns the current mesh
  83784. */
  83785. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83786. /**
  83787. * Disposes a previously registered javascript function called after the rendering.
  83788. * @param func defines the function to remove
  83789. * @returns the current mesh
  83790. */
  83791. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83792. /** @hidden */
  83793. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  83794. /** @hidden */
  83795. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  83796. /** @hidden */
  83797. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  83798. /** @hidden */
  83799. _freeze(): void;
  83800. /** @hidden */
  83801. _unFreeze(): void;
  83802. /**
  83803. * 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
  83804. * @param subMesh defines the subMesh to render
  83805. * @param enableAlphaMode defines if alpha mode can be changed
  83806. * @returns the current mesh
  83807. */
  83808. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  83809. private _onBeforeDraw;
  83810. /**
  83811. * Renormalize the mesh and patch it up if there are no weights
  83812. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  83813. * However in the case of zero weights then we set just a single influence to 1.
  83814. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  83815. */
  83816. cleanMatrixWeights(): void;
  83817. private normalizeSkinFourWeights;
  83818. private normalizeSkinWeightsAndExtra;
  83819. /**
  83820. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  83821. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  83822. * the user know there was an issue with importing the mesh
  83823. * @returns a validation object with skinned, valid and report string
  83824. */
  83825. validateSkinning(): {
  83826. skinned: boolean;
  83827. valid: boolean;
  83828. report: string;
  83829. };
  83830. /** @hidden */
  83831. _checkDelayState(): Mesh;
  83832. private _queueLoad;
  83833. /**
  83834. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83835. * A mesh is in the frustum if its bounding box intersects the frustum
  83836. * @param frustumPlanes defines the frustum to test
  83837. * @returns true if the mesh is in the frustum planes
  83838. */
  83839. isInFrustum(frustumPlanes: Plane[]): boolean;
  83840. /**
  83841. * Sets the mesh material by the material or multiMaterial `id` property
  83842. * @param id is a string identifying the material or the multiMaterial
  83843. * @returns the current mesh
  83844. */
  83845. setMaterialByID(id: string): Mesh;
  83846. /**
  83847. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  83848. * @returns an array of IAnimatable
  83849. */
  83850. getAnimatables(): IAnimatable[];
  83851. /**
  83852. * Modifies the mesh geometry according to the passed transformation matrix.
  83853. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  83854. * The mesh normals are modified using the same transformation.
  83855. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83856. * @param transform defines the transform matrix to use
  83857. * @see http://doc.babylonjs.com/resources/baking_transformations
  83858. * @returns the current mesh
  83859. */
  83860. bakeTransformIntoVertices(transform: Matrix): Mesh;
  83861. /**
  83862. * Modifies the mesh geometry according to its own current World Matrix.
  83863. * The mesh World Matrix is then reset.
  83864. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  83865. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83866. * @see http://doc.babylonjs.com/resources/baking_transformations
  83867. * @returns the current mesh
  83868. */
  83869. bakeCurrentTransformIntoVertices(): Mesh;
  83870. /** @hidden */
  83871. readonly _positions: Nullable<Vector3[]>;
  83872. /** @hidden */
  83873. _resetPointsArrayCache(): Mesh;
  83874. /** @hidden */
  83875. _generatePointsArray(): boolean;
  83876. /**
  83877. * Returns a new Mesh object generated from the current mesh properties.
  83878. * This method must not get confused with createInstance()
  83879. * @param name is a string, the name given to the new mesh
  83880. * @param newParent can be any Node object (default `null`)
  83881. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  83882. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  83883. * @returns a new mesh
  83884. */
  83885. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  83886. /**
  83887. * Releases resources associated with this mesh.
  83888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83890. */
  83891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83892. /**
  83893. * Modifies the mesh geometry according to a displacement map.
  83894. * 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.
  83895. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83896. * @param url is a string, the URL from the image file is to be downloaded.
  83897. * @param minHeight is the lower limit of the displacement.
  83898. * @param maxHeight is the upper limit of the displacement.
  83899. * @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.
  83900. * @param uvOffset is an optional vector2 used to offset UV.
  83901. * @param uvScale is an optional vector2 used to scale UV.
  83902. * @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.
  83903. * @returns the Mesh.
  83904. */
  83905. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83906. /**
  83907. * Modifies the mesh geometry according to a displacementMap buffer.
  83908. * 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.
  83909. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83910. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  83911. * @param heightMapWidth is the width of the buffer image.
  83912. * @param heightMapHeight is the height of the buffer image.
  83913. * @param minHeight is the lower limit of the displacement.
  83914. * @param maxHeight is the upper limit of the displacement.
  83915. * @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.
  83916. * @param uvOffset is an optional vector2 used to offset UV.
  83917. * @param uvScale is an optional vector2 used to scale UV.
  83918. * @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.
  83919. * @returns the Mesh.
  83920. */
  83921. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83922. /**
  83923. * Modify the mesh to get a flat shading rendering.
  83924. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  83925. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  83926. * @returns current mesh
  83927. */
  83928. convertToFlatShadedMesh(): Mesh;
  83929. /**
  83930. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  83931. * In other words, more vertices, no more indices and a single bigger VBO.
  83932. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  83933. * @returns current mesh
  83934. */
  83935. convertToUnIndexedMesh(): Mesh;
  83936. /**
  83937. * Inverses facet orientations.
  83938. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83939. * @param flipNormals will also inverts the normals
  83940. * @returns current mesh
  83941. */
  83942. flipFaces(flipNormals?: boolean): Mesh;
  83943. /**
  83944. * Increase the number of facets and hence vertices in a mesh
  83945. * Vertex normals are interpolated from existing vertex normals
  83946. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83947. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  83948. */
  83949. increaseVertices(numberPerEdge: number): void;
  83950. /**
  83951. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  83952. * This will undo any application of covertToFlatShadedMesh
  83953. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83954. */
  83955. forceSharedVertices(): void;
  83956. /** @hidden */
  83957. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  83958. /** @hidden */
  83959. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  83960. /**
  83961. * Creates a new InstancedMesh object from the mesh model.
  83962. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83963. * @param name defines the name of the new instance
  83964. * @returns a new InstancedMesh
  83965. */
  83966. createInstance(name: string): InstancedMesh;
  83967. /**
  83968. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  83969. * After this call, all the mesh instances have the same submeshes than the current mesh.
  83970. * @returns the current mesh
  83971. */
  83972. synchronizeInstances(): Mesh;
  83973. /**
  83974. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  83975. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  83976. * This should be used together with the simplification to avoid disappearing triangles.
  83977. * @param successCallback an optional success callback to be called after the optimization finished.
  83978. * @returns the current mesh
  83979. */
  83980. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  83981. /**
  83982. * Serialize current mesh
  83983. * @param serializationObject defines the object which will receive the serialization data
  83984. */
  83985. serialize(serializationObject: any): void;
  83986. /** @hidden */
  83987. _syncGeometryWithMorphTargetManager(): void;
  83988. /** @hidden */
  83989. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  83990. /**
  83991. * Returns a new Mesh object parsed from the source provided.
  83992. * @param parsedMesh is the source
  83993. * @param scene defines the hosting scene
  83994. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  83995. * @returns a new Mesh
  83996. */
  83997. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  83998. /**
  83999. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  84000. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84001. * @param name defines the name of the mesh to create
  84002. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  84003. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  84004. * @param closePath creates a seam between the first and the last points of each path of the path array
  84005. * @param offset is taken in account only if the `pathArray` is containing a single path
  84006. * @param scene defines the hosting scene
  84007. * @param updatable defines if the mesh must be flagged as updatable
  84008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84009. * @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)
  84010. * @returns a new Mesh
  84011. */
  84012. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84013. /**
  84014. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  84015. * @param name defines the name of the mesh to create
  84016. * @param radius sets the radius size (float) of the polygon (default 0.5)
  84017. * @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
  84018. * @param scene defines the hosting scene
  84019. * @param updatable defines if the mesh must be flagged as updatable
  84020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84021. * @returns a new Mesh
  84022. */
  84023. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  84024. /**
  84025. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  84026. * @param name defines the name of the mesh to create
  84027. * @param size sets the size (float) of each box side (default 1)
  84028. * @param scene defines the hosting scene
  84029. * @param updatable defines if the mesh must be flagged as updatable
  84030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84031. * @returns a new Mesh
  84032. */
  84033. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  84034. /**
  84035. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  84036. * @param name defines the name of the mesh to create
  84037. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  84038. * @param diameter sets the diameter size (float) of the sphere (default 1)
  84039. * @param scene defines the hosting scene
  84040. * @param updatable defines if the mesh must be flagged as updatable
  84041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84042. * @returns a new Mesh
  84043. */
  84044. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84045. /**
  84046. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  84047. * @param name defines the name of the mesh to create
  84048. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  84049. * @param diameter sets the diameter size (float) of the sphere (default 1)
  84050. * @param scene defines the hosting scene
  84051. * @returns a new Mesh
  84052. */
  84053. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  84054. /**
  84055. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  84056. * @param name defines the name of the mesh to create
  84057. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  84058. * @param diameterTop set the top cap diameter (floats, default 1)
  84059. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  84060. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  84061. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  84062. * @param scene defines the hosting scene
  84063. * @param updatable defines if the mesh must be flagged as updatable
  84064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84065. * @returns a new Mesh
  84066. */
  84067. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  84068. /**
  84069. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  84070. * @param name defines the name of the mesh to create
  84071. * @param diameter sets the diameter size (float) of the torus (default 1)
  84072. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  84073. * @param tessellation sets the number of torus sides (postive integer, default 16)
  84074. * @param scene defines the hosting scene
  84075. * @param updatable defines if the mesh must be flagged as updatable
  84076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84077. * @returns a new Mesh
  84078. */
  84079. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84080. /**
  84081. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  84082. * @param name defines the name of the mesh to create
  84083. * @param radius sets the global radius size (float) of the torus knot (default 2)
  84084. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  84085. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  84086. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  84087. * @param p the number of windings on X axis (positive integers, default 2)
  84088. * @param q the number of windings on Y axis (positive integers, default 3)
  84089. * @param scene defines the hosting scene
  84090. * @param updatable defines if the mesh must be flagged as updatable
  84091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84092. * @returns a new Mesh
  84093. */
  84094. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84095. /**
  84096. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  84097. * @param name defines the name of the mesh to create
  84098. * @param points is an array successive Vector3
  84099. * @param scene defines the hosting scene
  84100. * @param updatable defines if the mesh must be flagged as updatable
  84101. * @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).
  84102. * @returns a new Mesh
  84103. */
  84104. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  84105. /**
  84106. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  84107. * @param name defines the name of the mesh to create
  84108. * @param points is an array successive Vector3
  84109. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  84110. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  84111. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  84112. * @param scene defines the hosting scene
  84113. * @param updatable defines if the mesh must be flagged as updatable
  84114. * @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)
  84115. * @returns a new Mesh
  84116. */
  84117. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  84118. /**
  84119. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  84120. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  84121. * 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.
  84122. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84123. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  84124. * Remember you can only change the shape positions, not their number when updating a polygon.
  84125. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  84126. * @param name defines the name of the mesh to create
  84127. * @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
  84128. * @param scene defines the hosting scene
  84129. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  84130. * @param updatable defines if the mesh must be flagged as updatable
  84131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84132. * @param earcutInjection can be used to inject your own earcut reference
  84133. * @returns a new Mesh
  84134. */
  84135. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  84136. /**
  84137. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  84138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  84139. * @param name defines the name of the mesh to create
  84140. * @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
  84141. * @param depth defines the height of extrusion
  84142. * @param scene defines the hosting scene
  84143. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  84144. * @param updatable defines if the mesh must be flagged as updatable
  84145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84146. * @param earcutInjection can be used to inject your own earcut reference
  84147. * @returns a new Mesh
  84148. */
  84149. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  84150. /**
  84151. * Creates an extruded shape mesh.
  84152. * 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
  84153. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84154. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  84155. * @param name defines the name of the mesh to create
  84156. * @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
  84157. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  84158. * @param scale is the value to scale the shape
  84159. * @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
  84160. * @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
  84161. * @param scene defines the hosting scene
  84162. * @param updatable defines if the mesh must be flagged as updatable
  84163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84164. * @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)
  84165. * @returns a new Mesh
  84166. */
  84167. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84168. /**
  84169. * Creates an custom extruded shape mesh.
  84170. * The custom extrusion is a parametric shape.
  84171. * It has no predefined shape. Its final shape will depend on the input parameters.
  84172. * Please consider using the same method from the MeshBuilder class instead
  84173. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  84174. * @param name defines the name of the mesh to create
  84175. * @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
  84176. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  84177. * @param scaleFunction is a custom Javascript function called on each path point
  84178. * @param rotationFunction is a custom Javascript function called on each path point
  84179. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  84180. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  84181. * @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
  84182. * @param scene defines the hosting scene
  84183. * @param updatable defines if the mesh must be flagged as updatable
  84184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84185. * @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)
  84186. * @returns a new Mesh
  84187. */
  84188. 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;
  84189. /**
  84190. * Creates lathe mesh.
  84191. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  84192. * Please consider using the same method from the MeshBuilder class instead
  84193. * @param name defines the name of the mesh to create
  84194. * @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
  84195. * @param radius is the radius value of the lathe
  84196. * @param tessellation is the side number of the lathe.
  84197. * @param scene defines the hosting scene
  84198. * @param updatable defines if the mesh must be flagged as updatable
  84199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84200. * @returns a new Mesh
  84201. */
  84202. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84203. /**
  84204. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  84205. * @param name defines the name of the mesh to create
  84206. * @param size sets the size (float) of both sides of the plane at once (default 1)
  84207. * @param scene defines the hosting scene
  84208. * @param updatable defines if the mesh must be flagged as updatable
  84209. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84210. * @returns a new Mesh
  84211. */
  84212. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  84213. /**
  84214. * Creates a ground mesh.
  84215. * Please consider using the same method from the MeshBuilder class instead
  84216. * @param name defines the name of the mesh to create
  84217. * @param width set the width of the ground
  84218. * @param height set the height of the ground
  84219. * @param subdivisions sets the number of subdivisions per side
  84220. * @param scene defines the hosting scene
  84221. * @param updatable defines if the mesh must be flagged as updatable
  84222. * @returns a new Mesh
  84223. */
  84224. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  84225. /**
  84226. * Creates a tiled ground mesh.
  84227. * Please consider using the same method from the MeshBuilder class instead
  84228. * @param name defines the name of the mesh to create
  84229. * @param xmin set the ground minimum X coordinate
  84230. * @param zmin set the ground minimum Y coordinate
  84231. * @param xmax set the ground maximum X coordinate
  84232. * @param zmax set the ground maximum Z coordinate
  84233. * @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
  84234. * @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
  84235. * @param scene defines the hosting scene
  84236. * @param updatable defines if the mesh must be flagged as updatable
  84237. * @returns a new Mesh
  84238. */
  84239. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  84240. w: number;
  84241. h: number;
  84242. }, precision: {
  84243. w: number;
  84244. h: number;
  84245. }, scene: Scene, updatable?: boolean): Mesh;
  84246. /**
  84247. * Creates a ground mesh from a height map.
  84248. * Please consider using the same method from the MeshBuilder class instead
  84249. * @see http://doc.babylonjs.com/babylon101/height_map
  84250. * @param name defines the name of the mesh to create
  84251. * @param url sets the URL of the height map image resource
  84252. * @param width set the ground width size
  84253. * @param height set the ground height size
  84254. * @param subdivisions sets the number of subdivision per side
  84255. * @param minHeight is the minimum altitude on the ground
  84256. * @param maxHeight is the maximum altitude on the ground
  84257. * @param scene defines the hosting scene
  84258. * @param updatable defines if the mesh must be flagged as updatable
  84259. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  84260. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  84261. * @returns a new Mesh
  84262. */
  84263. 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;
  84264. /**
  84265. * Creates a tube mesh.
  84266. * The tube is a parametric shape.
  84267. * It has no predefined shape. Its final shape will depend on the input parameters.
  84268. * Please consider using the same method from the MeshBuilder class instead
  84269. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  84270. * @param name defines the name of the mesh to create
  84271. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  84272. * @param radius sets the tube radius size
  84273. * @param tessellation is the number of sides on the tubular surface
  84274. * @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
  84275. * @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
  84276. * @param scene defines the hosting scene
  84277. * @param updatable defines if the mesh must be flagged as updatable
  84278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  84279. * @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)
  84280. * @returns a new Mesh
  84281. */
  84282. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  84283. (i: number, distance: number): number;
  84284. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  84285. /**
  84286. * Creates a polyhedron mesh.
  84287. * Please consider using the same method from the MeshBuilder class instead.
  84288. * * 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
  84289. * * The parameter `size` (positive float, default 1) sets the polygon size
  84290. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  84291. * * 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`
  84292. * * 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
  84293. * * 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)`)
  84294. * * 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
  84295. * * 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
  84296. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84297. * * If you create a double-sided mesh, you can choose what parts of 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
  84298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  84299. * @param name defines the name of the mesh to create
  84300. * @param options defines the options used to create the mesh
  84301. * @param scene defines the hosting scene
  84302. * @returns a new Mesh
  84303. */
  84304. static CreatePolyhedron(name: string, options: {
  84305. type?: number;
  84306. size?: number;
  84307. sizeX?: number;
  84308. sizeY?: number;
  84309. sizeZ?: number;
  84310. custom?: any;
  84311. faceUV?: Vector4[];
  84312. faceColors?: Color4[];
  84313. updatable?: boolean;
  84314. sideOrientation?: number;
  84315. }, scene: Scene): Mesh;
  84316. /**
  84317. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  84318. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  84319. * * 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`)
  84320. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  84321. * * 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
  84322. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  84323. * * If you create a double-sided mesh, you can choose what parts of 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
  84324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  84325. * @param name defines the name of the mesh
  84326. * @param options defines the options used to create the mesh
  84327. * @param scene defines the hosting scene
  84328. * @returns a new Mesh
  84329. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  84330. */
  84331. static CreateIcoSphere(name: string, options: {
  84332. radius?: number;
  84333. flat?: boolean;
  84334. subdivisions?: number;
  84335. sideOrientation?: number;
  84336. updatable?: boolean;
  84337. }, scene: Scene): Mesh;
  84338. /**
  84339. * Creates a decal mesh.
  84340. * Please consider using the same method from the MeshBuilder class instead.
  84341. * A decal is a mesh usually applied as a model onto the surface of another mesh
  84342. * @param name defines the name of the mesh
  84343. * @param sourceMesh defines the mesh receiving the decal
  84344. * @param position sets the position of the decal in world coordinates
  84345. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  84346. * @param size sets the decal scaling
  84347. * @param angle sets the angle to rotate the decal
  84348. * @returns a new Mesh
  84349. */
  84350. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  84351. /**
  84352. * Prepare internal position array for software CPU skinning
  84353. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  84354. */
  84355. setPositionsForCPUSkinning(): Float32Array;
  84356. /**
  84357. * Prepare internal normal array for software CPU skinning
  84358. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  84359. */
  84360. setNormalsForCPUSkinning(): Float32Array;
  84361. /**
  84362. * Updates the vertex buffer by applying transformation from the bones
  84363. * @param skeleton defines the skeleton to apply to current mesh
  84364. * @returns the current mesh
  84365. */
  84366. applySkeleton(skeleton: Skeleton): Mesh;
  84367. /**
  84368. * 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
  84369. * @param meshes defines the list of meshes to scan
  84370. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  84371. */
  84372. static MinMax(meshes: AbstractMesh[]): {
  84373. min: Vector3;
  84374. max: Vector3;
  84375. };
  84376. /**
  84377. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  84378. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  84379. * @returns a vector3
  84380. */
  84381. static Center(meshesOrMinMaxVector: {
  84382. min: Vector3;
  84383. max: Vector3;
  84384. } | AbstractMesh[]): Vector3;
  84385. /**
  84386. * Merge the array of meshes into a single mesh for performance reasons.
  84387. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  84388. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  84389. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  84390. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  84391. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  84392. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  84393. * @returns a new mesh
  84394. */
  84395. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  84396. /** @hidden */
  84397. addInstance(instance: InstancedMesh): void;
  84398. /** @hidden */
  84399. removeInstance(instance: InstancedMesh): void;
  84400. }
  84401. }
  84402. declare module BABYLON {
  84403. /**
  84404. * Base class for the main features of a material in Babylon.js
  84405. */
  84406. export class Material implements IAnimatable {
  84407. /**
  84408. * Returns the triangle fill mode
  84409. */
  84410. static readonly TriangleFillMode: number;
  84411. /**
  84412. * Returns the wireframe mode
  84413. */
  84414. static readonly WireFrameFillMode: number;
  84415. /**
  84416. * Returns the point fill mode
  84417. */
  84418. static readonly PointFillMode: number;
  84419. /**
  84420. * Returns the point list draw mode
  84421. */
  84422. static readonly PointListDrawMode: number;
  84423. /**
  84424. * Returns the line list draw mode
  84425. */
  84426. static readonly LineListDrawMode: number;
  84427. /**
  84428. * Returns the line loop draw mode
  84429. */
  84430. static readonly LineLoopDrawMode: number;
  84431. /**
  84432. * Returns the line strip draw mode
  84433. */
  84434. static readonly LineStripDrawMode: number;
  84435. /**
  84436. * Returns the triangle strip draw mode
  84437. */
  84438. static readonly TriangleStripDrawMode: number;
  84439. /**
  84440. * Returns the triangle fan draw mode
  84441. */
  84442. static readonly TriangleFanDrawMode: number;
  84443. /**
  84444. * Stores the clock-wise side orientation
  84445. */
  84446. static readonly ClockWiseSideOrientation: number;
  84447. /**
  84448. * Stores the counter clock-wise side orientation
  84449. */
  84450. static readonly CounterClockWiseSideOrientation: number;
  84451. /**
  84452. * The dirty texture flag value
  84453. */
  84454. static readonly TextureDirtyFlag: number;
  84455. /**
  84456. * The dirty light flag value
  84457. */
  84458. static readonly LightDirtyFlag: number;
  84459. /**
  84460. * The dirty fresnel flag value
  84461. */
  84462. static readonly FresnelDirtyFlag: number;
  84463. /**
  84464. * The dirty attribute flag value
  84465. */
  84466. static readonly AttributesDirtyFlag: number;
  84467. /**
  84468. * The dirty misc flag value
  84469. */
  84470. static readonly MiscDirtyFlag: number;
  84471. /**
  84472. * The all dirty flag value
  84473. */
  84474. static readonly AllDirtyFlag: number;
  84475. /**
  84476. * The ID of the material
  84477. */
  84478. id: string;
  84479. /**
  84480. * Gets or sets the unique id of the material
  84481. */
  84482. uniqueId: number;
  84483. /**
  84484. * The name of the material
  84485. */
  84486. name: string;
  84487. /**
  84488. * Gets or sets user defined metadata
  84489. */
  84490. metadata: any;
  84491. /**
  84492. * For internal use only. Please do not use.
  84493. */
  84494. reservedDataStore: any;
  84495. /**
  84496. * Specifies if the ready state should be checked on each call
  84497. */
  84498. checkReadyOnEveryCall: boolean;
  84499. /**
  84500. * Specifies if the ready state should be checked once
  84501. */
  84502. checkReadyOnlyOnce: boolean;
  84503. /**
  84504. * The state of the material
  84505. */
  84506. state: string;
  84507. /**
  84508. * The alpha value of the material
  84509. */
  84510. protected _alpha: number;
  84511. /**
  84512. * List of inspectable custom properties (used by the Inspector)
  84513. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84514. */
  84515. inspectableCustomProperties: IInspectable[];
  84516. /**
  84517. * Sets the alpha value of the material
  84518. */
  84519. /**
  84520. * Gets the alpha value of the material
  84521. */
  84522. alpha: number;
  84523. /**
  84524. * Specifies if back face culling is enabled
  84525. */
  84526. protected _backFaceCulling: boolean;
  84527. /**
  84528. * Sets the back-face culling state
  84529. */
  84530. /**
  84531. * Gets the back-face culling state
  84532. */
  84533. backFaceCulling: boolean;
  84534. /**
  84535. * Stores the value for side orientation
  84536. */
  84537. sideOrientation: number;
  84538. /**
  84539. * Callback triggered when the material is compiled
  84540. */
  84541. onCompiled: Nullable<(effect: Effect) => void>;
  84542. /**
  84543. * Callback triggered when an error occurs
  84544. */
  84545. onError: Nullable<(effect: Effect, errors: string) => void>;
  84546. /**
  84547. * Callback triggered to get the render target textures
  84548. */
  84549. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84550. /**
  84551. * Gets a boolean indicating that current material needs to register RTT
  84552. */
  84553. readonly hasRenderTargetTextures: boolean;
  84554. /**
  84555. * Specifies if the material should be serialized
  84556. */
  84557. doNotSerialize: boolean;
  84558. /**
  84559. * @hidden
  84560. */
  84561. _storeEffectOnSubMeshes: boolean;
  84562. /**
  84563. * Stores the animations for the material
  84564. */
  84565. animations: Nullable<Array<Animation>>;
  84566. /**
  84567. * An event triggered when the material is disposed
  84568. */
  84569. onDisposeObservable: Observable<Material>;
  84570. /**
  84571. * An observer which watches for dispose events
  84572. */
  84573. private _onDisposeObserver;
  84574. private _onUnBindObservable;
  84575. /**
  84576. * Called during a dispose event
  84577. */
  84578. onDispose: () => void;
  84579. private _onBindObservable;
  84580. /**
  84581. * An event triggered when the material is bound
  84582. */
  84583. readonly onBindObservable: Observable<AbstractMesh>;
  84584. /**
  84585. * An observer which watches for bind events
  84586. */
  84587. private _onBindObserver;
  84588. /**
  84589. * Called during a bind event
  84590. */
  84591. onBind: (Mesh: AbstractMesh) => void;
  84592. /**
  84593. * An event triggered when the material is unbound
  84594. */
  84595. readonly onUnBindObservable: Observable<Material>;
  84596. /**
  84597. * Stores the value of the alpha mode
  84598. */
  84599. private _alphaMode;
  84600. /**
  84601. * Sets the value of the alpha mode.
  84602. *
  84603. * | Value | Type | Description |
  84604. * | --- | --- | --- |
  84605. * | 0 | ALPHA_DISABLE | |
  84606. * | 1 | ALPHA_ADD | |
  84607. * | 2 | ALPHA_COMBINE | |
  84608. * | 3 | ALPHA_SUBTRACT | |
  84609. * | 4 | ALPHA_MULTIPLY | |
  84610. * | 5 | ALPHA_MAXIMIZED | |
  84611. * | 6 | ALPHA_ONEONE | |
  84612. * | 7 | ALPHA_PREMULTIPLIED | |
  84613. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84614. * | 9 | ALPHA_INTERPOLATE | |
  84615. * | 10 | ALPHA_SCREENMODE | |
  84616. *
  84617. */
  84618. /**
  84619. * Gets the value of the alpha mode
  84620. */
  84621. alphaMode: number;
  84622. /**
  84623. * Stores the state of the need depth pre-pass value
  84624. */
  84625. private _needDepthPrePass;
  84626. /**
  84627. * Sets the need depth pre-pass value
  84628. */
  84629. /**
  84630. * Gets the depth pre-pass value
  84631. */
  84632. needDepthPrePass: boolean;
  84633. /**
  84634. * Specifies if depth writing should be disabled
  84635. */
  84636. disableDepthWrite: boolean;
  84637. /**
  84638. * Specifies if depth writing should be forced
  84639. */
  84640. forceDepthWrite: boolean;
  84641. /**
  84642. * Specifies if there should be a separate pass for culling
  84643. */
  84644. separateCullingPass: boolean;
  84645. /**
  84646. * Stores the state specifing if fog should be enabled
  84647. */
  84648. private _fogEnabled;
  84649. /**
  84650. * Sets the state for enabling fog
  84651. */
  84652. /**
  84653. * Gets the value of the fog enabled state
  84654. */
  84655. fogEnabled: boolean;
  84656. /**
  84657. * Stores the size of points
  84658. */
  84659. pointSize: number;
  84660. /**
  84661. * Stores the z offset value
  84662. */
  84663. zOffset: number;
  84664. /**
  84665. * Gets a value specifying if wireframe mode is enabled
  84666. */
  84667. /**
  84668. * Sets the state of wireframe mode
  84669. */
  84670. wireframe: boolean;
  84671. /**
  84672. * Gets the value specifying if point clouds are enabled
  84673. */
  84674. /**
  84675. * Sets the state of point cloud mode
  84676. */
  84677. pointsCloud: boolean;
  84678. /**
  84679. * Gets the material fill mode
  84680. */
  84681. /**
  84682. * Sets the material fill mode
  84683. */
  84684. fillMode: number;
  84685. /**
  84686. * @hidden
  84687. * Stores the effects for the material
  84688. */
  84689. _effect: Nullable<Effect>;
  84690. /**
  84691. * @hidden
  84692. * Specifies if the material was previously ready
  84693. */
  84694. _wasPreviouslyReady: boolean;
  84695. /**
  84696. * Specifies if uniform buffers should be used
  84697. */
  84698. private _useUBO;
  84699. /**
  84700. * Stores a reference to the scene
  84701. */
  84702. private _scene;
  84703. /**
  84704. * Stores the fill mode state
  84705. */
  84706. private _fillMode;
  84707. /**
  84708. * Specifies if the depth write state should be cached
  84709. */
  84710. private _cachedDepthWriteState;
  84711. /**
  84712. * Stores the uniform buffer
  84713. */
  84714. protected _uniformBuffer: UniformBuffer;
  84715. /** @hidden */
  84716. _indexInSceneMaterialArray: number;
  84717. /** @hidden */
  84718. meshMap: Nullable<{
  84719. [id: string]: AbstractMesh | undefined;
  84720. }>;
  84721. /**
  84722. * Creates a material instance
  84723. * @param name defines the name of the material
  84724. * @param scene defines the scene to reference
  84725. * @param doNotAdd specifies if the material should be added to the scene
  84726. */
  84727. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84728. /**
  84729. * Returns a string representation of the current material
  84730. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84731. * @returns a string with material information
  84732. */
  84733. toString(fullDetails?: boolean): string;
  84734. /**
  84735. * Gets the class name of the material
  84736. * @returns a string with the class name of the material
  84737. */
  84738. getClassName(): string;
  84739. /**
  84740. * Specifies if updates for the material been locked
  84741. */
  84742. readonly isFrozen: boolean;
  84743. /**
  84744. * Locks updates for the material
  84745. */
  84746. freeze(): void;
  84747. /**
  84748. * Unlocks updates for the material
  84749. */
  84750. unfreeze(): void;
  84751. /**
  84752. * Specifies if the material is ready to be used
  84753. * @param mesh defines the mesh to check
  84754. * @param useInstances specifies if instances should be used
  84755. * @returns a boolean indicating if the material is ready to be used
  84756. */
  84757. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84758. /**
  84759. * Specifies that the submesh is ready to be used
  84760. * @param mesh defines the mesh to check
  84761. * @param subMesh defines which submesh to check
  84762. * @param useInstances specifies that instances should be used
  84763. * @returns a boolean indicating that the submesh is ready or not
  84764. */
  84765. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84766. /**
  84767. * Returns the material effect
  84768. * @returns the effect associated with the material
  84769. */
  84770. getEffect(): Nullable<Effect>;
  84771. /**
  84772. * Returns the current scene
  84773. * @returns a Scene
  84774. */
  84775. getScene(): Scene;
  84776. /**
  84777. * Specifies if the material will require alpha blending
  84778. * @returns a boolean specifying if alpha blending is needed
  84779. */
  84780. needAlphaBlending(): boolean;
  84781. /**
  84782. * Specifies if the mesh will require alpha blending
  84783. * @param mesh defines the mesh to check
  84784. * @returns a boolean specifying if alpha blending is needed for the mesh
  84785. */
  84786. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84787. /**
  84788. * Specifies if this material should be rendered in alpha test mode
  84789. * @returns a boolean specifying if an alpha test is needed.
  84790. */
  84791. needAlphaTesting(): boolean;
  84792. /**
  84793. * Gets the texture used for the alpha test
  84794. * @returns the texture to use for alpha testing
  84795. */
  84796. getAlphaTestTexture(): Nullable<BaseTexture>;
  84797. /**
  84798. * Marks the material to indicate that it needs to be re-calculated
  84799. */
  84800. markDirty(): void;
  84801. /** @hidden */
  84802. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84803. /**
  84804. * Binds the material to the mesh
  84805. * @param world defines the world transformation matrix
  84806. * @param mesh defines the mesh to bind the material to
  84807. */
  84808. bind(world: Matrix, mesh?: Mesh): void;
  84809. /**
  84810. * Binds the submesh to the material
  84811. * @param world defines the world transformation matrix
  84812. * @param mesh defines the mesh containing the submesh
  84813. * @param subMesh defines the submesh to bind the material to
  84814. */
  84815. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84816. /**
  84817. * Binds the world matrix to the material
  84818. * @param world defines the world transformation matrix
  84819. */
  84820. bindOnlyWorldMatrix(world: Matrix): void;
  84821. /**
  84822. * Binds the scene's uniform buffer to the effect.
  84823. * @param effect defines the effect to bind to the scene uniform buffer
  84824. * @param sceneUbo defines the uniform buffer storing scene data
  84825. */
  84826. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84827. /**
  84828. * Binds the view matrix to the effect
  84829. * @param effect defines the effect to bind the view matrix to
  84830. */
  84831. bindView(effect: Effect): void;
  84832. /**
  84833. * Binds the view projection matrix to the effect
  84834. * @param effect defines the effect to bind the view projection matrix to
  84835. */
  84836. bindViewProjection(effect: Effect): void;
  84837. /**
  84838. * Specifies if material alpha testing should be turned on for the mesh
  84839. * @param mesh defines the mesh to check
  84840. */
  84841. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84842. /**
  84843. * Processes to execute after binding the material to a mesh
  84844. * @param mesh defines the rendered mesh
  84845. */
  84846. protected _afterBind(mesh?: Mesh): void;
  84847. /**
  84848. * Unbinds the material from the mesh
  84849. */
  84850. unbind(): void;
  84851. /**
  84852. * Gets the active textures from the material
  84853. * @returns an array of textures
  84854. */
  84855. getActiveTextures(): BaseTexture[];
  84856. /**
  84857. * Specifies if the material uses a texture
  84858. * @param texture defines the texture to check against the material
  84859. * @returns a boolean specifying if the material uses the texture
  84860. */
  84861. hasTexture(texture: BaseTexture): boolean;
  84862. /**
  84863. * Makes a duplicate of the material, and gives it a new name
  84864. * @param name defines the new name for the duplicated material
  84865. * @returns the cloned material
  84866. */
  84867. clone(name: string): Nullable<Material>;
  84868. /**
  84869. * Gets the meshes bound to the material
  84870. * @returns an array of meshes bound to the material
  84871. */
  84872. getBindedMeshes(): AbstractMesh[];
  84873. /**
  84874. * Force shader compilation
  84875. * @param mesh defines the mesh associated with this material
  84876. * @param onCompiled defines a function to execute once the material is compiled
  84877. * @param options defines the options to configure the compilation
  84878. */
  84879. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84880. clipPlane: boolean;
  84881. }>): void;
  84882. /**
  84883. * Force shader compilation
  84884. * @param mesh defines the mesh that will use this material
  84885. * @param options defines additional options for compiling the shaders
  84886. * @returns a promise that resolves when the compilation completes
  84887. */
  84888. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84889. clipPlane: boolean;
  84890. }>): Promise<void>;
  84891. private static readonly _AllDirtyCallBack;
  84892. private static readonly _ImageProcessingDirtyCallBack;
  84893. private static readonly _TextureDirtyCallBack;
  84894. private static readonly _FresnelDirtyCallBack;
  84895. private static readonly _MiscDirtyCallBack;
  84896. private static readonly _LightsDirtyCallBack;
  84897. private static readonly _AttributeDirtyCallBack;
  84898. private static _FresnelAndMiscDirtyCallBack;
  84899. private static _TextureAndMiscDirtyCallBack;
  84900. private static readonly _DirtyCallbackArray;
  84901. private static readonly _RunDirtyCallBacks;
  84902. /**
  84903. * Marks a define in the material to indicate that it needs to be re-computed
  84904. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84905. */
  84906. markAsDirty(flag: number): void;
  84907. /**
  84908. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84909. * @param func defines a function which checks material defines against the submeshes
  84910. */
  84911. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84912. /**
  84913. * Indicates that we need to re-calculated for all submeshes
  84914. */
  84915. protected _markAllSubMeshesAsAllDirty(): void;
  84916. /**
  84917. * Indicates that image processing needs to be re-calculated for all submeshes
  84918. */
  84919. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84920. /**
  84921. * Indicates that textures need to be re-calculated for all submeshes
  84922. */
  84923. protected _markAllSubMeshesAsTexturesDirty(): void;
  84924. /**
  84925. * Indicates that fresnel needs to be re-calculated for all submeshes
  84926. */
  84927. protected _markAllSubMeshesAsFresnelDirty(): void;
  84928. /**
  84929. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84930. */
  84931. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84932. /**
  84933. * Indicates that lights need to be re-calculated for all submeshes
  84934. */
  84935. protected _markAllSubMeshesAsLightsDirty(): void;
  84936. /**
  84937. * Indicates that attributes need to be re-calculated for all submeshes
  84938. */
  84939. protected _markAllSubMeshesAsAttributesDirty(): void;
  84940. /**
  84941. * Indicates that misc needs to be re-calculated for all submeshes
  84942. */
  84943. protected _markAllSubMeshesAsMiscDirty(): void;
  84944. /**
  84945. * Indicates that textures and misc need to be re-calculated for all submeshes
  84946. */
  84947. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84948. /**
  84949. * Disposes the material
  84950. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84951. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84952. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84953. */
  84954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84955. /** @hidden */
  84956. private releaseVertexArrayObject;
  84957. /**
  84958. * Serializes this material
  84959. * @returns the serialized material object
  84960. */
  84961. serialize(): any;
  84962. /**
  84963. * Creates a material from parsed material data
  84964. * @param parsedMaterial defines parsed material data
  84965. * @param scene defines the hosting scene
  84966. * @param rootUrl defines the root URL to use to load textures
  84967. * @returns a new material
  84968. */
  84969. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84970. }
  84971. }
  84972. declare module BABYLON {
  84973. /**
  84974. * Base class for submeshes
  84975. */
  84976. export class BaseSubMesh {
  84977. /** @hidden */
  84978. _materialDefines: Nullable<MaterialDefines>;
  84979. /** @hidden */
  84980. _materialEffect: Nullable<Effect>;
  84981. /**
  84982. * Gets associated effect
  84983. */
  84984. readonly effect: Nullable<Effect>;
  84985. /**
  84986. * Sets associated effect (effect used to render this submesh)
  84987. * @param effect defines the effect to associate with
  84988. * @param defines defines the set of defines used to compile this effect
  84989. */
  84990. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84991. }
  84992. /**
  84993. * Defines a subdivision inside a mesh
  84994. */
  84995. export class SubMesh extends BaseSubMesh implements ICullable {
  84996. /** the material index to use */
  84997. materialIndex: number;
  84998. /** vertex index start */
  84999. verticesStart: number;
  85000. /** vertices count */
  85001. verticesCount: number;
  85002. /** index start */
  85003. indexStart: number;
  85004. /** indices count */
  85005. indexCount: number;
  85006. /** @hidden */
  85007. _linesIndexCount: number;
  85008. private _mesh;
  85009. private _renderingMesh;
  85010. private _boundingInfo;
  85011. private _linesIndexBuffer;
  85012. /** @hidden */
  85013. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85014. /** @hidden */
  85015. _trianglePlanes: Plane[];
  85016. /** @hidden */
  85017. _lastColliderTransformMatrix: Nullable<Matrix>;
  85018. /** @hidden */
  85019. _renderId: number;
  85020. /** @hidden */
  85021. _alphaIndex: number;
  85022. /** @hidden */
  85023. _distanceToCamera: number;
  85024. /** @hidden */
  85025. _id: number;
  85026. private _currentMaterial;
  85027. /**
  85028. * Add a new submesh to a mesh
  85029. * @param materialIndex defines the material index to use
  85030. * @param verticesStart defines vertex index start
  85031. * @param verticesCount defines vertices count
  85032. * @param indexStart defines index start
  85033. * @param indexCount defines indices count
  85034. * @param mesh defines the parent mesh
  85035. * @param renderingMesh defines an optional rendering mesh
  85036. * @param createBoundingBox defines if bounding box should be created for this submesh
  85037. * @returns the new submesh
  85038. */
  85039. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85040. /**
  85041. * Creates a new submesh
  85042. * @param materialIndex defines the material index to use
  85043. * @param verticesStart defines vertex index start
  85044. * @param verticesCount defines vertices count
  85045. * @param indexStart defines index start
  85046. * @param indexCount defines indices count
  85047. * @param mesh defines the parent mesh
  85048. * @param renderingMesh defines an optional rendering mesh
  85049. * @param createBoundingBox defines if bounding box should be created for this submesh
  85050. */
  85051. constructor(
  85052. /** the material index to use */
  85053. materialIndex: number,
  85054. /** vertex index start */
  85055. verticesStart: number,
  85056. /** vertices count */
  85057. verticesCount: number,
  85058. /** index start */
  85059. indexStart: number,
  85060. /** indices count */
  85061. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85062. /**
  85063. * Returns true if this submesh covers the entire parent mesh
  85064. * @ignorenaming
  85065. */
  85066. readonly IsGlobal: boolean;
  85067. /**
  85068. * Returns the submesh BoudingInfo object
  85069. * @returns current bounding info (or mesh's one if the submesh is global)
  85070. */
  85071. getBoundingInfo(): BoundingInfo;
  85072. /**
  85073. * Sets the submesh BoundingInfo
  85074. * @param boundingInfo defines the new bounding info to use
  85075. * @returns the SubMesh
  85076. */
  85077. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85078. /**
  85079. * Returns the mesh of the current submesh
  85080. * @return the parent mesh
  85081. */
  85082. getMesh(): AbstractMesh;
  85083. /**
  85084. * Returns the rendering mesh of the submesh
  85085. * @returns the rendering mesh (could be different from parent mesh)
  85086. */
  85087. getRenderingMesh(): Mesh;
  85088. /**
  85089. * Returns the submesh material
  85090. * @returns null or the current material
  85091. */
  85092. getMaterial(): Nullable<Material>;
  85093. /**
  85094. * Sets a new updated BoundingInfo object to the submesh
  85095. * @param data defines an optional position array to use to determine the bounding info
  85096. * @returns the SubMesh
  85097. */
  85098. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85099. /** @hidden */
  85100. _checkCollision(collider: Collider): boolean;
  85101. /**
  85102. * Updates the submesh BoundingInfo
  85103. * @param world defines the world matrix to use to update the bounding info
  85104. * @returns the submesh
  85105. */
  85106. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85107. /**
  85108. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85109. * @param frustumPlanes defines the frustum planes
  85110. * @returns true if the submesh is intersecting with the frustum
  85111. */
  85112. isInFrustum(frustumPlanes: Plane[]): boolean;
  85113. /**
  85114. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85115. * @param frustumPlanes defines the frustum planes
  85116. * @returns true if the submesh is inside the frustum
  85117. */
  85118. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85119. /**
  85120. * Renders the submesh
  85121. * @param enableAlphaMode defines if alpha needs to be used
  85122. * @returns the submesh
  85123. */
  85124. render(enableAlphaMode: boolean): SubMesh;
  85125. /**
  85126. * @hidden
  85127. */
  85128. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85129. /**
  85130. * Checks if the submesh intersects with a ray
  85131. * @param ray defines the ray to test
  85132. * @returns true is the passed ray intersects the submesh bounding box
  85133. */
  85134. canIntersects(ray: Ray): boolean;
  85135. /**
  85136. * Intersects current submesh with a ray
  85137. * @param ray defines the ray to test
  85138. * @param positions defines mesh's positions array
  85139. * @param indices defines mesh's indices array
  85140. * @param fastCheck defines if only bounding info should be used
  85141. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85142. * @returns intersection info or null if no intersection
  85143. */
  85144. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85145. /** @hidden */
  85146. private _intersectLines;
  85147. /** @hidden */
  85148. private _intersectUnIndexedLines;
  85149. /** @hidden */
  85150. private _intersectTriangles;
  85151. /** @hidden */
  85152. private _intersectUnIndexedTriangles;
  85153. /** @hidden */
  85154. _rebuild(): void;
  85155. /**
  85156. * Creates a new submesh from the passed mesh
  85157. * @param newMesh defines the new hosting mesh
  85158. * @param newRenderingMesh defines an optional rendering mesh
  85159. * @returns the new submesh
  85160. */
  85161. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85162. /**
  85163. * Release associated resources
  85164. */
  85165. dispose(): void;
  85166. /**
  85167. * Gets the class name
  85168. * @returns the string "SubMesh".
  85169. */
  85170. getClassName(): string;
  85171. /**
  85172. * Creates a new submesh from indices data
  85173. * @param materialIndex the index of the main mesh material
  85174. * @param startIndex the index where to start the copy in the mesh indices array
  85175. * @param indexCount the number of indices to copy then from the startIndex
  85176. * @param mesh the main mesh to create the submesh from
  85177. * @param renderingMesh the optional rendering mesh
  85178. * @returns a new submesh
  85179. */
  85180. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85181. }
  85182. }
  85183. declare module BABYLON {
  85184. /**
  85185. * Class used to store geometry data (vertex buffers + index buffer)
  85186. */
  85187. export class Geometry implements IGetSetVerticesData {
  85188. /**
  85189. * Gets or sets the ID of the geometry
  85190. */
  85191. id: string;
  85192. /**
  85193. * Gets or sets the unique ID of the geometry
  85194. */
  85195. uniqueId: number;
  85196. /**
  85197. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85198. */
  85199. delayLoadState: number;
  85200. /**
  85201. * Gets the file containing the data to load when running in delay load state
  85202. */
  85203. delayLoadingFile: Nullable<string>;
  85204. /**
  85205. * Callback called when the geometry is updated
  85206. */
  85207. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85208. private _scene;
  85209. private _engine;
  85210. private _meshes;
  85211. private _totalVertices;
  85212. /** @hidden */
  85213. _indices: IndicesArray;
  85214. /** @hidden */
  85215. _vertexBuffers: {
  85216. [key: string]: VertexBuffer;
  85217. };
  85218. private _isDisposed;
  85219. private _extend;
  85220. private _boundingBias;
  85221. /** @hidden */
  85222. _delayInfo: Array<string>;
  85223. private _indexBuffer;
  85224. private _indexBufferIsUpdatable;
  85225. /** @hidden */
  85226. _boundingInfo: Nullable<BoundingInfo>;
  85227. /** @hidden */
  85228. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85229. /** @hidden */
  85230. _softwareSkinningFrameId: number;
  85231. private _vertexArrayObjects;
  85232. private _updatable;
  85233. /** @hidden */
  85234. _positions: Nullable<Vector3[]>;
  85235. /**
  85236. * 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
  85237. */
  85238. /**
  85239. * 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
  85240. */
  85241. boundingBias: Vector2;
  85242. /**
  85243. * Static function used to attach a new empty geometry to a mesh
  85244. * @param mesh defines the mesh to attach the geometry to
  85245. * @returns the new Geometry
  85246. */
  85247. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85248. /**
  85249. * Creates a new geometry
  85250. * @param id defines the unique ID
  85251. * @param scene defines the hosting scene
  85252. * @param vertexData defines the VertexData used to get geometry data
  85253. * @param updatable defines if geometry must be updatable (false by default)
  85254. * @param mesh defines the mesh that will be associated with the geometry
  85255. */
  85256. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85257. /**
  85258. * Gets the current extend of the geometry
  85259. */
  85260. readonly extend: {
  85261. minimum: Vector3;
  85262. maximum: Vector3;
  85263. };
  85264. /**
  85265. * Gets the hosting scene
  85266. * @returns the hosting Scene
  85267. */
  85268. getScene(): Scene;
  85269. /**
  85270. * Gets the hosting engine
  85271. * @returns the hosting Engine
  85272. */
  85273. getEngine(): Engine;
  85274. /**
  85275. * Defines if the geometry is ready to use
  85276. * @returns true if the geometry is ready to be used
  85277. */
  85278. isReady(): boolean;
  85279. /**
  85280. * Gets a value indicating that the geometry should not be serialized
  85281. */
  85282. readonly doNotSerialize: boolean;
  85283. /** @hidden */
  85284. _rebuild(): void;
  85285. /**
  85286. * Affects all geometry data in one call
  85287. * @param vertexData defines the geometry data
  85288. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85289. */
  85290. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85291. /**
  85292. * Set specific vertex data
  85293. * @param kind defines the data kind (Position, normal, etc...)
  85294. * @param data defines the vertex data to use
  85295. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85296. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85297. */
  85298. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85299. /**
  85300. * Removes a specific vertex data
  85301. * @param kind defines the data kind (Position, normal, etc...)
  85302. */
  85303. removeVerticesData(kind: string): void;
  85304. /**
  85305. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85306. * @param buffer defines the vertex buffer to use
  85307. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85308. */
  85309. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85310. /**
  85311. * Update a specific vertex buffer
  85312. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85313. * It will do nothing if the buffer is not updatable
  85314. * @param kind defines the data kind (Position, normal, etc...)
  85315. * @param data defines the data to use
  85316. * @param offset defines the offset in the target buffer where to store the data
  85317. * @param useBytes set to true if the offset is in bytes
  85318. */
  85319. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85320. /**
  85321. * Update a specific vertex buffer
  85322. * This function will create a new buffer if the current one is not updatable
  85323. * @param kind defines the data kind (Position, normal, etc...)
  85324. * @param data defines the data to use
  85325. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85326. */
  85327. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85328. private _updateBoundingInfo;
  85329. /** @hidden */
  85330. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85331. /**
  85332. * Gets total number of vertices
  85333. * @returns the total number of vertices
  85334. */
  85335. getTotalVertices(): number;
  85336. /**
  85337. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85338. * @param kind defines the data kind (Position, normal, etc...)
  85339. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85340. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85341. * @returns a float array containing vertex data
  85342. */
  85343. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85344. /**
  85345. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85346. * @param kind defines the data kind (Position, normal, etc...)
  85347. * @returns true if the vertex buffer with the specified kind is updatable
  85348. */
  85349. isVertexBufferUpdatable(kind: string): boolean;
  85350. /**
  85351. * Gets a specific vertex buffer
  85352. * @param kind defines the data kind (Position, normal, etc...)
  85353. * @returns a VertexBuffer
  85354. */
  85355. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85356. /**
  85357. * Returns all vertex buffers
  85358. * @return an object holding all vertex buffers indexed by kind
  85359. */
  85360. getVertexBuffers(): Nullable<{
  85361. [key: string]: VertexBuffer;
  85362. }>;
  85363. /**
  85364. * Gets a boolean indicating if specific vertex buffer is present
  85365. * @param kind defines the data kind (Position, normal, etc...)
  85366. * @returns true if data is present
  85367. */
  85368. isVerticesDataPresent(kind: string): boolean;
  85369. /**
  85370. * Gets a list of all attached data kinds (Position, normal, etc...)
  85371. * @returns a list of string containing all kinds
  85372. */
  85373. getVerticesDataKinds(): string[];
  85374. /**
  85375. * Update index buffer
  85376. * @param indices defines the indices to store in the index buffer
  85377. * @param offset defines the offset in the target buffer where to store the data
  85378. * @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)
  85379. */
  85380. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85381. /**
  85382. * Creates a new index buffer
  85383. * @param indices defines the indices to store in the index buffer
  85384. * @param totalVertices defines the total number of vertices (could be null)
  85385. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85386. */
  85387. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85388. /**
  85389. * Return the total number of indices
  85390. * @returns the total number of indices
  85391. */
  85392. getTotalIndices(): number;
  85393. /**
  85394. * Gets the index buffer array
  85395. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85396. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85397. * @returns the index buffer array
  85398. */
  85399. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85400. /**
  85401. * Gets the index buffer
  85402. * @return the index buffer
  85403. */
  85404. getIndexBuffer(): Nullable<DataBuffer>;
  85405. /** @hidden */
  85406. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85407. /**
  85408. * Release the associated resources for a specific mesh
  85409. * @param mesh defines the source mesh
  85410. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85411. */
  85412. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85413. /**
  85414. * Apply current geometry to a given mesh
  85415. * @param mesh defines the mesh to apply geometry to
  85416. */
  85417. applyToMesh(mesh: Mesh): void;
  85418. private _updateExtend;
  85419. private _applyToMesh;
  85420. private notifyUpdate;
  85421. /**
  85422. * Load the geometry if it was flagged as delay loaded
  85423. * @param scene defines the hosting scene
  85424. * @param onLoaded defines a callback called when the geometry is loaded
  85425. */
  85426. load(scene: Scene, onLoaded?: () => void): void;
  85427. private _queueLoad;
  85428. /**
  85429. * Invert the geometry to move from a right handed system to a left handed one.
  85430. */
  85431. toLeftHanded(): void;
  85432. /** @hidden */
  85433. _resetPointsArrayCache(): void;
  85434. /** @hidden */
  85435. _generatePointsArray(): boolean;
  85436. /**
  85437. * Gets a value indicating if the geometry is disposed
  85438. * @returns true if the geometry was disposed
  85439. */
  85440. isDisposed(): boolean;
  85441. private _disposeVertexArrayObjects;
  85442. /**
  85443. * Free all associated resources
  85444. */
  85445. dispose(): void;
  85446. /**
  85447. * Clone the current geometry into a new geometry
  85448. * @param id defines the unique ID of the new geometry
  85449. * @returns a new geometry object
  85450. */
  85451. copy(id: string): Geometry;
  85452. /**
  85453. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85454. * @return a JSON representation of the current geometry data (without the vertices data)
  85455. */
  85456. serialize(): any;
  85457. private toNumberArray;
  85458. /**
  85459. * Serialize all vertices data into a JSON oject
  85460. * @returns a JSON representation of the current geometry data
  85461. */
  85462. serializeVerticeData(): any;
  85463. /**
  85464. * Extracts a clone of a mesh geometry
  85465. * @param mesh defines the source mesh
  85466. * @param id defines the unique ID of the new geometry object
  85467. * @returns the new geometry object
  85468. */
  85469. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85470. /**
  85471. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85472. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85473. * Be aware Math.random() could cause collisions, but:
  85474. * "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"
  85475. * @returns a string containing a new GUID
  85476. */
  85477. static RandomId(): string;
  85478. /** @hidden */
  85479. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85480. private static _CleanMatricesWeights;
  85481. /**
  85482. * Create a new geometry from persisted data (Using .babylon file format)
  85483. * @param parsedVertexData defines the persisted data
  85484. * @param scene defines the hosting scene
  85485. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85486. * @returns the new geometry object
  85487. */
  85488. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85489. }
  85490. }
  85491. declare module BABYLON {
  85492. /**
  85493. * Define an interface for all classes that will get and set the data on vertices
  85494. */
  85495. export interface IGetSetVerticesData {
  85496. /**
  85497. * Gets a boolean indicating if specific vertex data is present
  85498. * @param kind defines the vertex data kind to use
  85499. * @returns true is data kind is present
  85500. */
  85501. isVerticesDataPresent(kind: string): boolean;
  85502. /**
  85503. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85504. * @param kind defines the data kind (Position, normal, etc...)
  85505. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85506. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85507. * @returns a float array containing vertex data
  85508. */
  85509. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85510. /**
  85511. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85512. * @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.
  85513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85514. * @returns the indices array or an empty array if the mesh has no geometry
  85515. */
  85516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85517. /**
  85518. * Set specific vertex data
  85519. * @param kind defines the data kind (Position, normal, etc...)
  85520. * @param data defines the vertex data to use
  85521. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85522. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85523. */
  85524. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85525. /**
  85526. * Update a specific associated vertex buffer
  85527. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85528. * - VertexBuffer.PositionKind
  85529. * - VertexBuffer.UVKind
  85530. * - VertexBuffer.UV2Kind
  85531. * - VertexBuffer.UV3Kind
  85532. * - VertexBuffer.UV4Kind
  85533. * - VertexBuffer.UV5Kind
  85534. * - VertexBuffer.UV6Kind
  85535. * - VertexBuffer.ColorKind
  85536. * - VertexBuffer.MatricesIndicesKind
  85537. * - VertexBuffer.MatricesIndicesExtraKind
  85538. * - VertexBuffer.MatricesWeightsKind
  85539. * - VertexBuffer.MatricesWeightsExtraKind
  85540. * @param data defines the data source
  85541. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85542. * @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)
  85543. */
  85544. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85545. /**
  85546. * Creates a new index buffer
  85547. * @param indices defines the indices to store in the index buffer
  85548. * @param totalVertices defines the total number of vertices (could be null)
  85549. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85550. */
  85551. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85552. }
  85553. /**
  85554. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85555. */
  85556. export class VertexData {
  85557. /**
  85558. * Mesh side orientation : usually the external or front surface
  85559. */
  85560. static readonly FRONTSIDE: number;
  85561. /**
  85562. * Mesh side orientation : usually the internal or back surface
  85563. */
  85564. static readonly BACKSIDE: number;
  85565. /**
  85566. * Mesh side orientation : both internal and external or front and back surfaces
  85567. */
  85568. static readonly DOUBLESIDE: number;
  85569. /**
  85570. * Mesh side orientation : by default, `FRONTSIDE`
  85571. */
  85572. static readonly DEFAULTSIDE: number;
  85573. /**
  85574. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85575. */
  85576. positions: Nullable<FloatArray>;
  85577. /**
  85578. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85579. */
  85580. normals: Nullable<FloatArray>;
  85581. /**
  85582. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85583. */
  85584. tangents: Nullable<FloatArray>;
  85585. /**
  85586. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85587. */
  85588. uvs: Nullable<FloatArray>;
  85589. /**
  85590. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85591. */
  85592. uvs2: Nullable<FloatArray>;
  85593. /**
  85594. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85595. */
  85596. uvs3: Nullable<FloatArray>;
  85597. /**
  85598. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85599. */
  85600. uvs4: Nullable<FloatArray>;
  85601. /**
  85602. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85603. */
  85604. uvs5: Nullable<FloatArray>;
  85605. /**
  85606. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85607. */
  85608. uvs6: Nullable<FloatArray>;
  85609. /**
  85610. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85611. */
  85612. colors: Nullable<FloatArray>;
  85613. /**
  85614. * 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).
  85615. */
  85616. matricesIndices: Nullable<FloatArray>;
  85617. /**
  85618. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85619. */
  85620. matricesWeights: Nullable<FloatArray>;
  85621. /**
  85622. * An array extending the number of possible indices
  85623. */
  85624. matricesIndicesExtra: Nullable<FloatArray>;
  85625. /**
  85626. * An array extending the number of possible weights when the number of indices is extended
  85627. */
  85628. matricesWeightsExtra: Nullable<FloatArray>;
  85629. /**
  85630. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85631. */
  85632. indices: Nullable<IndicesArray>;
  85633. /**
  85634. * Uses the passed data array to set the set the values for the specified kind of data
  85635. * @param data a linear array of floating numbers
  85636. * @param kind the type of data that is being set, eg positions, colors etc
  85637. */
  85638. set(data: FloatArray, kind: string): void;
  85639. /**
  85640. * Associates the vertexData to the passed Mesh.
  85641. * Sets it as updatable or not (default `false`)
  85642. * @param mesh the mesh the vertexData is applied to
  85643. * @param updatable when used and having the value true allows new data to update the vertexData
  85644. * @returns the VertexData
  85645. */
  85646. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85647. /**
  85648. * Associates the vertexData to the passed Geometry.
  85649. * Sets it as updatable or not (default `false`)
  85650. * @param geometry the geometry the vertexData is applied to
  85651. * @param updatable when used and having the value true allows new data to update the vertexData
  85652. * @returns VertexData
  85653. */
  85654. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85655. /**
  85656. * Updates the associated mesh
  85657. * @param mesh the mesh to be updated
  85658. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85659. * @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
  85660. * @returns VertexData
  85661. */
  85662. updateMesh(mesh: Mesh): VertexData;
  85663. /**
  85664. * Updates the associated geometry
  85665. * @param geometry the geometry to be updated
  85666. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85667. * @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
  85668. * @returns VertexData.
  85669. */
  85670. updateGeometry(geometry: Geometry): VertexData;
  85671. private _applyTo;
  85672. private _update;
  85673. /**
  85674. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85675. * @param matrix the transforming matrix
  85676. * @returns the VertexData
  85677. */
  85678. transform(matrix: Matrix): VertexData;
  85679. /**
  85680. * Merges the passed VertexData into the current one
  85681. * @param other the VertexData to be merged into the current one
  85682. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85683. * @returns the modified VertexData
  85684. */
  85685. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85686. private _mergeElement;
  85687. private _validate;
  85688. /**
  85689. * Serializes the VertexData
  85690. * @returns a serialized object
  85691. */
  85692. serialize(): any;
  85693. /**
  85694. * Extracts the vertexData from a mesh
  85695. * @param mesh the mesh from which to extract the VertexData
  85696. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85697. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85698. * @returns the object VertexData associated to the passed mesh
  85699. */
  85700. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85701. /**
  85702. * Extracts the vertexData from the geometry
  85703. * @param geometry the geometry from which to extract the VertexData
  85704. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85705. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85706. * @returns the object VertexData associated to the passed mesh
  85707. */
  85708. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85709. private static _ExtractFrom;
  85710. /**
  85711. * Creates the VertexData for a Ribbon
  85712. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85713. * * pathArray array of paths, each of which an array of successive Vector3
  85714. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85715. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85716. * * 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
  85717. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85718. * * 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)
  85719. * * 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)
  85720. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85721. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85722. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85723. * @returns the VertexData of the ribbon
  85724. */
  85725. static CreateRibbon(options: {
  85726. pathArray: Vector3[][];
  85727. closeArray?: boolean;
  85728. closePath?: boolean;
  85729. offset?: number;
  85730. sideOrientation?: number;
  85731. frontUVs?: Vector4;
  85732. backUVs?: Vector4;
  85733. invertUV?: boolean;
  85734. uvs?: Vector2[];
  85735. colors?: Color4[];
  85736. }): VertexData;
  85737. /**
  85738. * Creates the VertexData for a box
  85739. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85740. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85741. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85742. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85743. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85744. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85745. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85746. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85747. * * 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)
  85748. * * 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)
  85749. * @returns the VertexData of the box
  85750. */
  85751. static CreateBox(options: {
  85752. size?: number;
  85753. width?: number;
  85754. height?: number;
  85755. depth?: number;
  85756. faceUV?: Vector4[];
  85757. faceColors?: Color4[];
  85758. sideOrientation?: number;
  85759. frontUVs?: Vector4;
  85760. backUVs?: Vector4;
  85761. }): VertexData;
  85762. /**
  85763. * Creates the VertexData for a tiled box
  85764. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85765. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85766. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85767. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85769. * @returns the VertexData of the box
  85770. */
  85771. static CreateTiledBox(options: {
  85772. pattern?: number;
  85773. width?: number;
  85774. height?: number;
  85775. depth?: number;
  85776. tileSize?: number;
  85777. tileWidth?: number;
  85778. tileHeight?: number;
  85779. alignHorizontal?: number;
  85780. alignVertical?: number;
  85781. faceUV?: Vector4[];
  85782. faceColors?: Color4[];
  85783. sideOrientation?: number;
  85784. }): VertexData;
  85785. /**
  85786. * Creates the VertexData for a tiled plane
  85787. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85788. * * pattern a limited pattern arrangement depending on the number
  85789. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85790. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85791. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85792. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85793. * * 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)
  85794. * * 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)
  85795. * @returns the VertexData of the tiled plane
  85796. */
  85797. static CreateTiledPlane(options: {
  85798. pattern?: number;
  85799. tileSize?: number;
  85800. tileWidth?: number;
  85801. tileHeight?: number;
  85802. size?: number;
  85803. width?: number;
  85804. height?: number;
  85805. alignHorizontal?: number;
  85806. alignVertical?: number;
  85807. sideOrientation?: number;
  85808. frontUVs?: Vector4;
  85809. backUVs?: Vector4;
  85810. }): VertexData;
  85811. /**
  85812. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85813. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85814. * * segments sets the number of horizontal strips optional, default 32
  85815. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85816. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85817. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85818. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85819. * * 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
  85820. * * 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
  85821. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85822. * * 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)
  85823. * * 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)
  85824. * @returns the VertexData of the ellipsoid
  85825. */
  85826. static CreateSphere(options: {
  85827. segments?: number;
  85828. diameter?: number;
  85829. diameterX?: number;
  85830. diameterY?: number;
  85831. diameterZ?: number;
  85832. arc?: number;
  85833. slice?: number;
  85834. sideOrientation?: number;
  85835. frontUVs?: Vector4;
  85836. backUVs?: Vector4;
  85837. }): VertexData;
  85838. /**
  85839. * Creates the VertexData for a cylinder, cone or prism
  85840. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85841. * * height sets the height (y direction) of the cylinder, optional, default 2
  85842. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85843. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85844. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85845. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85846. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85847. * * 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
  85848. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85849. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85850. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85851. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85852. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85853. * * 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)
  85854. * * 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)
  85855. * @returns the VertexData of the cylinder, cone or prism
  85856. */
  85857. static CreateCylinder(options: {
  85858. height?: number;
  85859. diameterTop?: number;
  85860. diameterBottom?: number;
  85861. diameter?: number;
  85862. tessellation?: number;
  85863. subdivisions?: number;
  85864. arc?: number;
  85865. faceColors?: Color4[];
  85866. faceUV?: Vector4[];
  85867. hasRings?: boolean;
  85868. enclose?: boolean;
  85869. sideOrientation?: number;
  85870. frontUVs?: Vector4;
  85871. backUVs?: Vector4;
  85872. }): VertexData;
  85873. /**
  85874. * Creates the VertexData for a torus
  85875. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85876. * * diameter the diameter of the torus, optional default 1
  85877. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85878. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85879. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85880. * * 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)
  85881. * * 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)
  85882. * @returns the VertexData of the torus
  85883. */
  85884. static CreateTorus(options: {
  85885. diameter?: number;
  85886. thickness?: number;
  85887. tessellation?: number;
  85888. sideOrientation?: number;
  85889. frontUVs?: Vector4;
  85890. backUVs?: Vector4;
  85891. }): VertexData;
  85892. /**
  85893. * Creates the VertexData of the LineSystem
  85894. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85895. * - lines an array of lines, each line being an array of successive Vector3
  85896. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85897. * @returns the VertexData of the LineSystem
  85898. */
  85899. static CreateLineSystem(options: {
  85900. lines: Vector3[][];
  85901. colors?: Nullable<Color4[][]>;
  85902. }): VertexData;
  85903. /**
  85904. * Create the VertexData for a DashedLines
  85905. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85906. * - points an array successive Vector3
  85907. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85908. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85909. * - dashNb the intended total number of dashes, optional, default 200
  85910. * @returns the VertexData for the DashedLines
  85911. */
  85912. static CreateDashedLines(options: {
  85913. points: Vector3[];
  85914. dashSize?: number;
  85915. gapSize?: number;
  85916. dashNb?: number;
  85917. }): VertexData;
  85918. /**
  85919. * Creates the VertexData for a Ground
  85920. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85921. * - width the width (x direction) of the ground, optional, default 1
  85922. * - height the height (z direction) of the ground, optional, default 1
  85923. * - subdivisions the number of subdivisions per side, optional, default 1
  85924. * @returns the VertexData of the Ground
  85925. */
  85926. static CreateGround(options: {
  85927. width?: number;
  85928. height?: number;
  85929. subdivisions?: number;
  85930. subdivisionsX?: number;
  85931. subdivisionsY?: number;
  85932. }): VertexData;
  85933. /**
  85934. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85935. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85936. * * xmin the ground minimum X coordinate, optional, default -1
  85937. * * zmin the ground minimum Z coordinate, optional, default -1
  85938. * * xmax the ground maximum X coordinate, optional, default 1
  85939. * * zmax the ground maximum Z coordinate, optional, default 1
  85940. * * 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}
  85941. * * 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}
  85942. * @returns the VertexData of the TiledGround
  85943. */
  85944. static CreateTiledGround(options: {
  85945. xmin: number;
  85946. zmin: number;
  85947. xmax: number;
  85948. zmax: number;
  85949. subdivisions?: {
  85950. w: number;
  85951. h: number;
  85952. };
  85953. precision?: {
  85954. w: number;
  85955. h: number;
  85956. };
  85957. }): VertexData;
  85958. /**
  85959. * Creates the VertexData of the Ground designed from a heightmap
  85960. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85961. * * width the width (x direction) of the ground
  85962. * * height the height (z direction) of the ground
  85963. * * subdivisions the number of subdivisions per side
  85964. * * minHeight the minimum altitude on the ground, optional, default 0
  85965. * * maxHeight the maximum altitude on the ground, optional default 1
  85966. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85967. * * buffer the array holding the image color data
  85968. * * bufferWidth the width of image
  85969. * * bufferHeight the height of image
  85970. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85971. * @returns the VertexData of the Ground designed from a heightmap
  85972. */
  85973. static CreateGroundFromHeightMap(options: {
  85974. width: number;
  85975. height: number;
  85976. subdivisions: number;
  85977. minHeight: number;
  85978. maxHeight: number;
  85979. colorFilter: Color3;
  85980. buffer: Uint8Array;
  85981. bufferWidth: number;
  85982. bufferHeight: number;
  85983. alphaFilter: number;
  85984. }): VertexData;
  85985. /**
  85986. * Creates the VertexData for a Plane
  85987. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85988. * * size sets the width and height of the plane to the value of size, optional default 1
  85989. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85990. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85992. * * 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)
  85993. * * 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)
  85994. * @returns the VertexData of the box
  85995. */
  85996. static CreatePlane(options: {
  85997. size?: number;
  85998. width?: number;
  85999. height?: number;
  86000. sideOrientation?: number;
  86001. frontUVs?: Vector4;
  86002. backUVs?: Vector4;
  86003. }): VertexData;
  86004. /**
  86005. * Creates the VertexData of the Disc or regular Polygon
  86006. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86007. * * radius the radius of the disc, optional default 0.5
  86008. * * tessellation the number of polygon sides, optional, default 64
  86009. * * 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
  86010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86011. * * 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)
  86012. * * 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)
  86013. * @returns the VertexData of the box
  86014. */
  86015. static CreateDisc(options: {
  86016. radius?: number;
  86017. tessellation?: number;
  86018. arc?: number;
  86019. sideOrientation?: number;
  86020. frontUVs?: Vector4;
  86021. backUVs?: Vector4;
  86022. }): VertexData;
  86023. /**
  86024. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86025. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86026. * @param polygon a mesh built from polygonTriangulation.build()
  86027. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86028. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86029. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86030. * @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)
  86031. * @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)
  86032. * @returns the VertexData of the Polygon
  86033. */
  86034. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86035. /**
  86036. * Creates the VertexData of the IcoSphere
  86037. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86038. * * radius the radius of the IcoSphere, optional default 1
  86039. * * radiusX allows stretching in the x direction, optional, default radius
  86040. * * radiusY allows stretching in the y direction, optional, default radius
  86041. * * radiusZ allows stretching in the z direction, optional, default radius
  86042. * * flat when true creates a flat shaded mesh, optional, default true
  86043. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86044. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86045. * * 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)
  86046. * * 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)
  86047. * @returns the VertexData of the IcoSphere
  86048. */
  86049. static CreateIcoSphere(options: {
  86050. radius?: number;
  86051. radiusX?: number;
  86052. radiusY?: number;
  86053. radiusZ?: number;
  86054. flat?: boolean;
  86055. subdivisions?: number;
  86056. sideOrientation?: number;
  86057. frontUVs?: Vector4;
  86058. backUVs?: Vector4;
  86059. }): VertexData;
  86060. /**
  86061. * Creates the VertexData for a Polyhedron
  86062. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86063. * * type provided types are:
  86064. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86065. * * 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)
  86066. * * size the size of the IcoSphere, optional default 1
  86067. * * sizeX allows stretching in the x direction, optional, default size
  86068. * * sizeY allows stretching in the y direction, optional, default size
  86069. * * sizeZ allows stretching in the z direction, optional, default size
  86070. * * 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
  86071. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86072. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86073. * * flat when true creates a flat shaded mesh, optional, default true
  86074. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86076. * * 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)
  86077. * * 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)
  86078. * @returns the VertexData of the Polyhedron
  86079. */
  86080. static CreatePolyhedron(options: {
  86081. type?: number;
  86082. size?: number;
  86083. sizeX?: number;
  86084. sizeY?: number;
  86085. sizeZ?: number;
  86086. custom?: any;
  86087. faceUV?: Vector4[];
  86088. faceColors?: Color4[];
  86089. flat?: boolean;
  86090. sideOrientation?: number;
  86091. frontUVs?: Vector4;
  86092. backUVs?: Vector4;
  86093. }): VertexData;
  86094. /**
  86095. * Creates the VertexData for a TorusKnot
  86096. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86097. * * radius the radius of the torus knot, optional, default 2
  86098. * * tube the thickness of the tube, optional, default 0.5
  86099. * * radialSegments the number of sides on each tube segments, optional, default 32
  86100. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86101. * * p the number of windings around the z axis, optional, default 2
  86102. * * q the number of windings around the x axis, optional, default 3
  86103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86104. * * 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)
  86105. * * 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)
  86106. * @returns the VertexData of the Torus Knot
  86107. */
  86108. static CreateTorusKnot(options: {
  86109. radius?: number;
  86110. tube?: number;
  86111. radialSegments?: number;
  86112. tubularSegments?: number;
  86113. p?: number;
  86114. q?: number;
  86115. sideOrientation?: number;
  86116. frontUVs?: Vector4;
  86117. backUVs?: Vector4;
  86118. }): VertexData;
  86119. /**
  86120. * Compute normals for given positions and indices
  86121. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86122. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86123. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86124. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86125. * * facetNormals : optional array of facet normals (vector3)
  86126. * * facetPositions : optional array of facet positions (vector3)
  86127. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86128. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86129. * * bInfo : optional bounding info, required for facetPartitioning computation
  86130. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86131. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86132. * * useRightHandedSystem: optional boolean to for right handed system computation
  86133. * * depthSort : optional boolean to enable the facet depth sort computation
  86134. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86135. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86136. */
  86137. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86138. facetNormals?: any;
  86139. facetPositions?: any;
  86140. facetPartitioning?: any;
  86141. ratio?: number;
  86142. bInfo?: any;
  86143. bbSize?: Vector3;
  86144. subDiv?: any;
  86145. useRightHandedSystem?: boolean;
  86146. depthSort?: boolean;
  86147. distanceTo?: Vector3;
  86148. depthSortedFacets?: any;
  86149. }): void;
  86150. /** @hidden */
  86151. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86152. /**
  86153. * Applies VertexData created from the imported parameters to the geometry
  86154. * @param parsedVertexData the parsed data from an imported file
  86155. * @param geometry the geometry to apply the VertexData to
  86156. */
  86157. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86158. }
  86159. }
  86160. declare module BABYLON {
  86161. /**
  86162. * Class containing static functions to help procedurally build meshes
  86163. */
  86164. export class DiscBuilder {
  86165. /**
  86166. * Creates a plane polygonal mesh. By default, this is a disc
  86167. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86168. * * 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
  86169. * * 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
  86170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86173. * @param name defines the name of the mesh
  86174. * @param options defines the options used to create the mesh
  86175. * @param scene defines the hosting scene
  86176. * @returns the plane polygonal mesh
  86177. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86178. */
  86179. static CreateDisc(name: string, options: {
  86180. radius?: number;
  86181. tessellation?: number;
  86182. arc?: number;
  86183. updatable?: boolean;
  86184. sideOrientation?: number;
  86185. frontUVs?: Vector4;
  86186. backUVs?: Vector4;
  86187. }, scene?: Nullable<Scene>): Mesh;
  86188. }
  86189. }
  86190. declare module BABYLON {
  86191. /**
  86192. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86193. *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.
  86194. * The SPS is also a particle system. It provides some methods to manage the particles.
  86195. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86196. *
  86197. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86198. */
  86199. export class SolidParticleSystem implements IDisposable {
  86200. /**
  86201. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86202. * Example : var p = SPS.particles[i];
  86203. */
  86204. particles: SolidParticle[];
  86205. /**
  86206. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86207. */
  86208. nbParticles: number;
  86209. /**
  86210. * If the particles must ever face the camera (default false). Useful for planar particles.
  86211. */
  86212. billboard: boolean;
  86213. /**
  86214. * Recompute normals when adding a shape
  86215. */
  86216. recomputeNormals: boolean;
  86217. /**
  86218. * This a counter ofr your own usage. It's not set by any SPS functions.
  86219. */
  86220. counter: number;
  86221. /**
  86222. * The SPS name. This name is also given to the underlying mesh.
  86223. */
  86224. name: string;
  86225. /**
  86226. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86227. */
  86228. mesh: Mesh;
  86229. /**
  86230. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86231. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86232. */
  86233. vars: any;
  86234. /**
  86235. * This array is populated when the SPS is set as 'pickable'.
  86236. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86237. * Each element of this array is an object `{idx: int, faceId: int}`.
  86238. * `idx` is the picked particle index in the `SPS.particles` array
  86239. * `faceId` is the picked face index counted within this particle.
  86240. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86241. */
  86242. pickedParticles: {
  86243. idx: number;
  86244. faceId: number;
  86245. }[];
  86246. /**
  86247. * This array is populated when `enableDepthSort` is set to true.
  86248. * Each element of this array is an instance of the class DepthSortedParticle.
  86249. */
  86250. depthSortedParticles: DepthSortedParticle[];
  86251. /**
  86252. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86253. * @hidden
  86254. */
  86255. _bSphereOnly: boolean;
  86256. /**
  86257. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86258. * @hidden
  86259. */
  86260. _bSphereRadiusFactor: number;
  86261. private _scene;
  86262. private _positions;
  86263. private _indices;
  86264. private _normals;
  86265. private _colors;
  86266. private _uvs;
  86267. private _indices32;
  86268. private _positions32;
  86269. private _normals32;
  86270. private _fixedNormal32;
  86271. private _colors32;
  86272. private _uvs32;
  86273. private _index;
  86274. private _updatable;
  86275. private _pickable;
  86276. private _isVisibilityBoxLocked;
  86277. private _alwaysVisible;
  86278. private _depthSort;
  86279. private _shapeCounter;
  86280. private _copy;
  86281. private _color;
  86282. private _computeParticleColor;
  86283. private _computeParticleTexture;
  86284. private _computeParticleRotation;
  86285. private _computeParticleVertex;
  86286. private _computeBoundingBox;
  86287. private _depthSortParticles;
  86288. private _camera;
  86289. private _mustUnrotateFixedNormals;
  86290. private _particlesIntersect;
  86291. private _needs32Bits;
  86292. /**
  86293. * Creates a SPS (Solid Particle System) object.
  86294. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86295. * @param scene (Scene) is the scene in which the SPS is added.
  86296. * @param options defines the options of the sps e.g.
  86297. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86298. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86299. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86300. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86301. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86302. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86303. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86304. */
  86305. constructor(name: string, scene: Scene, options?: {
  86306. updatable?: boolean;
  86307. isPickable?: boolean;
  86308. enableDepthSort?: boolean;
  86309. particleIntersection?: boolean;
  86310. boundingSphereOnly?: boolean;
  86311. bSphereRadiusFactor?: number;
  86312. });
  86313. /**
  86314. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86315. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86316. * @returns the created mesh
  86317. */
  86318. buildMesh(): Mesh;
  86319. /**
  86320. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86321. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86322. * Thus the particles generated from `digest()` have their property `position` set yet.
  86323. * @param mesh ( Mesh ) is the mesh to be digested
  86324. * @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
  86325. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86326. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86327. * @returns the current SPS
  86328. */
  86329. digest(mesh: Mesh, options?: {
  86330. facetNb?: number;
  86331. number?: number;
  86332. delta?: number;
  86333. }): SolidParticleSystem;
  86334. private _unrotateFixedNormals;
  86335. private _resetCopy;
  86336. private _meshBuilder;
  86337. private _posToShape;
  86338. private _uvsToShapeUV;
  86339. private _addParticle;
  86340. /**
  86341. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86342. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86343. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86344. * @param nb (positive integer) the number of particles to be created from this model
  86345. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86346. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86347. * @returns the number of shapes in the system
  86348. */
  86349. addShape(mesh: Mesh, nb: number, options?: {
  86350. positionFunction?: any;
  86351. vertexFunction?: any;
  86352. }): number;
  86353. private _rebuildParticle;
  86354. /**
  86355. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86356. * @returns the SPS.
  86357. */
  86358. rebuildMesh(): SolidParticleSystem;
  86359. /**
  86360. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86361. * This method calls `updateParticle()` for each particle of the SPS.
  86362. * For an animated SPS, it is usually called within the render loop.
  86363. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86364. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86365. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86366. * @returns the SPS.
  86367. */
  86368. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86369. /**
  86370. * Disposes the SPS.
  86371. */
  86372. dispose(): void;
  86373. /**
  86374. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86375. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86376. * @returns the SPS.
  86377. */
  86378. refreshVisibleSize(): SolidParticleSystem;
  86379. /**
  86380. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86381. * @param size the size (float) of the visibility box
  86382. * note : this doesn't lock the SPS mesh bounding box.
  86383. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86384. */
  86385. setVisibilityBox(size: number): void;
  86386. /**
  86387. * Gets whether the SPS as always visible or not
  86388. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86389. */
  86390. /**
  86391. * Sets the SPS as always visible or not
  86392. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86393. */
  86394. isAlwaysVisible: boolean;
  86395. /**
  86396. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86397. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86398. */
  86399. /**
  86400. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86401. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86402. */
  86403. isVisibilityBoxLocked: boolean;
  86404. /**
  86405. * Tells to `setParticles()` to compute the particle rotations or not.
  86406. * Default value : true. The SPS is faster when it's set to false.
  86407. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86408. */
  86409. /**
  86410. * Gets if `setParticles()` computes the particle rotations or not.
  86411. * Default value : true. The SPS is faster when it's set to false.
  86412. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86413. */
  86414. computeParticleRotation: boolean;
  86415. /**
  86416. * Tells to `setParticles()` to compute the particle colors or not.
  86417. * Default value : true. The SPS is faster when it's set to false.
  86418. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86419. */
  86420. /**
  86421. * Gets if `setParticles()` computes the particle colors or not.
  86422. * Default value : true. The SPS is faster when it's set to false.
  86423. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86424. */
  86425. computeParticleColor: boolean;
  86426. /**
  86427. * Gets if `setParticles()` computes the particle textures or not.
  86428. * Default value : true. The SPS is faster when it's set to false.
  86429. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86430. */
  86431. computeParticleTexture: boolean;
  86432. /**
  86433. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86434. * Default value : false. The SPS is faster when it's set to false.
  86435. * Note : the particle custom vertex positions aren't stored values.
  86436. */
  86437. /**
  86438. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86439. * Default value : false. The SPS is faster when it's set to false.
  86440. * Note : the particle custom vertex positions aren't stored values.
  86441. */
  86442. computeParticleVertex: boolean;
  86443. /**
  86444. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86445. */
  86446. /**
  86447. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86448. */
  86449. computeBoundingBox: boolean;
  86450. /**
  86451. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86452. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86453. * Default : `true`
  86454. */
  86455. /**
  86456. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86457. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86458. * Default : `true`
  86459. */
  86460. depthSortParticles: boolean;
  86461. /**
  86462. * This function does nothing. It may be overwritten to set all the particle first values.
  86463. * The SPS doesn't call this function, you may have to call it by your own.
  86464. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86465. */
  86466. initParticles(): void;
  86467. /**
  86468. * This function does nothing. It may be overwritten to recycle a particle.
  86469. * The SPS doesn't call this function, you may have to call it by your own.
  86470. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86471. * @param particle The particle to recycle
  86472. * @returns the recycled particle
  86473. */
  86474. recycleParticle(particle: SolidParticle): SolidParticle;
  86475. /**
  86476. * Updates a particle : this function should be overwritten by the user.
  86477. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86478. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86479. * @example : just set a particle position or velocity and recycle conditions
  86480. * @param particle The particle to update
  86481. * @returns the updated particle
  86482. */
  86483. updateParticle(particle: SolidParticle): SolidParticle;
  86484. /**
  86485. * Updates a vertex of a particle : it can be overwritten by the user.
  86486. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86487. * @param particle the current particle
  86488. * @param vertex the current index of the current particle
  86489. * @param pt the index of the current vertex in the particle shape
  86490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86491. * @example : just set a vertex particle position
  86492. * @returns the updated vertex
  86493. */
  86494. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86495. /**
  86496. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86497. * This does nothing and may be overwritten by the user.
  86498. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86499. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86500. * @param update the boolean update value actually passed to setParticles()
  86501. */
  86502. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86503. /**
  86504. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86505. * This will be passed three parameters.
  86506. * This does nothing and may be overwritten by the user.
  86507. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86508. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86509. * @param update the boolean update value actually passed to setParticles()
  86510. */
  86511. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86512. }
  86513. }
  86514. declare module BABYLON {
  86515. /**
  86516. * Represents one particle of a solid particle system.
  86517. */
  86518. export class SolidParticle {
  86519. /**
  86520. * particle global index
  86521. */
  86522. idx: number;
  86523. /**
  86524. * The color of the particle
  86525. */
  86526. color: Nullable<Color4>;
  86527. /**
  86528. * The world space position of the particle.
  86529. */
  86530. position: Vector3;
  86531. /**
  86532. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86533. */
  86534. rotation: Vector3;
  86535. /**
  86536. * The world space rotation quaternion of the particle.
  86537. */
  86538. rotationQuaternion: Nullable<Quaternion>;
  86539. /**
  86540. * The scaling of the particle.
  86541. */
  86542. scaling: Vector3;
  86543. /**
  86544. * The uvs of the particle.
  86545. */
  86546. uvs: Vector4;
  86547. /**
  86548. * The current speed of the particle.
  86549. */
  86550. velocity: Vector3;
  86551. /**
  86552. * The pivot point in the particle local space.
  86553. */
  86554. pivot: Vector3;
  86555. /**
  86556. * Must the particle be translated from its pivot point in its local space ?
  86557. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86558. * Default : false
  86559. */
  86560. translateFromPivot: boolean;
  86561. /**
  86562. * Is the particle active or not ?
  86563. */
  86564. alive: boolean;
  86565. /**
  86566. * Is the particle visible or not ?
  86567. */
  86568. isVisible: boolean;
  86569. /**
  86570. * Index of this particle in the global "positions" array (Internal use)
  86571. * @hidden
  86572. */
  86573. _pos: number;
  86574. /**
  86575. * @hidden Index of this particle in the global "indices" array (Internal use)
  86576. */
  86577. _ind: number;
  86578. /**
  86579. * @hidden ModelShape of this particle (Internal use)
  86580. */
  86581. _model: ModelShape;
  86582. /**
  86583. * ModelShape id of this particle
  86584. */
  86585. shapeId: number;
  86586. /**
  86587. * Index of the particle in its shape id (Internal use)
  86588. */
  86589. idxInShape: number;
  86590. /**
  86591. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86592. */
  86593. _modelBoundingInfo: BoundingInfo;
  86594. /**
  86595. * @hidden Particle BoundingInfo object (Internal use)
  86596. */
  86597. _boundingInfo: BoundingInfo;
  86598. /**
  86599. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86600. */
  86601. _sps: SolidParticleSystem;
  86602. /**
  86603. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86604. */
  86605. _stillInvisible: boolean;
  86606. /**
  86607. * @hidden Last computed particle rotation matrix
  86608. */
  86609. _rotationMatrix: number[];
  86610. /**
  86611. * Parent particle Id, if any.
  86612. * Default null.
  86613. */
  86614. parentId: Nullable<number>;
  86615. /**
  86616. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86617. * The possible values are :
  86618. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86619. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86620. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86621. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86622. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86623. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86624. * */
  86625. cullingStrategy: number;
  86626. /**
  86627. * @hidden Internal global position in the SPS.
  86628. */
  86629. _globalPosition: Vector3;
  86630. /**
  86631. * Creates a Solid Particle object.
  86632. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86633. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86634. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86635. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86636. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86637. * @param shapeId (integer) is the model shape identifier in the SPS.
  86638. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86639. * @param sps defines the sps it is associated to
  86640. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86641. */
  86642. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86643. /**
  86644. * Legacy support, changed scale to scaling
  86645. */
  86646. /**
  86647. * Legacy support, changed scale to scaling
  86648. */
  86649. scale: Vector3;
  86650. /**
  86651. * Legacy support, changed quaternion to rotationQuaternion
  86652. */
  86653. /**
  86654. * Legacy support, changed quaternion to rotationQuaternion
  86655. */
  86656. quaternion: Nullable<Quaternion>;
  86657. /**
  86658. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86659. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86660. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86661. * @returns true if it intersects
  86662. */
  86663. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86664. /**
  86665. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86666. * A particle is in the frustum if its bounding box intersects the frustum
  86667. * @param frustumPlanes defines the frustum to test
  86668. * @returns true if the particle is in the frustum planes
  86669. */
  86670. isInFrustum(frustumPlanes: Plane[]): boolean;
  86671. /**
  86672. * get the rotation matrix of the particle
  86673. * @hidden
  86674. */
  86675. getRotationMatrix(m: Matrix): void;
  86676. }
  86677. /**
  86678. * Represents the shape of the model used by one particle of a solid particle system.
  86679. * SPS internal tool, don't use it manually.
  86680. */
  86681. export class ModelShape {
  86682. /**
  86683. * The shape id
  86684. * @hidden
  86685. */
  86686. shapeID: number;
  86687. /**
  86688. * flat array of model positions (internal use)
  86689. * @hidden
  86690. */
  86691. _shape: Vector3[];
  86692. /**
  86693. * flat array of model UVs (internal use)
  86694. * @hidden
  86695. */
  86696. _shapeUV: number[];
  86697. /**
  86698. * length of the shape in the model indices array (internal use)
  86699. * @hidden
  86700. */
  86701. _indicesLength: number;
  86702. /**
  86703. * Custom position function (internal use)
  86704. * @hidden
  86705. */
  86706. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86707. /**
  86708. * Custom vertex function (internal use)
  86709. * @hidden
  86710. */
  86711. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86712. /**
  86713. * 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.
  86714. * SPS internal tool, don't use it manually.
  86715. * @hidden
  86716. */
  86717. 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>);
  86718. }
  86719. /**
  86720. * Represents a Depth Sorted Particle in the solid particle system.
  86721. */
  86722. export class DepthSortedParticle {
  86723. /**
  86724. * Index of the particle in the "indices" array
  86725. */
  86726. ind: number;
  86727. /**
  86728. * Length of the particle shape in the "indices" array
  86729. */
  86730. indicesLength: number;
  86731. /**
  86732. * Squared distance from the particle to the camera
  86733. */
  86734. sqDistance: number;
  86735. }
  86736. }
  86737. declare module BABYLON {
  86738. /**
  86739. * @hidden
  86740. */
  86741. export class _MeshCollisionData {
  86742. _checkCollisions: boolean;
  86743. _collisionMask: number;
  86744. _collisionGroup: number;
  86745. _collider: Nullable<Collider>;
  86746. _oldPositionForCollisions: Vector3;
  86747. _diffPositionForCollisions: Vector3;
  86748. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86749. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86750. }
  86751. }
  86752. declare module BABYLON {
  86753. /** @hidden */
  86754. class _FacetDataStorage {
  86755. facetPositions: Vector3[];
  86756. facetNormals: Vector3[];
  86757. facetPartitioning: number[][];
  86758. facetNb: number;
  86759. partitioningSubdivisions: number;
  86760. partitioningBBoxRatio: number;
  86761. facetDataEnabled: boolean;
  86762. facetParameters: any;
  86763. bbSize: Vector3;
  86764. subDiv: {
  86765. max: number;
  86766. X: number;
  86767. Y: number;
  86768. Z: number;
  86769. };
  86770. facetDepthSort: boolean;
  86771. facetDepthSortEnabled: boolean;
  86772. depthSortedIndices: IndicesArray;
  86773. depthSortedFacets: {
  86774. ind: number;
  86775. sqDistance: number;
  86776. }[];
  86777. facetDepthSortFunction: (f1: {
  86778. ind: number;
  86779. sqDistance: number;
  86780. }, f2: {
  86781. ind: number;
  86782. sqDistance: number;
  86783. }) => number;
  86784. facetDepthSortFrom: Vector3;
  86785. facetDepthSortOrigin: Vector3;
  86786. invertedMatrix: Matrix;
  86787. }
  86788. /**
  86789. * @hidden
  86790. **/
  86791. class _InternalAbstractMeshDataInfo {
  86792. _hasVertexAlpha: boolean;
  86793. _useVertexColors: boolean;
  86794. _numBoneInfluencers: number;
  86795. _applyFog: boolean;
  86796. _receiveShadows: boolean;
  86797. _facetData: _FacetDataStorage;
  86798. _visibility: number;
  86799. _skeleton: Nullable<Skeleton>;
  86800. _layerMask: number;
  86801. _computeBonesUsingShaders: boolean;
  86802. _isActive: boolean;
  86803. _onlyForInstances: boolean;
  86804. _isActiveIntermediate: boolean;
  86805. _onlyForInstancesIntermediate: boolean;
  86806. }
  86807. /**
  86808. * Class used to store all common mesh properties
  86809. */
  86810. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  86811. /** No occlusion */
  86812. static OCCLUSION_TYPE_NONE: number;
  86813. /** Occlusion set to optimisitic */
  86814. static OCCLUSION_TYPE_OPTIMISTIC: number;
  86815. /** Occlusion set to strict */
  86816. static OCCLUSION_TYPE_STRICT: number;
  86817. /** Use an accurante occlusion algorithm */
  86818. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  86819. /** Use a conservative occlusion algorithm */
  86820. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  86821. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86822. * Test order :
  86823. * Is the bounding sphere outside the frustum ?
  86824. * If not, are the bounding box vertices outside the frustum ?
  86825. * It not, then the cullable object is in the frustum.
  86826. */
  86827. static readonly CULLINGSTRATEGY_STANDARD: number;
  86828. /** Culling strategy : Bounding Sphere Only.
  86829. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86830. * It's also less accurate than the standard because some not visible objects can still be selected.
  86831. * Test : is the bounding sphere outside the frustum ?
  86832. * If not, then the cullable object is in the frustum.
  86833. */
  86834. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86835. /** Culling strategy : Optimistic Inclusion.
  86836. * This in an inclusion test first, then the standard exclusion test.
  86837. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86838. * 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.
  86839. * Anyway, it's as accurate as the standard strategy.
  86840. * Test :
  86841. * Is the cullable object bounding sphere center in the frustum ?
  86842. * If not, apply the default culling strategy.
  86843. */
  86844. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86845. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86846. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86847. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86848. * 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.
  86849. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86850. * Test :
  86851. * Is the cullable object bounding sphere center in the frustum ?
  86852. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86853. */
  86854. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86855. /**
  86856. * No billboard
  86857. */
  86858. static readonly BILLBOARDMODE_NONE: number;
  86859. /** Billboard on X axis */
  86860. static readonly BILLBOARDMODE_X: number;
  86861. /** Billboard on Y axis */
  86862. static readonly BILLBOARDMODE_Y: number;
  86863. /** Billboard on Z axis */
  86864. static readonly BILLBOARDMODE_Z: number;
  86865. /** Billboard on all axes */
  86866. static readonly BILLBOARDMODE_ALL: number;
  86867. /** @hidden */
  86868. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  86869. /**
  86870. * The culling strategy to use to check whether the mesh must be rendered or not.
  86871. * This value can be changed at any time and will be used on the next render mesh selection.
  86872. * The possible values are :
  86873. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86874. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86875. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86876. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86877. * Please read each static variable documentation to get details about the culling process.
  86878. * */
  86879. cullingStrategy: number;
  86880. /**
  86881. * Gets the number of facets in the mesh
  86882. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86883. */
  86884. readonly facetNb: number;
  86885. /**
  86886. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  86887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86888. */
  86889. partitioningSubdivisions: number;
  86890. /**
  86891. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  86892. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  86893. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86894. */
  86895. partitioningBBoxRatio: number;
  86896. /**
  86897. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  86898. * Works only for updatable meshes.
  86899. * Doesn't work with multi-materials
  86900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86901. */
  86902. mustDepthSortFacets: boolean;
  86903. /**
  86904. * The location (Vector3) where the facet depth sort must be computed from.
  86905. * By default, the active camera position.
  86906. * Used only when facet depth sort is enabled
  86907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86908. */
  86909. facetDepthSortFrom: Vector3;
  86910. /**
  86911. * gets a boolean indicating if facetData is enabled
  86912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86913. */
  86914. readonly isFacetDataEnabled: boolean;
  86915. /** @hidden */
  86916. _updateNonUniformScalingState(value: boolean): boolean;
  86917. /**
  86918. * An event triggered when this mesh collides with another one
  86919. */
  86920. onCollideObservable: Observable<AbstractMesh>;
  86921. /** Set a function to call when this mesh collides with another one */
  86922. onCollide: () => void;
  86923. /**
  86924. * An event triggered when the collision's position changes
  86925. */
  86926. onCollisionPositionChangeObservable: Observable<Vector3>;
  86927. /** Set a function to call when the collision's position changes */
  86928. onCollisionPositionChange: () => void;
  86929. /**
  86930. * An event triggered when material is changed
  86931. */
  86932. onMaterialChangedObservable: Observable<AbstractMesh>;
  86933. /**
  86934. * Gets or sets the orientation for POV movement & rotation
  86935. */
  86936. definedFacingForward: boolean;
  86937. /** @hidden */
  86938. _occlusionQuery: Nullable<WebGLQuery>;
  86939. /** @hidden */
  86940. _renderingGroup: Nullable<RenderingGroup>;
  86941. /**
  86942. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86943. */
  86944. /**
  86945. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86946. */
  86947. visibility: number;
  86948. /** Gets or sets the alpha index used to sort transparent meshes
  86949. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  86950. */
  86951. alphaIndex: number;
  86952. /**
  86953. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  86954. */
  86955. isVisible: boolean;
  86956. /**
  86957. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86958. */
  86959. isPickable: boolean;
  86960. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  86961. showSubMeshesBoundingBox: boolean;
  86962. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  86963. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  86964. */
  86965. isBlocker: boolean;
  86966. /**
  86967. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  86968. */
  86969. enablePointerMoveEvents: boolean;
  86970. /**
  86971. * Specifies the rendering group id for this mesh (0 by default)
  86972. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86973. */
  86974. renderingGroupId: number;
  86975. private _material;
  86976. /** Gets or sets current material */
  86977. material: Nullable<Material>;
  86978. /**
  86979. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  86980. * @see http://doc.babylonjs.com/babylon101/shadows
  86981. */
  86982. receiveShadows: boolean;
  86983. /** Defines color to use when rendering outline */
  86984. outlineColor: Color3;
  86985. /** Define width to use when rendering outline */
  86986. outlineWidth: number;
  86987. /** Defines color to use when rendering overlay */
  86988. overlayColor: Color3;
  86989. /** Defines alpha to use when rendering overlay */
  86990. overlayAlpha: number;
  86991. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  86992. hasVertexAlpha: boolean;
  86993. /** 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) */
  86994. useVertexColors: boolean;
  86995. /**
  86996. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  86997. */
  86998. computeBonesUsingShaders: boolean;
  86999. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87000. numBoneInfluencers: number;
  87001. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87002. applyFog: boolean;
  87003. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87004. useOctreeForRenderingSelection: boolean;
  87005. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87006. useOctreeForPicking: boolean;
  87007. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87008. useOctreeForCollisions: boolean;
  87009. /**
  87010. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87011. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87012. */
  87013. layerMask: number;
  87014. /**
  87015. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87016. */
  87017. alwaysSelectAsActiveMesh: boolean;
  87018. /**
  87019. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87020. */
  87021. doNotSyncBoundingInfo: boolean;
  87022. /**
  87023. * Gets or sets the current action manager
  87024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87025. */
  87026. actionManager: Nullable<AbstractActionManager>;
  87027. private _meshCollisionData;
  87028. /**
  87029. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87030. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87031. */
  87032. ellipsoid: Vector3;
  87033. /**
  87034. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87036. */
  87037. ellipsoidOffset: Vector3;
  87038. /**
  87039. * Gets or sets a collision mask used to mask collisions (default is -1).
  87040. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87041. */
  87042. collisionMask: number;
  87043. /**
  87044. * Gets or sets the current collision group mask (-1 by default).
  87045. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87046. */
  87047. collisionGroup: number;
  87048. /**
  87049. * Defines edge width used when edgesRenderer is enabled
  87050. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87051. */
  87052. edgesWidth: number;
  87053. /**
  87054. * Defines edge color used when edgesRenderer is enabled
  87055. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87056. */
  87057. edgesColor: Color4;
  87058. /** @hidden */
  87059. _edgesRenderer: Nullable<IEdgesRenderer>;
  87060. /** @hidden */
  87061. _masterMesh: Nullable<AbstractMesh>;
  87062. /** @hidden */
  87063. _boundingInfo: Nullable<BoundingInfo>;
  87064. /** @hidden */
  87065. _renderId: number;
  87066. /**
  87067. * Gets or sets the list of subMeshes
  87068. * @see http://doc.babylonjs.com/how_to/multi_materials
  87069. */
  87070. subMeshes: SubMesh[];
  87071. /** @hidden */
  87072. _intersectionsInProgress: AbstractMesh[];
  87073. /** @hidden */
  87074. _unIndexed: boolean;
  87075. /** @hidden */
  87076. _lightSources: Light[];
  87077. /** Gets the list of lights affecting that mesh */
  87078. readonly lightSources: Light[];
  87079. /** @hidden */
  87080. readonly _positions: Nullable<Vector3[]>;
  87081. /** @hidden */
  87082. _waitingData: {
  87083. lods: Nullable<any>;
  87084. actions: Nullable<any>;
  87085. freezeWorldMatrix: Nullable<boolean>;
  87086. };
  87087. /** @hidden */
  87088. _bonesTransformMatrices: Nullable<Float32Array>;
  87089. /**
  87090. * Gets or sets a skeleton to apply skining transformations
  87091. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87092. */
  87093. skeleton: Nullable<Skeleton>;
  87094. /**
  87095. * An event triggered when the mesh is rebuilt.
  87096. */
  87097. onRebuildObservable: Observable<AbstractMesh>;
  87098. /**
  87099. * Creates a new AbstractMesh
  87100. * @param name defines the name of the mesh
  87101. * @param scene defines the hosting scene
  87102. */
  87103. constructor(name: string, scene?: Nullable<Scene>);
  87104. /**
  87105. * Returns the string "AbstractMesh"
  87106. * @returns "AbstractMesh"
  87107. */
  87108. getClassName(): string;
  87109. /**
  87110. * Gets a string representation of the current mesh
  87111. * @param fullDetails defines a boolean indicating if full details must be included
  87112. * @returns a string representation of the current mesh
  87113. */
  87114. toString(fullDetails?: boolean): string;
  87115. /**
  87116. * @hidden
  87117. */
  87118. protected _getEffectiveParent(): Nullable<Node>;
  87119. /** @hidden */
  87120. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87121. /** @hidden */
  87122. _rebuild(): void;
  87123. /** @hidden */
  87124. _resyncLightSources(): void;
  87125. /** @hidden */
  87126. _resyncLighSource(light: Light): void;
  87127. /** @hidden */
  87128. _unBindEffect(): void;
  87129. /** @hidden */
  87130. _removeLightSource(light: Light): void;
  87131. private _markSubMeshesAsDirty;
  87132. /** @hidden */
  87133. _markSubMeshesAsLightDirty(): void;
  87134. /** @hidden */
  87135. _markSubMeshesAsAttributesDirty(): void;
  87136. /** @hidden */
  87137. _markSubMeshesAsMiscDirty(): void;
  87138. /**
  87139. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87140. */
  87141. scaling: Vector3;
  87142. /**
  87143. * Returns true if the mesh is blocked. Implemented by child classes
  87144. */
  87145. readonly isBlocked: boolean;
  87146. /**
  87147. * Returns the mesh itself by default. Implemented by child classes
  87148. * @param camera defines the camera to use to pick the right LOD level
  87149. * @returns the currentAbstractMesh
  87150. */
  87151. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87152. /**
  87153. * Returns 0 by default. Implemented by child classes
  87154. * @returns an integer
  87155. */
  87156. getTotalVertices(): number;
  87157. /**
  87158. * Returns a positive integer : the total number of indices in this mesh geometry.
  87159. * @returns the numner of indices or zero if the mesh has no geometry.
  87160. */
  87161. getTotalIndices(): number;
  87162. /**
  87163. * Returns null by default. Implemented by child classes
  87164. * @returns null
  87165. */
  87166. getIndices(): Nullable<IndicesArray>;
  87167. /**
  87168. * Returns the array of the requested vertex data kind. Implemented by child classes
  87169. * @param kind defines the vertex data kind to use
  87170. * @returns null
  87171. */
  87172. getVerticesData(kind: string): Nullable<FloatArray>;
  87173. /**
  87174. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87175. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87176. * Note that a new underlying VertexBuffer object is created each call.
  87177. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87178. * @param kind defines vertex data kind:
  87179. * * VertexBuffer.PositionKind
  87180. * * VertexBuffer.UVKind
  87181. * * VertexBuffer.UV2Kind
  87182. * * VertexBuffer.UV3Kind
  87183. * * VertexBuffer.UV4Kind
  87184. * * VertexBuffer.UV5Kind
  87185. * * VertexBuffer.UV6Kind
  87186. * * VertexBuffer.ColorKind
  87187. * * VertexBuffer.MatricesIndicesKind
  87188. * * VertexBuffer.MatricesIndicesExtraKind
  87189. * * VertexBuffer.MatricesWeightsKind
  87190. * * VertexBuffer.MatricesWeightsExtraKind
  87191. * @param data defines the data source
  87192. * @param updatable defines if the data must be flagged as updatable (or static)
  87193. * @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
  87194. * @returns the current mesh
  87195. */
  87196. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87197. /**
  87198. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87199. * If the mesh has no geometry, it is simply returned as it is.
  87200. * @param kind defines vertex data kind:
  87201. * * VertexBuffer.PositionKind
  87202. * * VertexBuffer.UVKind
  87203. * * VertexBuffer.UV2Kind
  87204. * * VertexBuffer.UV3Kind
  87205. * * VertexBuffer.UV4Kind
  87206. * * VertexBuffer.UV5Kind
  87207. * * VertexBuffer.UV6Kind
  87208. * * VertexBuffer.ColorKind
  87209. * * VertexBuffer.MatricesIndicesKind
  87210. * * VertexBuffer.MatricesIndicesExtraKind
  87211. * * VertexBuffer.MatricesWeightsKind
  87212. * * VertexBuffer.MatricesWeightsExtraKind
  87213. * @param data defines the data source
  87214. * @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
  87215. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87216. * @returns the current mesh
  87217. */
  87218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87219. /**
  87220. * Sets the mesh indices,
  87221. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87222. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87223. * @param totalVertices Defines the total number of vertices
  87224. * @returns the current mesh
  87225. */
  87226. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87227. /**
  87228. * Gets a boolean indicating if specific vertex data is present
  87229. * @param kind defines the vertex data kind to use
  87230. * @returns true is data kind is present
  87231. */
  87232. isVerticesDataPresent(kind: string): boolean;
  87233. /**
  87234. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  87235. * @returns a BoundingInfo
  87236. */
  87237. getBoundingInfo(): BoundingInfo;
  87238. /**
  87239. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87240. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87241. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87242. * @returns the current mesh
  87243. */
  87244. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  87245. /**
  87246. * Overwrite the current bounding info
  87247. * @param boundingInfo defines the new bounding info
  87248. * @returns the current mesh
  87249. */
  87250. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87251. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87252. readonly useBones: boolean;
  87253. /** @hidden */
  87254. _preActivate(): void;
  87255. /** @hidden */
  87256. _preActivateForIntermediateRendering(renderId: number): void;
  87257. /** @hidden */
  87258. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87259. /** @hidden */
  87260. _postActivate(): void;
  87261. /** @hidden */
  87262. _freeze(): void;
  87263. /** @hidden */
  87264. _unFreeze(): void;
  87265. /**
  87266. * Gets the current world matrix
  87267. * @returns a Matrix
  87268. */
  87269. getWorldMatrix(): Matrix;
  87270. /** @hidden */
  87271. _getWorldMatrixDeterminant(): number;
  87272. /**
  87273. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87274. */
  87275. readonly isAnInstance: boolean;
  87276. /**
  87277. * Perform relative position change from the point of view of behind the front of the mesh.
  87278. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87279. * Supports definition of mesh facing forward or backward
  87280. * @param amountRight defines the distance on the right axis
  87281. * @param amountUp defines the distance on the up axis
  87282. * @param amountForward defines the distance on the forward axis
  87283. * @returns the current mesh
  87284. */
  87285. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87286. /**
  87287. * Calculate relative position change from the point of view of behind the front of the mesh.
  87288. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87289. * Supports definition of mesh facing forward or backward
  87290. * @param amountRight defines the distance on the right axis
  87291. * @param amountUp defines the distance on the up axis
  87292. * @param amountForward defines the distance on the forward axis
  87293. * @returns the new displacement vector
  87294. */
  87295. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87296. /**
  87297. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87298. * Supports definition of mesh facing forward or backward
  87299. * @param flipBack defines the flip
  87300. * @param twirlClockwise defines the twirl
  87301. * @param tiltRight defines the tilt
  87302. * @returns the current mesh
  87303. */
  87304. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87305. /**
  87306. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87307. * Supports definition of mesh facing forward or backward.
  87308. * @param flipBack defines the flip
  87309. * @param twirlClockwise defines the twirl
  87310. * @param tiltRight defines the tilt
  87311. * @returns the new rotation vector
  87312. */
  87313. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87314. /**
  87315. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87316. * This means the mesh underlying bounding box and sphere are recomputed.
  87317. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87318. * @returns the current mesh
  87319. */
  87320. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87321. /** @hidden */
  87322. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87323. /** @hidden */
  87324. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87325. /** @hidden */
  87326. _updateBoundingInfo(): AbstractMesh;
  87327. /** @hidden */
  87328. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87329. /** @hidden */
  87330. protected _afterComputeWorldMatrix(): void;
  87331. /** @hidden */
  87332. readonly _effectiveMesh: AbstractMesh;
  87333. /**
  87334. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87335. * A mesh is in the frustum if its bounding box intersects the frustum
  87336. * @param frustumPlanes defines the frustum to test
  87337. * @returns true if the mesh is in the frustum planes
  87338. */
  87339. isInFrustum(frustumPlanes: Plane[]): boolean;
  87340. /**
  87341. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87342. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87343. * @param frustumPlanes defines the frustum to test
  87344. * @returns true if the mesh is completely in the frustum planes
  87345. */
  87346. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87347. /**
  87348. * True if the mesh intersects another mesh or a SolidParticle object
  87349. * @param mesh defines a target mesh or SolidParticle to test
  87350. * @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)
  87351. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87352. * @returns true if there is an intersection
  87353. */
  87354. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87355. /**
  87356. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87357. * @param point defines the point to test
  87358. * @returns true if there is an intersection
  87359. */
  87360. intersectsPoint(point: Vector3): boolean;
  87361. /**
  87362. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87364. */
  87365. checkCollisions: boolean;
  87366. /**
  87367. * Gets Collider object used to compute collisions (not physics)
  87368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87369. */
  87370. readonly collider: Nullable<Collider>;
  87371. /**
  87372. * Move the mesh using collision engine
  87373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87374. * @param displacement defines the requested displacement vector
  87375. * @returns the current mesh
  87376. */
  87377. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87378. private _onCollisionPositionChange;
  87379. /** @hidden */
  87380. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87381. /** @hidden */
  87382. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87383. /** @hidden */
  87384. _checkCollision(collider: Collider): AbstractMesh;
  87385. /** @hidden */
  87386. _generatePointsArray(): boolean;
  87387. /**
  87388. * Checks if the passed Ray intersects with the mesh
  87389. * @param ray defines the ray to use
  87390. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87391. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87392. * @returns the picking info
  87393. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87394. */
  87395. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87396. /**
  87397. * Clones the current mesh
  87398. * @param name defines the mesh name
  87399. * @param newParent defines the new mesh parent
  87400. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87401. * @returns the new mesh
  87402. */
  87403. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87404. /**
  87405. * Disposes all the submeshes of the current meshnp
  87406. * @returns the current mesh
  87407. */
  87408. releaseSubMeshes(): AbstractMesh;
  87409. /**
  87410. * Releases resources associated with this abstract mesh.
  87411. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87412. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87413. */
  87414. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87415. /**
  87416. * Adds the passed mesh as a child to the current mesh
  87417. * @param mesh defines the child mesh
  87418. * @returns the current mesh
  87419. */
  87420. addChild(mesh: AbstractMesh): AbstractMesh;
  87421. /**
  87422. * Removes the passed mesh from the current mesh children list
  87423. * @param mesh defines the child mesh
  87424. * @returns the current mesh
  87425. */
  87426. removeChild(mesh: AbstractMesh): AbstractMesh;
  87427. /** @hidden */
  87428. private _initFacetData;
  87429. /**
  87430. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87431. * This method can be called within the render loop.
  87432. * 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
  87433. * @returns the current mesh
  87434. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87435. */
  87436. updateFacetData(): AbstractMesh;
  87437. /**
  87438. * Returns the facetLocalNormals array.
  87439. * The normals are expressed in the mesh local spac
  87440. * @returns an array of Vector3
  87441. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87442. */
  87443. getFacetLocalNormals(): Vector3[];
  87444. /**
  87445. * Returns the facetLocalPositions array.
  87446. * The facet positions are expressed in the mesh local space
  87447. * @returns an array of Vector3
  87448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87449. */
  87450. getFacetLocalPositions(): Vector3[];
  87451. /**
  87452. * Returns the facetLocalPartioning array
  87453. * @returns an array of array of numbers
  87454. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87455. */
  87456. getFacetLocalPartitioning(): number[][];
  87457. /**
  87458. * Returns the i-th facet position in the world system.
  87459. * This method allocates a new Vector3 per call
  87460. * @param i defines the facet index
  87461. * @returns a new Vector3
  87462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87463. */
  87464. getFacetPosition(i: number): Vector3;
  87465. /**
  87466. * Sets the reference Vector3 with the i-th facet position in the world system
  87467. * @param i defines the facet index
  87468. * @param ref defines the target vector
  87469. * @returns the current mesh
  87470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87471. */
  87472. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87473. /**
  87474. * Returns the i-th facet normal in the world system.
  87475. * This method allocates a new Vector3 per call
  87476. * @param i defines the facet index
  87477. * @returns a new Vector3
  87478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87479. */
  87480. getFacetNormal(i: number): Vector3;
  87481. /**
  87482. * Sets the reference Vector3 with the i-th facet normal in the world system
  87483. * @param i defines the facet index
  87484. * @param ref defines the target vector
  87485. * @returns the current mesh
  87486. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87487. */
  87488. getFacetNormalToRef(i: number, ref: Vector3): this;
  87489. /**
  87490. * 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)
  87491. * @param x defines x coordinate
  87492. * @param y defines y coordinate
  87493. * @param z defines z coordinate
  87494. * @returns the array of facet indexes
  87495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87496. */
  87497. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87498. /**
  87499. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87500. * @param projected sets as the (x,y,z) world projection on the facet
  87501. * @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
  87502. * @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
  87503. * @param x defines x coordinate
  87504. * @param y defines y coordinate
  87505. * @param z defines z coordinate
  87506. * @returns the face index if found (or null instead)
  87507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87508. */
  87509. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87510. /**
  87511. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87512. * @param projected sets as the (x,y,z) local projection on the facet
  87513. * @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
  87514. * @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
  87515. * @param x defines x coordinate
  87516. * @param y defines y coordinate
  87517. * @param z defines z coordinate
  87518. * @returns the face index if found (or null instead)
  87519. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87520. */
  87521. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87522. /**
  87523. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87524. * @returns the parameters
  87525. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87526. */
  87527. getFacetDataParameters(): any;
  87528. /**
  87529. * Disables the feature FacetData and frees the related memory
  87530. * @returns the current mesh
  87531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87532. */
  87533. disableFacetData(): AbstractMesh;
  87534. /**
  87535. * Updates the AbstractMesh indices array
  87536. * @param indices defines the data source
  87537. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87538. * @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)
  87539. * @returns the current mesh
  87540. */
  87541. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87542. /**
  87543. * Creates new normals data for the mesh
  87544. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87545. * @returns the current mesh
  87546. */
  87547. createNormals(updatable: boolean): AbstractMesh;
  87548. /**
  87549. * Align the mesh with a normal
  87550. * @param normal defines the normal to use
  87551. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87552. * @returns the current mesh
  87553. */
  87554. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87555. /** @hidden */
  87556. _checkOcclusionQuery(): boolean;
  87557. /**
  87558. * Disables the mesh edge rendering mode
  87559. * @returns the currentAbstractMesh
  87560. */
  87561. disableEdgesRendering(): AbstractMesh;
  87562. /**
  87563. * Enables the edge rendering mode on the mesh.
  87564. * This mode makes the mesh edges visible
  87565. * @param epsilon defines the maximal distance between two angles to detect a face
  87566. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87567. * @returns the currentAbstractMesh
  87568. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87569. */
  87570. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87571. }
  87572. }
  87573. declare module BABYLON {
  87574. /**
  87575. * Interface used to define ActionEvent
  87576. */
  87577. export interface IActionEvent {
  87578. /** The mesh or sprite that triggered the action */
  87579. source: any;
  87580. /** The X mouse cursor position at the time of the event */
  87581. pointerX: number;
  87582. /** The Y mouse cursor position at the time of the event */
  87583. pointerY: number;
  87584. /** The mesh that is currently pointed at (can be null) */
  87585. meshUnderPointer: Nullable<AbstractMesh>;
  87586. /** the original (browser) event that triggered the ActionEvent */
  87587. sourceEvent?: any;
  87588. /** additional data for the event */
  87589. additionalData?: any;
  87590. }
  87591. /**
  87592. * ActionEvent is the event being sent when an action is triggered.
  87593. */
  87594. export class ActionEvent implements IActionEvent {
  87595. /** The mesh or sprite that triggered the action */
  87596. source: any;
  87597. /** The X mouse cursor position at the time of the event */
  87598. pointerX: number;
  87599. /** The Y mouse cursor position at the time of the event */
  87600. pointerY: number;
  87601. /** The mesh that is currently pointed at (can be null) */
  87602. meshUnderPointer: Nullable<AbstractMesh>;
  87603. /** the original (browser) event that triggered the ActionEvent */
  87604. sourceEvent?: any;
  87605. /** additional data for the event */
  87606. additionalData?: any;
  87607. /**
  87608. * Creates a new ActionEvent
  87609. * @param source The mesh or sprite that triggered the action
  87610. * @param pointerX The X mouse cursor position at the time of the event
  87611. * @param pointerY The Y mouse cursor position at the time of the event
  87612. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87613. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87614. * @param additionalData additional data for the event
  87615. */
  87616. constructor(
  87617. /** The mesh or sprite that triggered the action */
  87618. source: any,
  87619. /** The X mouse cursor position at the time of the event */
  87620. pointerX: number,
  87621. /** The Y mouse cursor position at the time of the event */
  87622. pointerY: number,
  87623. /** The mesh that is currently pointed at (can be null) */
  87624. meshUnderPointer: Nullable<AbstractMesh>,
  87625. /** the original (browser) event that triggered the ActionEvent */
  87626. sourceEvent?: any,
  87627. /** additional data for the event */
  87628. additionalData?: any);
  87629. /**
  87630. * Helper function to auto-create an ActionEvent from a source mesh.
  87631. * @param source The source mesh that triggered the event
  87632. * @param evt The original (browser) event
  87633. * @param additionalData additional data for the event
  87634. * @returns the new ActionEvent
  87635. */
  87636. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87637. /**
  87638. * Helper function to auto-create an ActionEvent from a source sprite
  87639. * @param source The source sprite that triggered the event
  87640. * @param scene Scene associated with the sprite
  87641. * @param evt The original (browser) event
  87642. * @param additionalData additional data for the event
  87643. * @returns the new ActionEvent
  87644. */
  87645. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87646. /**
  87647. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87648. * @param scene the scene where the event occurred
  87649. * @param evt The original (browser) event
  87650. * @returns the new ActionEvent
  87651. */
  87652. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87653. /**
  87654. * Helper function to auto-create an ActionEvent from a primitive
  87655. * @param prim defines the target primitive
  87656. * @param pointerPos defines the pointer position
  87657. * @param evt The original (browser) event
  87658. * @param additionalData additional data for the event
  87659. * @returns the new ActionEvent
  87660. */
  87661. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87662. }
  87663. }
  87664. declare module BABYLON {
  87665. /**
  87666. * Abstract class used to decouple action Manager from scene and meshes.
  87667. * Do not instantiate.
  87668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87669. */
  87670. export abstract class AbstractActionManager implements IDisposable {
  87671. /** Gets the list of active triggers */
  87672. static Triggers: {
  87673. [key: string]: number;
  87674. };
  87675. /** Gets the cursor to use when hovering items */
  87676. hoverCursor: string;
  87677. /** Gets the list of actions */
  87678. actions: IAction[];
  87679. /**
  87680. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87681. */
  87682. isRecursive: boolean;
  87683. /**
  87684. * Releases all associated resources
  87685. */
  87686. abstract dispose(): void;
  87687. /**
  87688. * Does this action manager has pointer triggers
  87689. */
  87690. abstract readonly hasPointerTriggers: boolean;
  87691. /**
  87692. * Does this action manager has pick triggers
  87693. */
  87694. abstract readonly hasPickTriggers: boolean;
  87695. /**
  87696. * Process a specific trigger
  87697. * @param trigger defines the trigger to process
  87698. * @param evt defines the event details to be processed
  87699. */
  87700. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87701. /**
  87702. * Does this action manager handles actions of any of the given triggers
  87703. * @param triggers defines the triggers to be tested
  87704. * @return a boolean indicating whether one (or more) of the triggers is handled
  87705. */
  87706. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87707. /**
  87708. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87709. * speed.
  87710. * @param triggerA defines the trigger to be tested
  87711. * @param triggerB defines the trigger to be tested
  87712. * @return a boolean indicating whether one (or more) of the triggers is handled
  87713. */
  87714. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87715. /**
  87716. * Does this action manager handles actions of a given trigger
  87717. * @param trigger defines the trigger to be tested
  87718. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87719. * @return whether the trigger is handled
  87720. */
  87721. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87722. /**
  87723. * Serialize this manager to a JSON object
  87724. * @param name defines the property name to store this manager
  87725. * @returns a JSON representation of this manager
  87726. */
  87727. abstract serialize(name: string): any;
  87728. /**
  87729. * Registers an action to this action manager
  87730. * @param action defines the action to be registered
  87731. * @return the action amended (prepared) after registration
  87732. */
  87733. abstract registerAction(action: IAction): Nullable<IAction>;
  87734. /**
  87735. * Unregisters an action to this action manager
  87736. * @param action defines the action to be unregistered
  87737. * @return a boolean indicating whether the action has been unregistered
  87738. */
  87739. abstract unregisterAction(action: IAction): Boolean;
  87740. /**
  87741. * Does exist one action manager with at least one trigger
  87742. **/
  87743. static readonly HasTriggers: boolean;
  87744. /**
  87745. * Does exist one action manager with at least one pick trigger
  87746. **/
  87747. static readonly HasPickTriggers: boolean;
  87748. /**
  87749. * Does exist one action manager that handles actions of a given trigger
  87750. * @param trigger defines the trigger to be tested
  87751. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87752. **/
  87753. static HasSpecificTrigger(trigger: number): boolean;
  87754. }
  87755. }
  87756. declare module BABYLON {
  87757. /**
  87758. * Defines how a node can be built from a string name.
  87759. */
  87760. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87761. /**
  87762. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87763. */
  87764. export class Node implements IBehaviorAware<Node> {
  87765. /** @hidden */
  87766. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87767. private static _NodeConstructors;
  87768. /**
  87769. * Add a new node constructor
  87770. * @param type defines the type name of the node to construct
  87771. * @param constructorFunc defines the constructor function
  87772. */
  87773. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87774. /**
  87775. * Returns a node constructor based on type name
  87776. * @param type defines the type name
  87777. * @param name defines the new node name
  87778. * @param scene defines the hosting scene
  87779. * @param options defines optional options to transmit to constructors
  87780. * @returns the new constructor or null
  87781. */
  87782. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87783. /**
  87784. * Gets or sets the name of the node
  87785. */
  87786. name: string;
  87787. /**
  87788. * Gets or sets the id of the node
  87789. */
  87790. id: string;
  87791. /**
  87792. * Gets or sets the unique id of the node
  87793. */
  87794. uniqueId: number;
  87795. /**
  87796. * Gets or sets a string used to store user defined state for the node
  87797. */
  87798. state: string;
  87799. /**
  87800. * Gets or sets an object used to store user defined information for the node
  87801. */
  87802. metadata: any;
  87803. /**
  87804. * For internal use only. Please do not use.
  87805. */
  87806. reservedDataStore: any;
  87807. /**
  87808. * List of inspectable custom properties (used by the Inspector)
  87809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87810. */
  87811. inspectableCustomProperties: IInspectable[];
  87812. /**
  87813. * Gets or sets a boolean used to define if the node must be serialized
  87814. */
  87815. doNotSerialize: boolean;
  87816. /** @hidden */
  87817. _isDisposed: boolean;
  87818. /**
  87819. * Gets a list of Animations associated with the node
  87820. */
  87821. animations: Animation[];
  87822. protected _ranges: {
  87823. [name: string]: Nullable<AnimationRange>;
  87824. };
  87825. /**
  87826. * Callback raised when the node is ready to be used
  87827. */
  87828. onReady: Nullable<(node: Node) => void>;
  87829. private _isEnabled;
  87830. private _isParentEnabled;
  87831. private _isReady;
  87832. /** @hidden */
  87833. _currentRenderId: number;
  87834. private _parentUpdateId;
  87835. /** @hidden */
  87836. _childUpdateId: number;
  87837. /** @hidden */
  87838. _waitingParentId: Nullable<string>;
  87839. /** @hidden */
  87840. _scene: Scene;
  87841. /** @hidden */
  87842. _cache: any;
  87843. private _parentNode;
  87844. private _children;
  87845. /** @hidden */
  87846. _worldMatrix: Matrix;
  87847. /** @hidden */
  87848. _worldMatrixDeterminant: number;
  87849. /** @hidden */
  87850. _worldMatrixDeterminantIsDirty: boolean;
  87851. /** @hidden */
  87852. private _sceneRootNodesIndex;
  87853. /**
  87854. * Gets a boolean indicating if the node has been disposed
  87855. * @returns true if the node was disposed
  87856. */
  87857. isDisposed(): boolean;
  87858. /**
  87859. * Gets or sets the parent of the node (without keeping the current position in the scene)
  87860. * @see https://doc.babylonjs.com/how_to/parenting
  87861. */
  87862. parent: Nullable<Node>;
  87863. private addToSceneRootNodes;
  87864. private removeFromSceneRootNodes;
  87865. private _animationPropertiesOverride;
  87866. /**
  87867. * Gets or sets the animation properties override
  87868. */
  87869. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87870. /**
  87871. * Gets a string idenfifying the name of the class
  87872. * @returns "Node" string
  87873. */
  87874. getClassName(): string;
  87875. /** @hidden */
  87876. readonly _isNode: boolean;
  87877. /**
  87878. * An event triggered when the mesh is disposed
  87879. */
  87880. onDisposeObservable: Observable<Node>;
  87881. private _onDisposeObserver;
  87882. /**
  87883. * Sets a callback that will be raised when the node will be disposed
  87884. */
  87885. onDispose: () => void;
  87886. /**
  87887. * Creates a new Node
  87888. * @param name the name and id to be given to this node
  87889. * @param scene the scene this node will be added to
  87890. * @param addToRootNodes the node will be added to scene.rootNodes
  87891. */
  87892. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  87893. /**
  87894. * Gets the scene of the node
  87895. * @returns a scene
  87896. */
  87897. getScene(): Scene;
  87898. /**
  87899. * Gets the engine of the node
  87900. * @returns a Engine
  87901. */
  87902. getEngine(): Engine;
  87903. private _behaviors;
  87904. /**
  87905. * Attach a behavior to the node
  87906. * @see http://doc.babylonjs.com/features/behaviour
  87907. * @param behavior defines the behavior to attach
  87908. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  87909. * @returns the current Node
  87910. */
  87911. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  87912. /**
  87913. * Remove an attached behavior
  87914. * @see http://doc.babylonjs.com/features/behaviour
  87915. * @param behavior defines the behavior to attach
  87916. * @returns the current Node
  87917. */
  87918. removeBehavior(behavior: Behavior<Node>): Node;
  87919. /**
  87920. * Gets the list of attached behaviors
  87921. * @see http://doc.babylonjs.com/features/behaviour
  87922. */
  87923. readonly behaviors: Behavior<Node>[];
  87924. /**
  87925. * Gets an attached behavior by name
  87926. * @param name defines the name of the behavior to look for
  87927. * @see http://doc.babylonjs.com/features/behaviour
  87928. * @returns null if behavior was not found else the requested behavior
  87929. */
  87930. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  87931. /**
  87932. * Returns the latest update of the World matrix
  87933. * @returns a Matrix
  87934. */
  87935. getWorldMatrix(): Matrix;
  87936. /** @hidden */
  87937. _getWorldMatrixDeterminant(): number;
  87938. /**
  87939. * Returns directly the latest state of the mesh World matrix.
  87940. * A Matrix is returned.
  87941. */
  87942. readonly worldMatrixFromCache: Matrix;
  87943. /** @hidden */
  87944. _initCache(): void;
  87945. /** @hidden */
  87946. updateCache(force?: boolean): void;
  87947. /** @hidden */
  87948. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87949. /** @hidden */
  87950. _updateCache(ignoreParentClass?: boolean): void;
  87951. /** @hidden */
  87952. _isSynchronized(): boolean;
  87953. /** @hidden */
  87954. _markSyncedWithParent(): void;
  87955. /** @hidden */
  87956. isSynchronizedWithParent(): boolean;
  87957. /** @hidden */
  87958. isSynchronized(): boolean;
  87959. /**
  87960. * Is this node ready to be used/rendered
  87961. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87962. * @return true if the node is ready
  87963. */
  87964. isReady(completeCheck?: boolean): boolean;
  87965. /**
  87966. * Is this node enabled?
  87967. * 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
  87968. * @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
  87969. * @return whether this node (and its parent) is enabled
  87970. */
  87971. isEnabled(checkAncestors?: boolean): boolean;
  87972. /** @hidden */
  87973. protected _syncParentEnabledState(): void;
  87974. /**
  87975. * Set the enabled state of this node
  87976. * @param value defines the new enabled state
  87977. */
  87978. setEnabled(value: boolean): void;
  87979. /**
  87980. * Is this node a descendant of the given node?
  87981. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  87982. * @param ancestor defines the parent node to inspect
  87983. * @returns a boolean indicating if this node is a descendant of the given node
  87984. */
  87985. isDescendantOf(ancestor: Node): boolean;
  87986. /** @hidden */
  87987. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  87988. /**
  87989. * Will return all nodes that have this node as ascendant
  87990. * @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
  87991. * @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
  87992. * @return all children nodes of all types
  87993. */
  87994. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  87995. /**
  87996. * Get all child-meshes of this node
  87997. * @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)
  87998. * @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
  87999. * @returns an array of AbstractMesh
  88000. */
  88001. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88002. /**
  88003. * Get all direct children of this node
  88004. * @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
  88005. * @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)
  88006. * @returns an array of Node
  88007. */
  88008. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88009. /** @hidden */
  88010. _setReady(state: boolean): void;
  88011. /**
  88012. * Get an animation by name
  88013. * @param name defines the name of the animation to look for
  88014. * @returns null if not found else the requested animation
  88015. */
  88016. getAnimationByName(name: string): Nullable<Animation>;
  88017. /**
  88018. * Creates an animation range for this node
  88019. * @param name defines the name of the range
  88020. * @param from defines the starting key
  88021. * @param to defines the end key
  88022. */
  88023. createAnimationRange(name: string, from: number, to: number): void;
  88024. /**
  88025. * Delete a specific animation range
  88026. * @param name defines the name of the range to delete
  88027. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88028. */
  88029. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88030. /**
  88031. * Get an animation range by name
  88032. * @param name defines the name of the animation range to look for
  88033. * @returns null if not found else the requested animation range
  88034. */
  88035. getAnimationRange(name: string): Nullable<AnimationRange>;
  88036. /**
  88037. * Gets the list of all animation ranges defined on this node
  88038. * @returns an array
  88039. */
  88040. getAnimationRanges(): Nullable<AnimationRange>[];
  88041. /**
  88042. * Will start the animation sequence
  88043. * @param name defines the range frames for animation sequence
  88044. * @param loop defines if the animation should loop (false by default)
  88045. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88046. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88047. * @returns the object created for this animation. If range does not exist, it will return null
  88048. */
  88049. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88050. /**
  88051. * Serialize animation ranges into a JSON compatible object
  88052. * @returns serialization object
  88053. */
  88054. serializeAnimationRanges(): any;
  88055. /**
  88056. * Computes the world matrix of the node
  88057. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88058. * @returns the world matrix
  88059. */
  88060. computeWorldMatrix(force?: boolean): Matrix;
  88061. /**
  88062. * Releases resources associated with this node.
  88063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88065. */
  88066. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88067. /**
  88068. * Parse animation range data from a serialization object and store them into a given node
  88069. * @param node defines where to store the animation ranges
  88070. * @param parsedNode defines the serialization object to read data from
  88071. * @param scene defines the hosting scene
  88072. */
  88073. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88074. /**
  88075. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88076. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88077. * @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
  88078. * @returns the new bounding vectors
  88079. */
  88080. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88081. min: Vector3;
  88082. max: Vector3;
  88083. };
  88084. }
  88085. }
  88086. declare module BABYLON {
  88087. /**
  88088. * @hidden
  88089. */
  88090. export class _IAnimationState {
  88091. key: number;
  88092. repeatCount: number;
  88093. workValue?: any;
  88094. loopMode?: number;
  88095. offsetValue?: any;
  88096. highLimitValue?: any;
  88097. }
  88098. /**
  88099. * Class used to store any kind of animation
  88100. */
  88101. export class Animation {
  88102. /**Name of the animation */
  88103. name: string;
  88104. /**Property to animate */
  88105. targetProperty: string;
  88106. /**The frames per second of the animation */
  88107. framePerSecond: number;
  88108. /**The data type of the animation */
  88109. dataType: number;
  88110. /**The loop mode of the animation */
  88111. loopMode?: number | undefined;
  88112. /**Specifies if blending should be enabled */
  88113. enableBlending?: boolean | undefined;
  88114. /**
  88115. * Use matrix interpolation instead of using direct key value when animating matrices
  88116. */
  88117. static AllowMatricesInterpolation: boolean;
  88118. /**
  88119. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88120. */
  88121. static AllowMatrixDecomposeForInterpolation: boolean;
  88122. /**
  88123. * Stores the key frames of the animation
  88124. */
  88125. private _keys;
  88126. /**
  88127. * Stores the easing function of the animation
  88128. */
  88129. private _easingFunction;
  88130. /**
  88131. * @hidden Internal use only
  88132. */
  88133. _runtimeAnimations: RuntimeAnimation[];
  88134. /**
  88135. * The set of event that will be linked to this animation
  88136. */
  88137. private _events;
  88138. /**
  88139. * Stores an array of target property paths
  88140. */
  88141. targetPropertyPath: string[];
  88142. /**
  88143. * Stores the blending speed of the animation
  88144. */
  88145. blendingSpeed: number;
  88146. /**
  88147. * Stores the animation ranges for the animation
  88148. */
  88149. private _ranges;
  88150. /**
  88151. * @hidden Internal use
  88152. */
  88153. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88154. /**
  88155. * Sets up an animation
  88156. * @param property The property to animate
  88157. * @param animationType The animation type to apply
  88158. * @param framePerSecond The frames per second of the animation
  88159. * @param easingFunction The easing function used in the animation
  88160. * @returns The created animation
  88161. */
  88162. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88163. /**
  88164. * Create and start an animation on a node
  88165. * @param name defines the name of the global animation that will be run on all nodes
  88166. * @param node defines the root node where the animation will take place
  88167. * @param targetProperty defines property to animate
  88168. * @param framePerSecond defines the number of frame per second yo use
  88169. * @param totalFrame defines the number of frames in total
  88170. * @param from defines the initial value
  88171. * @param to defines the final value
  88172. * @param loopMode defines which loop mode you want to use (off by default)
  88173. * @param easingFunction defines the easing function to use (linear by default)
  88174. * @param onAnimationEnd defines the callback to call when animation end
  88175. * @returns the animatable created for this animation
  88176. */
  88177. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88178. /**
  88179. * Create and start an animation on a node and its descendants
  88180. * @param name defines the name of the global animation that will be run on all nodes
  88181. * @param node defines the root node where the animation will take place
  88182. * @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
  88183. * @param targetProperty defines property to animate
  88184. * @param framePerSecond defines the number of frame per second to use
  88185. * @param totalFrame defines the number of frames in total
  88186. * @param from defines the initial value
  88187. * @param to defines the final value
  88188. * @param loopMode defines which loop mode you want to use (off by default)
  88189. * @param easingFunction defines the easing function to use (linear by default)
  88190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88191. * @returns the list of animatables created for all nodes
  88192. * @example https://www.babylonjs-playground.com/#MH0VLI
  88193. */
  88194. 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[]>;
  88195. /**
  88196. * Creates a new animation, merges it with the existing animations and starts it
  88197. * @param name Name of the animation
  88198. * @param node Node which contains the scene that begins the animations
  88199. * @param targetProperty Specifies which property to animate
  88200. * @param framePerSecond The frames per second of the animation
  88201. * @param totalFrame The total number of frames
  88202. * @param from The frame at the beginning of the animation
  88203. * @param to The frame at the end of the animation
  88204. * @param loopMode Specifies the loop mode of the animation
  88205. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88206. * @param onAnimationEnd Callback to run once the animation is complete
  88207. * @returns Nullable animation
  88208. */
  88209. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88210. /**
  88211. * Transition property of an host to the target Value
  88212. * @param property The property to transition
  88213. * @param targetValue The target Value of the property
  88214. * @param host The object where the property to animate belongs
  88215. * @param scene Scene used to run the animation
  88216. * @param frameRate Framerate (in frame/s) to use
  88217. * @param transition The transition type we want to use
  88218. * @param duration The duration of the animation, in milliseconds
  88219. * @param onAnimationEnd Callback trigger at the end of the animation
  88220. * @returns Nullable animation
  88221. */
  88222. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88223. /**
  88224. * Return the array of runtime animations currently using this animation
  88225. */
  88226. readonly runtimeAnimations: RuntimeAnimation[];
  88227. /**
  88228. * Specifies if any of the runtime animations are currently running
  88229. */
  88230. readonly hasRunningRuntimeAnimations: boolean;
  88231. /**
  88232. * Initializes the animation
  88233. * @param name Name of the animation
  88234. * @param targetProperty Property to animate
  88235. * @param framePerSecond The frames per second of the animation
  88236. * @param dataType The data type of the animation
  88237. * @param loopMode The loop mode of the animation
  88238. * @param enableBlending Specifies if blending should be enabled
  88239. */
  88240. constructor(
  88241. /**Name of the animation */
  88242. name: string,
  88243. /**Property to animate */
  88244. targetProperty: string,
  88245. /**The frames per second of the animation */
  88246. framePerSecond: number,
  88247. /**The data type of the animation */
  88248. dataType: number,
  88249. /**The loop mode of the animation */
  88250. loopMode?: number | undefined,
  88251. /**Specifies if blending should be enabled */
  88252. enableBlending?: boolean | undefined);
  88253. /**
  88254. * Converts the animation to a string
  88255. * @param fullDetails support for multiple levels of logging within scene loading
  88256. * @returns String form of the animation
  88257. */
  88258. toString(fullDetails?: boolean): string;
  88259. /**
  88260. * Add an event to this animation
  88261. * @param event Event to add
  88262. */
  88263. addEvent(event: AnimationEvent): void;
  88264. /**
  88265. * Remove all events found at the given frame
  88266. * @param frame The frame to remove events from
  88267. */
  88268. removeEvents(frame: number): void;
  88269. /**
  88270. * Retrieves all the events from the animation
  88271. * @returns Events from the animation
  88272. */
  88273. getEvents(): AnimationEvent[];
  88274. /**
  88275. * Creates an animation range
  88276. * @param name Name of the animation range
  88277. * @param from Starting frame of the animation range
  88278. * @param to Ending frame of the animation
  88279. */
  88280. createRange(name: string, from: number, to: number): void;
  88281. /**
  88282. * Deletes an animation range by name
  88283. * @param name Name of the animation range to delete
  88284. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88285. */
  88286. deleteRange(name: string, deleteFrames?: boolean): void;
  88287. /**
  88288. * Gets the animation range by name, or null if not defined
  88289. * @param name Name of the animation range
  88290. * @returns Nullable animation range
  88291. */
  88292. getRange(name: string): Nullable<AnimationRange>;
  88293. /**
  88294. * Gets the key frames from the animation
  88295. * @returns The key frames of the animation
  88296. */
  88297. getKeys(): Array<IAnimationKey>;
  88298. /**
  88299. * Gets the highest frame rate of the animation
  88300. * @returns Highest frame rate of the animation
  88301. */
  88302. getHighestFrame(): number;
  88303. /**
  88304. * Gets the easing function of the animation
  88305. * @returns Easing function of the animation
  88306. */
  88307. getEasingFunction(): IEasingFunction;
  88308. /**
  88309. * Sets the easing function of the animation
  88310. * @param easingFunction A custom mathematical formula for animation
  88311. */
  88312. setEasingFunction(easingFunction: EasingFunction): void;
  88313. /**
  88314. * Interpolates a scalar linearly
  88315. * @param startValue Start value of the animation curve
  88316. * @param endValue End value of the animation curve
  88317. * @param gradient Scalar amount to interpolate
  88318. * @returns Interpolated scalar value
  88319. */
  88320. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88321. /**
  88322. * Interpolates a scalar cubically
  88323. * @param startValue Start value of the animation curve
  88324. * @param outTangent End tangent of the animation
  88325. * @param endValue End value of the animation curve
  88326. * @param inTangent Start tangent of the animation curve
  88327. * @param gradient Scalar amount to interpolate
  88328. * @returns Interpolated scalar value
  88329. */
  88330. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88331. /**
  88332. * Interpolates a quaternion using a spherical linear interpolation
  88333. * @param startValue Start value of the animation curve
  88334. * @param endValue End value of the animation curve
  88335. * @param gradient Scalar amount to interpolate
  88336. * @returns Interpolated quaternion value
  88337. */
  88338. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88339. /**
  88340. * Interpolates a quaternion cubically
  88341. * @param startValue Start value of the animation curve
  88342. * @param outTangent End tangent of the animation curve
  88343. * @param endValue End value of the animation curve
  88344. * @param inTangent Start tangent of the animation curve
  88345. * @param gradient Scalar amount to interpolate
  88346. * @returns Interpolated quaternion value
  88347. */
  88348. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88349. /**
  88350. * Interpolates a Vector3 linearl
  88351. * @param startValue Start value of the animation curve
  88352. * @param endValue End value of the animation curve
  88353. * @param gradient Scalar amount to interpolate
  88354. * @returns Interpolated scalar value
  88355. */
  88356. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88357. /**
  88358. * Interpolates a Vector3 cubically
  88359. * @param startValue Start value of the animation curve
  88360. * @param outTangent End tangent of the animation
  88361. * @param endValue End value of the animation curve
  88362. * @param inTangent Start tangent of the animation curve
  88363. * @param gradient Scalar amount to interpolate
  88364. * @returns InterpolatedVector3 value
  88365. */
  88366. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88367. /**
  88368. * Interpolates a Vector2 linearly
  88369. * @param startValue Start value of the animation curve
  88370. * @param endValue End value of the animation curve
  88371. * @param gradient Scalar amount to interpolate
  88372. * @returns Interpolated Vector2 value
  88373. */
  88374. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88375. /**
  88376. * Interpolates a Vector2 cubically
  88377. * @param startValue Start value of the animation curve
  88378. * @param outTangent End tangent of the animation
  88379. * @param endValue End value of the animation curve
  88380. * @param inTangent Start tangent of the animation curve
  88381. * @param gradient Scalar amount to interpolate
  88382. * @returns Interpolated Vector2 value
  88383. */
  88384. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88385. /**
  88386. * Interpolates a size linearly
  88387. * @param startValue Start value of the animation curve
  88388. * @param endValue End value of the animation curve
  88389. * @param gradient Scalar amount to interpolate
  88390. * @returns Interpolated Size value
  88391. */
  88392. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88393. /**
  88394. * Interpolates a Color3 linearly
  88395. * @param startValue Start value of the animation curve
  88396. * @param endValue End value of the animation curve
  88397. * @param gradient Scalar amount to interpolate
  88398. * @returns Interpolated Color3 value
  88399. */
  88400. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88401. /**
  88402. * @hidden Internal use only
  88403. */
  88404. _getKeyValue(value: any): any;
  88405. /**
  88406. * @hidden Internal use only
  88407. */
  88408. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88409. /**
  88410. * Defines the function to use to interpolate matrices
  88411. * @param startValue defines the start matrix
  88412. * @param endValue defines the end matrix
  88413. * @param gradient defines the gradient between both matrices
  88414. * @param result defines an optional target matrix where to store the interpolation
  88415. * @returns the interpolated matrix
  88416. */
  88417. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88418. /**
  88419. * Makes a copy of the animation
  88420. * @returns Cloned animation
  88421. */
  88422. clone(): Animation;
  88423. /**
  88424. * Sets the key frames of the animation
  88425. * @param values The animation key frames to set
  88426. */
  88427. setKeys(values: Array<IAnimationKey>): void;
  88428. /**
  88429. * Serializes the animation to an object
  88430. * @returns Serialized object
  88431. */
  88432. serialize(): any;
  88433. /**
  88434. * Float animation type
  88435. */
  88436. private static _ANIMATIONTYPE_FLOAT;
  88437. /**
  88438. * Vector3 animation type
  88439. */
  88440. private static _ANIMATIONTYPE_VECTOR3;
  88441. /**
  88442. * Quaternion animation type
  88443. */
  88444. private static _ANIMATIONTYPE_QUATERNION;
  88445. /**
  88446. * Matrix animation type
  88447. */
  88448. private static _ANIMATIONTYPE_MATRIX;
  88449. /**
  88450. * Color3 animation type
  88451. */
  88452. private static _ANIMATIONTYPE_COLOR3;
  88453. /**
  88454. * Vector2 animation type
  88455. */
  88456. private static _ANIMATIONTYPE_VECTOR2;
  88457. /**
  88458. * Size animation type
  88459. */
  88460. private static _ANIMATIONTYPE_SIZE;
  88461. /**
  88462. * Relative Loop Mode
  88463. */
  88464. private static _ANIMATIONLOOPMODE_RELATIVE;
  88465. /**
  88466. * Cycle Loop Mode
  88467. */
  88468. private static _ANIMATIONLOOPMODE_CYCLE;
  88469. /**
  88470. * Constant Loop Mode
  88471. */
  88472. private static _ANIMATIONLOOPMODE_CONSTANT;
  88473. /**
  88474. * Get the float animation type
  88475. */
  88476. static readonly ANIMATIONTYPE_FLOAT: number;
  88477. /**
  88478. * Get the Vector3 animation type
  88479. */
  88480. static readonly ANIMATIONTYPE_VECTOR3: number;
  88481. /**
  88482. * Get the Vector2 animation type
  88483. */
  88484. static readonly ANIMATIONTYPE_VECTOR2: number;
  88485. /**
  88486. * Get the Size animation type
  88487. */
  88488. static readonly ANIMATIONTYPE_SIZE: number;
  88489. /**
  88490. * Get the Quaternion animation type
  88491. */
  88492. static readonly ANIMATIONTYPE_QUATERNION: number;
  88493. /**
  88494. * Get the Matrix animation type
  88495. */
  88496. static readonly ANIMATIONTYPE_MATRIX: number;
  88497. /**
  88498. * Get the Color3 animation type
  88499. */
  88500. static readonly ANIMATIONTYPE_COLOR3: number;
  88501. /**
  88502. * Get the Relative Loop Mode
  88503. */
  88504. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88505. /**
  88506. * Get the Cycle Loop Mode
  88507. */
  88508. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88509. /**
  88510. * Get the Constant Loop Mode
  88511. */
  88512. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88513. /** @hidden */
  88514. static _UniversalLerp(left: any, right: any, amount: number): any;
  88515. /**
  88516. * Parses an animation object and creates an animation
  88517. * @param parsedAnimation Parsed animation object
  88518. * @returns Animation object
  88519. */
  88520. static Parse(parsedAnimation: any): Animation;
  88521. /**
  88522. * Appends the serialized animations from the source animations
  88523. * @param source Source containing the animations
  88524. * @param destination Target to store the animations
  88525. */
  88526. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88527. }
  88528. }
  88529. declare module BABYLON {
  88530. /**
  88531. * Base class of all the textures in babylon.
  88532. * It groups all the common properties the materials, post process, lights... might need
  88533. * in order to make a correct use of the texture.
  88534. */
  88535. export class BaseTexture implements IAnimatable {
  88536. /**
  88537. * Default anisotropic filtering level for the application.
  88538. * It is set to 4 as a good tradeoff between perf and quality.
  88539. */
  88540. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88541. /**
  88542. * Gets or sets the unique id of the texture
  88543. */
  88544. uniqueId: number;
  88545. /**
  88546. * Define the name of the texture.
  88547. */
  88548. name: string;
  88549. /**
  88550. * Gets or sets an object used to store user defined information.
  88551. */
  88552. metadata: any;
  88553. /**
  88554. * For internal use only. Please do not use.
  88555. */
  88556. reservedDataStore: any;
  88557. private _hasAlpha;
  88558. /**
  88559. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88560. */
  88561. hasAlpha: boolean;
  88562. /**
  88563. * Defines if the alpha value should be determined via the rgb values.
  88564. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88565. */
  88566. getAlphaFromRGB: boolean;
  88567. /**
  88568. * Intensity or strength of the texture.
  88569. * It is commonly used by materials to fine tune the intensity of the texture
  88570. */
  88571. level: number;
  88572. /**
  88573. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88574. * This is part of the texture as textures usually maps to one uv set.
  88575. */
  88576. coordinatesIndex: number;
  88577. private _coordinatesMode;
  88578. /**
  88579. * How a texture is mapped.
  88580. *
  88581. * | Value | Type | Description |
  88582. * | ----- | ----------------------------------- | ----------- |
  88583. * | 0 | EXPLICIT_MODE | |
  88584. * | 1 | SPHERICAL_MODE | |
  88585. * | 2 | PLANAR_MODE | |
  88586. * | 3 | CUBIC_MODE | |
  88587. * | 4 | PROJECTION_MODE | |
  88588. * | 5 | SKYBOX_MODE | |
  88589. * | 6 | INVCUBIC_MODE | |
  88590. * | 7 | EQUIRECTANGULAR_MODE | |
  88591. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88592. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88593. */
  88594. coordinatesMode: number;
  88595. /**
  88596. * | Value | Type | Description |
  88597. * | ----- | ------------------ | ----------- |
  88598. * | 0 | CLAMP_ADDRESSMODE | |
  88599. * | 1 | WRAP_ADDRESSMODE | |
  88600. * | 2 | MIRROR_ADDRESSMODE | |
  88601. */
  88602. wrapU: number;
  88603. /**
  88604. * | Value | Type | Description |
  88605. * | ----- | ------------------ | ----------- |
  88606. * | 0 | CLAMP_ADDRESSMODE | |
  88607. * | 1 | WRAP_ADDRESSMODE | |
  88608. * | 2 | MIRROR_ADDRESSMODE | |
  88609. */
  88610. wrapV: number;
  88611. /**
  88612. * | Value | Type | Description |
  88613. * | ----- | ------------------ | ----------- |
  88614. * | 0 | CLAMP_ADDRESSMODE | |
  88615. * | 1 | WRAP_ADDRESSMODE | |
  88616. * | 2 | MIRROR_ADDRESSMODE | |
  88617. */
  88618. wrapR: number;
  88619. /**
  88620. * With compliant hardware and browser (supporting anisotropic filtering)
  88621. * this defines the level of anisotropic filtering in the texture.
  88622. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88623. */
  88624. anisotropicFilteringLevel: number;
  88625. /**
  88626. * Define if the texture is a cube texture or if false a 2d texture.
  88627. */
  88628. isCube: boolean;
  88629. /**
  88630. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88631. */
  88632. is3D: boolean;
  88633. /**
  88634. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88635. * HDR texture are usually stored in linear space.
  88636. * This only impacts the PBR and Background materials
  88637. */
  88638. gammaSpace: boolean;
  88639. /**
  88640. * Gets whether or not the texture contains RGBD data.
  88641. */
  88642. readonly isRGBD: boolean;
  88643. /**
  88644. * Is Z inverted in the texture (useful in a cube texture).
  88645. */
  88646. invertZ: boolean;
  88647. /**
  88648. * Are mip maps generated for this texture or not.
  88649. */
  88650. readonly noMipmap: boolean;
  88651. /**
  88652. * @hidden
  88653. */
  88654. lodLevelInAlpha: boolean;
  88655. /**
  88656. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88657. */
  88658. lodGenerationOffset: number;
  88659. /**
  88660. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88661. */
  88662. lodGenerationScale: number;
  88663. /**
  88664. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88665. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88666. * average roughness values.
  88667. */
  88668. linearSpecularLOD: boolean;
  88669. /**
  88670. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88671. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88672. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88673. */
  88674. irradianceTexture: Nullable<BaseTexture>;
  88675. /**
  88676. * Define if the texture is a render target.
  88677. */
  88678. isRenderTarget: boolean;
  88679. /**
  88680. * Define the unique id of the texture in the scene.
  88681. */
  88682. readonly uid: string;
  88683. /**
  88684. * Return a string representation of the texture.
  88685. * @returns the texture as a string
  88686. */
  88687. toString(): string;
  88688. /**
  88689. * Get the class name of the texture.
  88690. * @returns "BaseTexture"
  88691. */
  88692. getClassName(): string;
  88693. /**
  88694. * Define the list of animation attached to the texture.
  88695. */
  88696. animations: Animation[];
  88697. /**
  88698. * An event triggered when the texture is disposed.
  88699. */
  88700. onDisposeObservable: Observable<BaseTexture>;
  88701. private _onDisposeObserver;
  88702. /**
  88703. * Callback triggered when the texture has been disposed.
  88704. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88705. */
  88706. onDispose: () => void;
  88707. /**
  88708. * Define the current state of the loading sequence when in delayed load mode.
  88709. */
  88710. delayLoadState: number;
  88711. private _scene;
  88712. /** @hidden */
  88713. _texture: Nullable<InternalTexture>;
  88714. private _uid;
  88715. /**
  88716. * Define if the texture is preventinga material to render or not.
  88717. * If not and the texture is not ready, the engine will use a default black texture instead.
  88718. */
  88719. readonly isBlocking: boolean;
  88720. /**
  88721. * Instantiates a new BaseTexture.
  88722. * Base class of all the textures in babylon.
  88723. * It groups all the common properties the materials, post process, lights... might need
  88724. * in order to make a correct use of the texture.
  88725. * @param scene Define the scene the texture blongs to
  88726. */
  88727. constructor(scene: Nullable<Scene>);
  88728. /**
  88729. * Get the scene the texture belongs to.
  88730. * @returns the scene or null if undefined
  88731. */
  88732. getScene(): Nullable<Scene>;
  88733. /**
  88734. * Get the texture transform matrix used to offset tile the texture for istance.
  88735. * @returns the transformation matrix
  88736. */
  88737. getTextureMatrix(): Matrix;
  88738. /**
  88739. * Get the texture reflection matrix used to rotate/transform the reflection.
  88740. * @returns the reflection matrix
  88741. */
  88742. getReflectionTextureMatrix(): Matrix;
  88743. /**
  88744. * Get the underlying lower level texture from Babylon.
  88745. * @returns the insternal texture
  88746. */
  88747. getInternalTexture(): Nullable<InternalTexture>;
  88748. /**
  88749. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88750. * @returns true if ready or not blocking
  88751. */
  88752. isReadyOrNotBlocking(): boolean;
  88753. /**
  88754. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88755. * @returns true if fully ready
  88756. */
  88757. isReady(): boolean;
  88758. private _cachedSize;
  88759. /**
  88760. * Get the size of the texture.
  88761. * @returns the texture size.
  88762. */
  88763. getSize(): ISize;
  88764. /**
  88765. * Get the base size of the texture.
  88766. * It can be different from the size if the texture has been resized for POT for instance
  88767. * @returns the base size
  88768. */
  88769. getBaseSize(): ISize;
  88770. /**
  88771. * Update the sampling mode of the texture.
  88772. * Default is Trilinear mode.
  88773. *
  88774. * | Value | Type | Description |
  88775. * | ----- | ------------------ | ----------- |
  88776. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88777. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88778. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88779. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88780. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88781. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88782. * | 7 | NEAREST_LINEAR | |
  88783. * | 8 | NEAREST_NEAREST | |
  88784. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88785. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88786. * | 11 | LINEAR_LINEAR | |
  88787. * | 12 | LINEAR_NEAREST | |
  88788. *
  88789. * > _mag_: magnification filter (close to the viewer)
  88790. * > _min_: minification filter (far from the viewer)
  88791. * > _mip_: filter used between mip map levels
  88792. *@param samplingMode Define the new sampling mode of the texture
  88793. */
  88794. updateSamplingMode(samplingMode: number): void;
  88795. /**
  88796. * Scales the texture if is `canRescale()`
  88797. * @param ratio the resize factor we want to use to rescale
  88798. */
  88799. scale(ratio: number): void;
  88800. /**
  88801. * Get if the texture can rescale.
  88802. */
  88803. readonly canRescale: boolean;
  88804. /** @hidden */
  88805. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  88806. /** @hidden */
  88807. _rebuild(): void;
  88808. /**
  88809. * Triggers the load sequence in delayed load mode.
  88810. */
  88811. delayLoad(): void;
  88812. /**
  88813. * Clones the texture.
  88814. * @returns the cloned texture
  88815. */
  88816. clone(): Nullable<BaseTexture>;
  88817. /**
  88818. * Get the texture underlying type (INT, FLOAT...)
  88819. */
  88820. readonly textureType: number;
  88821. /**
  88822. * Get the texture underlying format (RGB, RGBA...)
  88823. */
  88824. readonly textureFormat: number;
  88825. /**
  88826. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  88827. * This will returns an RGBA array buffer containing either in values (0-255) or
  88828. * float values (0-1) depending of the underlying buffer type.
  88829. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  88830. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  88831. * @param buffer defines a user defined buffer to fill with data (can be null)
  88832. * @returns The Array buffer containing the pixels data.
  88833. */
  88834. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  88835. /**
  88836. * Release and destroy the underlying lower level texture aka internalTexture.
  88837. */
  88838. releaseInternalTexture(): void;
  88839. /**
  88840. * Get the polynomial representation of the texture data.
  88841. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  88842. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  88843. */
  88844. sphericalPolynomial: Nullable<SphericalPolynomial>;
  88845. /** @hidden */
  88846. readonly _lodTextureHigh: Nullable<BaseTexture>;
  88847. /** @hidden */
  88848. readonly _lodTextureMid: Nullable<BaseTexture>;
  88849. /** @hidden */
  88850. readonly _lodTextureLow: Nullable<BaseTexture>;
  88851. /**
  88852. * Dispose the texture and release its associated resources.
  88853. */
  88854. dispose(): void;
  88855. /**
  88856. * Serialize the texture into a JSON representation that can be parsed later on.
  88857. * @returns the JSON representation of the texture
  88858. */
  88859. serialize(): any;
  88860. /**
  88861. * Helper function to be called back once a list of texture contains only ready textures.
  88862. * @param textures Define the list of textures to wait for
  88863. * @param callback Define the callback triggered once the entire list will be ready
  88864. */
  88865. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  88866. }
  88867. }
  88868. declare module BABYLON {
  88869. /**
  88870. * Uniform buffer objects.
  88871. *
  88872. * Handles blocks of uniform on the GPU.
  88873. *
  88874. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88875. *
  88876. * For more information, please refer to :
  88877. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88878. */
  88879. export class UniformBuffer {
  88880. private _engine;
  88881. private _buffer;
  88882. private _data;
  88883. private _bufferData;
  88884. private _dynamic?;
  88885. private _uniformLocations;
  88886. private _uniformSizes;
  88887. private _uniformLocationPointer;
  88888. private _needSync;
  88889. private _noUBO;
  88890. private _currentEffect;
  88891. private static _MAX_UNIFORM_SIZE;
  88892. private static _tempBuffer;
  88893. /**
  88894. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88895. * This is dynamic to allow compat with webgl 1 and 2.
  88896. * You will need to pass the name of the uniform as well as the value.
  88897. */
  88898. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88899. /**
  88900. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88901. * This is dynamic to allow compat with webgl 1 and 2.
  88902. * You will need to pass the name of the uniform as well as the value.
  88903. */
  88904. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88905. /**
  88906. * Lambda to Update a single float in a uniform buffer.
  88907. * This is dynamic to allow compat with webgl 1 and 2.
  88908. * You will need to pass the name of the uniform as well as the value.
  88909. */
  88910. updateFloat: (name: string, x: number) => void;
  88911. /**
  88912. * Lambda to Update a vec2 of float in a uniform buffer.
  88913. * This is dynamic to allow compat with webgl 1 and 2.
  88914. * You will need to pass the name of the uniform as well as the value.
  88915. */
  88916. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88917. /**
  88918. * Lambda to Update a vec3 of float in a uniform buffer.
  88919. * This is dynamic to allow compat with webgl 1 and 2.
  88920. * You will need to pass the name of the uniform as well as the value.
  88921. */
  88922. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88923. /**
  88924. * Lambda to Update a vec4 of float in a uniform buffer.
  88925. * This is dynamic to allow compat with webgl 1 and 2.
  88926. * You will need to pass the name of the uniform as well as the value.
  88927. */
  88928. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88929. /**
  88930. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88931. * This is dynamic to allow compat with webgl 1 and 2.
  88932. * You will need to pass the name of the uniform as well as the value.
  88933. */
  88934. updateMatrix: (name: string, mat: Matrix) => void;
  88935. /**
  88936. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88937. * This is dynamic to allow compat with webgl 1 and 2.
  88938. * You will need to pass the name of the uniform as well as the value.
  88939. */
  88940. updateVector3: (name: string, vector: Vector3) => void;
  88941. /**
  88942. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88943. * This is dynamic to allow compat with webgl 1 and 2.
  88944. * You will need to pass the name of the uniform as well as the value.
  88945. */
  88946. updateVector4: (name: string, vector: Vector4) => void;
  88947. /**
  88948. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88949. * This is dynamic to allow compat with webgl 1 and 2.
  88950. * You will need to pass the name of the uniform as well as the value.
  88951. */
  88952. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88953. /**
  88954. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88955. * This is dynamic to allow compat with webgl 1 and 2.
  88956. * You will need to pass the name of the uniform as well as the value.
  88957. */
  88958. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88959. /**
  88960. * Instantiates a new Uniform buffer objects.
  88961. *
  88962. * Handles blocks of uniform on the GPU.
  88963. *
  88964. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88965. *
  88966. * For more information, please refer to :
  88967. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88968. * @param engine Define the engine the buffer is associated with
  88969. * @param data Define the data contained in the buffer
  88970. * @param dynamic Define if the buffer is updatable
  88971. */
  88972. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88973. /**
  88974. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88975. * or just falling back on setUniformXXX calls.
  88976. */
  88977. readonly useUbo: boolean;
  88978. /**
  88979. * Indicates if the WebGL underlying uniform buffer is in sync
  88980. * with the javascript cache data.
  88981. */
  88982. readonly isSync: boolean;
  88983. /**
  88984. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88985. * Also, a dynamic UniformBuffer will disable cache verification and always
  88986. * update the underlying WebGL uniform buffer to the GPU.
  88987. * @returns if Dynamic, otherwise false
  88988. */
  88989. isDynamic(): boolean;
  88990. /**
  88991. * The data cache on JS side.
  88992. * @returns the underlying data as a float array
  88993. */
  88994. getData(): Float32Array;
  88995. /**
  88996. * The underlying WebGL Uniform buffer.
  88997. * @returns the webgl buffer
  88998. */
  88999. getBuffer(): Nullable<DataBuffer>;
  89000. /**
  89001. * std140 layout specifies how to align data within an UBO structure.
  89002. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89003. * for specs.
  89004. */
  89005. private _fillAlignment;
  89006. /**
  89007. * Adds an uniform in the buffer.
  89008. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89009. * for the layout to be correct !
  89010. * @param name Name of the uniform, as used in the uniform block in the shader.
  89011. * @param size Data size, or data directly.
  89012. */
  89013. addUniform(name: string, size: number | number[]): void;
  89014. /**
  89015. * Adds a Matrix 4x4 to the uniform buffer.
  89016. * @param name Name of the uniform, as used in the uniform block in the shader.
  89017. * @param mat A 4x4 matrix.
  89018. */
  89019. addMatrix(name: string, mat: Matrix): void;
  89020. /**
  89021. * Adds a vec2 to the uniform buffer.
  89022. * @param name Name of the uniform, as used in the uniform block in the shader.
  89023. * @param x Define the x component value of the vec2
  89024. * @param y Define the y component value of the vec2
  89025. */
  89026. addFloat2(name: string, x: number, y: number): void;
  89027. /**
  89028. * Adds a vec3 to the uniform buffer.
  89029. * @param name Name of the uniform, as used in the uniform block in the shader.
  89030. * @param x Define the x component value of the vec3
  89031. * @param y Define the y component value of the vec3
  89032. * @param z Define the z component value of the vec3
  89033. */
  89034. addFloat3(name: string, x: number, y: number, z: number): void;
  89035. /**
  89036. * Adds a vec3 to the uniform buffer.
  89037. * @param name Name of the uniform, as used in the uniform block in the shader.
  89038. * @param color Define the vec3 from a Color
  89039. */
  89040. addColor3(name: string, color: Color3): void;
  89041. /**
  89042. * Adds a vec4 to the uniform buffer.
  89043. * @param name Name of the uniform, as used in the uniform block in the shader.
  89044. * @param color Define the rgb components from a Color
  89045. * @param alpha Define the a component of the vec4
  89046. */
  89047. addColor4(name: string, color: Color3, alpha: number): void;
  89048. /**
  89049. * Adds a vec3 to the uniform buffer.
  89050. * @param name Name of the uniform, as used in the uniform block in the shader.
  89051. * @param vector Define the vec3 components from a Vector
  89052. */
  89053. addVector3(name: string, vector: Vector3): void;
  89054. /**
  89055. * Adds a Matrix 3x3 to the uniform buffer.
  89056. * @param name Name of the uniform, as used in the uniform block in the shader.
  89057. */
  89058. addMatrix3x3(name: string): void;
  89059. /**
  89060. * Adds a Matrix 2x2 to the uniform buffer.
  89061. * @param name Name of the uniform, as used in the uniform block in the shader.
  89062. */
  89063. addMatrix2x2(name: string): void;
  89064. /**
  89065. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89066. */
  89067. create(): void;
  89068. /** @hidden */
  89069. _rebuild(): void;
  89070. /**
  89071. * Updates the WebGL Uniform Buffer on the GPU.
  89072. * If the `dynamic` flag is set to true, no cache comparison is done.
  89073. * Otherwise, the buffer will be updated only if the cache differs.
  89074. */
  89075. update(): void;
  89076. /**
  89077. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89078. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89079. * @param data Define the flattened data
  89080. * @param size Define the size of the data.
  89081. */
  89082. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89083. private _updateMatrix3x3ForUniform;
  89084. private _updateMatrix3x3ForEffect;
  89085. private _updateMatrix2x2ForEffect;
  89086. private _updateMatrix2x2ForUniform;
  89087. private _updateFloatForEffect;
  89088. private _updateFloatForUniform;
  89089. private _updateFloat2ForEffect;
  89090. private _updateFloat2ForUniform;
  89091. private _updateFloat3ForEffect;
  89092. private _updateFloat3ForUniform;
  89093. private _updateFloat4ForEffect;
  89094. private _updateFloat4ForUniform;
  89095. private _updateMatrixForEffect;
  89096. private _updateMatrixForUniform;
  89097. private _updateVector3ForEffect;
  89098. private _updateVector3ForUniform;
  89099. private _updateVector4ForEffect;
  89100. private _updateVector4ForUniform;
  89101. private _updateColor3ForEffect;
  89102. private _updateColor3ForUniform;
  89103. private _updateColor4ForEffect;
  89104. private _updateColor4ForUniform;
  89105. /**
  89106. * Sets a sampler uniform on the effect.
  89107. * @param name Define the name of the sampler.
  89108. * @param texture Define the texture to set in the sampler
  89109. */
  89110. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89111. /**
  89112. * Directly updates the value of the uniform in the cache AND on the GPU.
  89113. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89114. * @param data Define the flattened data
  89115. */
  89116. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89117. /**
  89118. * Binds this uniform buffer to an effect.
  89119. * @param effect Define the effect to bind the buffer to
  89120. * @param name Name of the uniform block in the shader.
  89121. */
  89122. bindToEffect(effect: Effect, name: string): void;
  89123. /**
  89124. * Disposes the uniform buffer.
  89125. */
  89126. dispose(): void;
  89127. }
  89128. }
  89129. declare module BABYLON {
  89130. /**
  89131. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89133. */
  89134. export class Analyser {
  89135. /**
  89136. * Gets or sets the smoothing
  89137. * @ignorenaming
  89138. */
  89139. SMOOTHING: number;
  89140. /**
  89141. * Gets or sets the FFT table size
  89142. * @ignorenaming
  89143. */
  89144. FFT_SIZE: number;
  89145. /**
  89146. * Gets or sets the bar graph amplitude
  89147. * @ignorenaming
  89148. */
  89149. BARGRAPHAMPLITUDE: number;
  89150. /**
  89151. * Gets or sets the position of the debug canvas
  89152. * @ignorenaming
  89153. */
  89154. DEBUGCANVASPOS: {
  89155. x: number;
  89156. y: number;
  89157. };
  89158. /**
  89159. * Gets or sets the debug canvas size
  89160. * @ignorenaming
  89161. */
  89162. DEBUGCANVASSIZE: {
  89163. width: number;
  89164. height: number;
  89165. };
  89166. private _byteFreqs;
  89167. private _byteTime;
  89168. private _floatFreqs;
  89169. private _webAudioAnalyser;
  89170. private _debugCanvas;
  89171. private _debugCanvasContext;
  89172. private _scene;
  89173. private _registerFunc;
  89174. private _audioEngine;
  89175. /**
  89176. * Creates a new analyser
  89177. * @param scene defines hosting scene
  89178. */
  89179. constructor(scene: Scene);
  89180. /**
  89181. * Get the number of data values you will have to play with for the visualization
  89182. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89183. * @returns a number
  89184. */
  89185. getFrequencyBinCount(): number;
  89186. /**
  89187. * Gets the current frequency data as a byte array
  89188. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89189. * @returns a Uint8Array
  89190. */
  89191. getByteFrequencyData(): Uint8Array;
  89192. /**
  89193. * Gets the current waveform as a byte array
  89194. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89195. * @returns a Uint8Array
  89196. */
  89197. getByteTimeDomainData(): Uint8Array;
  89198. /**
  89199. * Gets the current frequency data as a float array
  89200. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89201. * @returns a Float32Array
  89202. */
  89203. getFloatFrequencyData(): Float32Array;
  89204. /**
  89205. * Renders the debug canvas
  89206. */
  89207. drawDebugCanvas(): void;
  89208. /**
  89209. * Stops rendering the debug canvas and removes it
  89210. */
  89211. stopDebugCanvas(): void;
  89212. /**
  89213. * Connects two audio nodes
  89214. * @param inputAudioNode defines first node to connect
  89215. * @param outputAudioNode defines second node to connect
  89216. */
  89217. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89218. /**
  89219. * Releases all associated resources
  89220. */
  89221. dispose(): void;
  89222. }
  89223. }
  89224. declare module BABYLON {
  89225. /**
  89226. * This represents an audio engine and it is responsible
  89227. * to play, synchronize and analyse sounds throughout the application.
  89228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89229. */
  89230. export interface IAudioEngine extends IDisposable {
  89231. /**
  89232. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89233. */
  89234. readonly canUseWebAudio: boolean;
  89235. /**
  89236. * Gets the current AudioContext if available.
  89237. */
  89238. readonly audioContext: Nullable<AudioContext>;
  89239. /**
  89240. * The master gain node defines the global audio volume of your audio engine.
  89241. */
  89242. readonly masterGain: GainNode;
  89243. /**
  89244. * Gets whether or not mp3 are supported by your browser.
  89245. */
  89246. readonly isMP3supported: boolean;
  89247. /**
  89248. * Gets whether or not ogg are supported by your browser.
  89249. */
  89250. readonly isOGGsupported: boolean;
  89251. /**
  89252. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89253. * @ignoreNaming
  89254. */
  89255. WarnedWebAudioUnsupported: boolean;
  89256. /**
  89257. * Defines if the audio engine relies on a custom unlocked button.
  89258. * In this case, the embedded button will not be displayed.
  89259. */
  89260. useCustomUnlockedButton: boolean;
  89261. /**
  89262. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89263. */
  89264. readonly unlocked: boolean;
  89265. /**
  89266. * Event raised when audio has been unlocked on the browser.
  89267. */
  89268. onAudioUnlockedObservable: Observable<AudioEngine>;
  89269. /**
  89270. * Event raised when audio has been locked on the browser.
  89271. */
  89272. onAudioLockedObservable: Observable<AudioEngine>;
  89273. /**
  89274. * Flags the audio engine in Locked state.
  89275. * This happens due to new browser policies preventing audio to autoplay.
  89276. */
  89277. lock(): void;
  89278. /**
  89279. * Unlocks the audio engine once a user action has been done on the dom.
  89280. * This is helpful to resume play once browser policies have been satisfied.
  89281. */
  89282. unlock(): void;
  89283. }
  89284. /**
  89285. * This represents the default audio engine used in babylon.
  89286. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89288. */
  89289. export class AudioEngine implements IAudioEngine {
  89290. private _audioContext;
  89291. private _audioContextInitialized;
  89292. private _muteButton;
  89293. private _hostElement;
  89294. /**
  89295. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89296. */
  89297. canUseWebAudio: boolean;
  89298. /**
  89299. * The master gain node defines the global audio volume of your audio engine.
  89300. */
  89301. masterGain: GainNode;
  89302. /**
  89303. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89304. * @ignoreNaming
  89305. */
  89306. WarnedWebAudioUnsupported: boolean;
  89307. /**
  89308. * Gets whether or not mp3 are supported by your browser.
  89309. */
  89310. isMP3supported: boolean;
  89311. /**
  89312. * Gets whether or not ogg are supported by your browser.
  89313. */
  89314. isOGGsupported: boolean;
  89315. /**
  89316. * Gets whether audio has been unlocked on the device.
  89317. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89318. * a user interaction has happened.
  89319. */
  89320. unlocked: boolean;
  89321. /**
  89322. * Defines if the audio engine relies on a custom unlocked button.
  89323. * In this case, the embedded button will not be displayed.
  89324. */
  89325. useCustomUnlockedButton: boolean;
  89326. /**
  89327. * Event raised when audio has been unlocked on the browser.
  89328. */
  89329. onAudioUnlockedObservable: Observable<AudioEngine>;
  89330. /**
  89331. * Event raised when audio has been locked on the browser.
  89332. */
  89333. onAudioLockedObservable: Observable<AudioEngine>;
  89334. /**
  89335. * Gets the current AudioContext if available.
  89336. */
  89337. readonly audioContext: Nullable<AudioContext>;
  89338. private _connectedAnalyser;
  89339. /**
  89340. * Instantiates a new audio engine.
  89341. *
  89342. * There should be only one per page as some browsers restrict the number
  89343. * of audio contexts you can create.
  89344. * @param hostElement defines the host element where to display the mute icon if necessary
  89345. */
  89346. constructor(hostElement?: Nullable<HTMLElement>);
  89347. /**
  89348. * Flags the audio engine in Locked state.
  89349. * This happens due to new browser policies preventing audio to autoplay.
  89350. */
  89351. lock(): void;
  89352. /**
  89353. * Unlocks the audio engine once a user action has been done on the dom.
  89354. * This is helpful to resume play once browser policies have been satisfied.
  89355. */
  89356. unlock(): void;
  89357. private _resumeAudioContext;
  89358. private _initializeAudioContext;
  89359. private _tryToRun;
  89360. private _triggerRunningState;
  89361. private _triggerSuspendedState;
  89362. private _displayMuteButton;
  89363. private _moveButtonToTopLeft;
  89364. private _onResize;
  89365. private _hideMuteButton;
  89366. /**
  89367. * Destroy and release the resources associated with the audio ccontext.
  89368. */
  89369. dispose(): void;
  89370. /**
  89371. * Gets the global volume sets on the master gain.
  89372. * @returns the global volume if set or -1 otherwise
  89373. */
  89374. getGlobalVolume(): number;
  89375. /**
  89376. * Sets the global volume of your experience (sets on the master gain).
  89377. * @param newVolume Defines the new global volume of the application
  89378. */
  89379. setGlobalVolume(newVolume: number): void;
  89380. /**
  89381. * Connect the audio engine to an audio analyser allowing some amazing
  89382. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89384. * @param analyser The analyser to connect to the engine
  89385. */
  89386. connectToAnalyser(analyser: Analyser): void;
  89387. }
  89388. }
  89389. declare module BABYLON {
  89390. /**
  89391. * Interface used to present a loading screen while loading a scene
  89392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89393. */
  89394. export interface ILoadingScreen {
  89395. /**
  89396. * Function called to display the loading screen
  89397. */
  89398. displayLoadingUI: () => void;
  89399. /**
  89400. * Function called to hide the loading screen
  89401. */
  89402. hideLoadingUI: () => void;
  89403. /**
  89404. * Gets or sets the color to use for the background
  89405. */
  89406. loadingUIBackgroundColor: string;
  89407. /**
  89408. * Gets or sets the text to display while loading
  89409. */
  89410. loadingUIText: string;
  89411. }
  89412. /**
  89413. * Class used for the default loading screen
  89414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89415. */
  89416. export class DefaultLoadingScreen implements ILoadingScreen {
  89417. private _renderingCanvas;
  89418. private _loadingText;
  89419. private _loadingDivBackgroundColor;
  89420. private _loadingDiv;
  89421. private _loadingTextDiv;
  89422. /** Gets or sets the logo url to use for the default loading screen */
  89423. static DefaultLogoUrl: string;
  89424. /** Gets or sets the spinner url to use for the default loading screen */
  89425. static DefaultSpinnerUrl: string;
  89426. /**
  89427. * Creates a new default loading screen
  89428. * @param _renderingCanvas defines the canvas used to render the scene
  89429. * @param _loadingText defines the default text to display
  89430. * @param _loadingDivBackgroundColor defines the default background color
  89431. */
  89432. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89433. /**
  89434. * Function called to display the loading screen
  89435. */
  89436. displayLoadingUI(): void;
  89437. /**
  89438. * Function called to hide the loading screen
  89439. */
  89440. hideLoadingUI(): void;
  89441. /**
  89442. * Gets or sets the text to display while loading
  89443. */
  89444. loadingUIText: string;
  89445. /**
  89446. * Gets or sets the color to use for the background
  89447. */
  89448. loadingUIBackgroundColor: string;
  89449. private _resizeLoadingUI;
  89450. }
  89451. }
  89452. declare module BABYLON {
  89453. /** @hidden */
  89454. export class WebGLPipelineContext implements IPipelineContext {
  89455. engine: Engine;
  89456. program: Nullable<WebGLProgram>;
  89457. context?: WebGLRenderingContext;
  89458. vertexShader?: WebGLShader;
  89459. fragmentShader?: WebGLShader;
  89460. isParallelCompiled: boolean;
  89461. onCompiled?: () => void;
  89462. transformFeedback?: WebGLTransformFeedback | null;
  89463. readonly isAsync: boolean;
  89464. readonly isReady: boolean;
  89465. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89466. }
  89467. }
  89468. declare module BABYLON {
  89469. /** @hidden */
  89470. export class WebGLDataBuffer extends DataBuffer {
  89471. private _buffer;
  89472. constructor(resource: WebGLBuffer);
  89473. readonly underlyingResource: any;
  89474. }
  89475. }
  89476. declare module BABYLON {
  89477. /** @hidden */
  89478. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89479. attributeProcessor(attribute: string): string;
  89480. varyingProcessor(varying: string, isFragment: boolean): string;
  89481. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89482. }
  89483. }
  89484. declare module BABYLON {
  89485. /**
  89486. * Settings for finer control over video usage
  89487. */
  89488. export interface VideoTextureSettings {
  89489. /**
  89490. * Applies `autoplay` to video, if specified
  89491. */
  89492. autoPlay?: boolean;
  89493. /**
  89494. * Applies `loop` to video, if specified
  89495. */
  89496. loop?: boolean;
  89497. /**
  89498. * Automatically updates internal texture from video at every frame in the render loop
  89499. */
  89500. autoUpdateTexture: boolean;
  89501. /**
  89502. * Image src displayed during the video loading or until the user interacts with the video.
  89503. */
  89504. poster?: string;
  89505. }
  89506. /**
  89507. * If you want to display a video in your scene, this is the special texture for that.
  89508. * This special texture works similar to other textures, with the exception of a few parameters.
  89509. * @see https://doc.babylonjs.com/how_to/video_texture
  89510. */
  89511. export class VideoTexture extends Texture {
  89512. /**
  89513. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89514. */
  89515. readonly autoUpdateTexture: boolean;
  89516. /**
  89517. * The video instance used by the texture internally
  89518. */
  89519. readonly video: HTMLVideoElement;
  89520. private _onUserActionRequestedObservable;
  89521. /**
  89522. * Event triggerd when a dom action is required by the user to play the video.
  89523. * This happens due to recent changes in browser policies preventing video to auto start.
  89524. */
  89525. readonly onUserActionRequestedObservable: Observable<Texture>;
  89526. private _generateMipMaps;
  89527. private _engine;
  89528. private _stillImageCaptured;
  89529. private _displayingPosterTexture;
  89530. private _settings;
  89531. private _createInternalTextureOnEvent;
  89532. /**
  89533. * Creates a video texture.
  89534. * If you want to display a video in your scene, this is the special texture for that.
  89535. * This special texture works similar to other textures, with the exception of a few parameters.
  89536. * @see https://doc.babylonjs.com/how_to/video_texture
  89537. * @param name optional name, will detect from video source, if not defined
  89538. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89539. * @param scene is obviously the current scene.
  89540. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89541. * @param invertY is false by default but can be used to invert video on Y axis
  89542. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89543. * @param settings allows finer control over video usage
  89544. */
  89545. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89546. private _getName;
  89547. private _getVideo;
  89548. private _createInternalTexture;
  89549. private reset;
  89550. /**
  89551. * @hidden Internal method to initiate `update`.
  89552. */
  89553. _rebuild(): void;
  89554. /**
  89555. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89556. */
  89557. update(): void;
  89558. /**
  89559. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89560. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89561. */
  89562. updateTexture(isVisible: boolean): void;
  89563. protected _updateInternalTexture: () => void;
  89564. /**
  89565. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89566. * @param url New url.
  89567. */
  89568. updateURL(url: string): void;
  89569. /**
  89570. * Dispose the texture and release its associated resources.
  89571. */
  89572. dispose(): void;
  89573. /**
  89574. * Creates a video texture straight from a stream.
  89575. * @param scene Define the scene the texture should be created in
  89576. * @param stream Define the stream the texture should be created from
  89577. * @returns The created video texture as a promise
  89578. */
  89579. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89580. /**
  89581. * Creates a video texture straight from your WebCam video feed.
  89582. * @param scene Define the scene the texture should be created in
  89583. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89584. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89585. * @returns The created video texture as a promise
  89586. */
  89587. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89588. minWidth: number;
  89589. maxWidth: number;
  89590. minHeight: number;
  89591. maxHeight: number;
  89592. deviceId: string;
  89593. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89594. /**
  89595. * Creates a video texture straight from your WebCam video feed.
  89596. * @param scene Define the scene the texture should be created in
  89597. * @param onReady Define a callback to triggered once the texture will be ready
  89598. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89599. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89600. */
  89601. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89602. minWidth: number;
  89603. maxWidth: number;
  89604. minHeight: number;
  89605. maxHeight: number;
  89606. deviceId: string;
  89607. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89608. }
  89609. }
  89610. declare module BABYLON {
  89611. /**
  89612. * Interface for attribute information associated with buffer instanciation
  89613. */
  89614. export class InstancingAttributeInfo {
  89615. /**
  89616. * Index/offset of the attribute in the vertex shader
  89617. */
  89618. index: number;
  89619. /**
  89620. * size of the attribute, 1, 2, 3 or 4
  89621. */
  89622. attributeSize: number;
  89623. /**
  89624. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89625. * default is FLOAT
  89626. */
  89627. attribyteType: number;
  89628. /**
  89629. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89630. */
  89631. normalized: boolean;
  89632. /**
  89633. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89634. */
  89635. offset: number;
  89636. /**
  89637. * Name of the GLSL attribute, for debugging purpose only
  89638. */
  89639. attributeName: string;
  89640. }
  89641. /**
  89642. * Define options used to create a depth texture
  89643. */
  89644. export class DepthTextureCreationOptions {
  89645. /** Specifies whether or not a stencil should be allocated in the texture */
  89646. generateStencil?: boolean;
  89647. /** Specifies whether or not bilinear filtering is enable on the texture */
  89648. bilinearFiltering?: boolean;
  89649. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89650. comparisonFunction?: number;
  89651. /** Specifies if the created texture is a cube texture */
  89652. isCube?: boolean;
  89653. }
  89654. /**
  89655. * Class used to describe the capabilities of the engine relatively to the current browser
  89656. */
  89657. export class EngineCapabilities {
  89658. /** Maximum textures units per fragment shader */
  89659. maxTexturesImageUnits: number;
  89660. /** Maximum texture units per vertex shader */
  89661. maxVertexTextureImageUnits: number;
  89662. /** Maximum textures units in the entire pipeline */
  89663. maxCombinedTexturesImageUnits: number;
  89664. /** Maximum texture size */
  89665. maxTextureSize: number;
  89666. /** Maximum cube texture size */
  89667. maxCubemapTextureSize: number;
  89668. /** Maximum render texture size */
  89669. maxRenderTextureSize: number;
  89670. /** Maximum number of vertex attributes */
  89671. maxVertexAttribs: number;
  89672. /** Maximum number of varyings */
  89673. maxVaryingVectors: number;
  89674. /** Maximum number of uniforms per vertex shader */
  89675. maxVertexUniformVectors: number;
  89676. /** Maximum number of uniforms per fragment shader */
  89677. maxFragmentUniformVectors: number;
  89678. /** Defines if standard derivates (dx/dy) are supported */
  89679. standardDerivatives: boolean;
  89680. /** Defines if s3tc texture compression is supported */
  89681. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89682. /** Defines if pvrtc texture compression is supported */
  89683. pvrtc: any;
  89684. /** Defines if etc1 texture compression is supported */
  89685. etc1: any;
  89686. /** Defines if etc2 texture compression is supported */
  89687. etc2: any;
  89688. /** Defines if astc texture compression is supported */
  89689. astc: any;
  89690. /** Defines if float textures are supported */
  89691. textureFloat: boolean;
  89692. /** Defines if vertex array objects are supported */
  89693. vertexArrayObject: boolean;
  89694. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89695. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89696. /** Gets the maximum level of anisotropy supported */
  89697. maxAnisotropy: number;
  89698. /** Defines if instancing is supported */
  89699. instancedArrays: boolean;
  89700. /** Defines if 32 bits indices are supported */
  89701. uintIndices: boolean;
  89702. /** Defines if high precision shaders are supported */
  89703. highPrecisionShaderSupported: boolean;
  89704. /** Defines if depth reading in the fragment shader is supported */
  89705. fragmentDepthSupported: boolean;
  89706. /** Defines if float texture linear filtering is supported*/
  89707. textureFloatLinearFiltering: boolean;
  89708. /** Defines if rendering to float textures is supported */
  89709. textureFloatRender: boolean;
  89710. /** Defines if half float textures are supported*/
  89711. textureHalfFloat: boolean;
  89712. /** Defines if half float texture linear filtering is supported*/
  89713. textureHalfFloatLinearFiltering: boolean;
  89714. /** Defines if rendering to half float textures is supported */
  89715. textureHalfFloatRender: boolean;
  89716. /** Defines if textureLOD shader command is supported */
  89717. textureLOD: boolean;
  89718. /** Defines if draw buffers extension is supported */
  89719. drawBuffersExtension: boolean;
  89720. /** Defines if depth textures are supported */
  89721. depthTextureExtension: boolean;
  89722. /** Defines if float color buffer are supported */
  89723. colorBufferFloat: boolean;
  89724. /** Gets disjoint timer query extension (null if not supported) */
  89725. timerQuery: EXT_disjoint_timer_query;
  89726. /** Defines if timestamp can be used with timer query */
  89727. canUseTimestampForTimerQuery: boolean;
  89728. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89729. multiview: any;
  89730. /** Function used to let the system compiles shaders in background */
  89731. parallelShaderCompile: {
  89732. COMPLETION_STATUS_KHR: number;
  89733. };
  89734. }
  89735. /** Interface defining initialization parameters for Engine class */
  89736. export interface EngineOptions extends WebGLContextAttributes {
  89737. /**
  89738. * Defines if the engine should no exceed a specified device ratio
  89739. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89740. */
  89741. limitDeviceRatio?: number;
  89742. /**
  89743. * Defines if webvr should be enabled automatically
  89744. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89745. */
  89746. autoEnableWebVR?: boolean;
  89747. /**
  89748. * Defines if webgl2 should be turned off even if supported
  89749. * @see http://doc.babylonjs.com/features/webgl2
  89750. */
  89751. disableWebGL2Support?: boolean;
  89752. /**
  89753. * Defines if webaudio should be initialized as well
  89754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89755. */
  89756. audioEngine?: boolean;
  89757. /**
  89758. * Defines if animations should run using a deterministic lock step
  89759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89760. */
  89761. deterministicLockstep?: boolean;
  89762. /** Defines the maximum steps to use with deterministic lock step mode */
  89763. lockstepMaxSteps?: number;
  89764. /**
  89765. * Defines that engine should ignore context lost events
  89766. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89767. */
  89768. doNotHandleContextLost?: boolean;
  89769. /**
  89770. * Defines that engine should ignore modifying touch action attribute and style
  89771. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89772. */
  89773. doNotHandleTouchAction?: boolean;
  89774. /**
  89775. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89776. */
  89777. useHighPrecisionFloats?: boolean;
  89778. }
  89779. /**
  89780. * Defines the interface used by display changed events
  89781. */
  89782. export interface IDisplayChangedEventArgs {
  89783. /** Gets the vrDisplay object (if any) */
  89784. vrDisplay: Nullable<any>;
  89785. /** Gets a boolean indicating if webVR is supported */
  89786. vrSupported: boolean;
  89787. }
  89788. /**
  89789. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89790. */
  89791. export class Engine {
  89792. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89793. static ExceptionList: ({
  89794. key: string;
  89795. capture: string;
  89796. captureConstraint: number;
  89797. targets: string[];
  89798. } | {
  89799. key: string;
  89800. capture: null;
  89801. captureConstraint: null;
  89802. targets: string[];
  89803. })[];
  89804. /** Gets the list of created engines */
  89805. static readonly Instances: Engine[];
  89806. /**
  89807. * Gets the latest created engine
  89808. */
  89809. static readonly LastCreatedEngine: Nullable<Engine>;
  89810. /**
  89811. * Gets the latest created scene
  89812. */
  89813. static readonly LastCreatedScene: Nullable<Scene>;
  89814. /**
  89815. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  89816. * @param flag defines which part of the materials must be marked as dirty
  89817. * @param predicate defines a predicate used to filter which materials should be affected
  89818. */
  89819. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89820. /** @hidden */
  89821. static _TextureLoaders: IInternalTextureLoader[];
  89822. /** Defines that alpha blending is disabled */
  89823. static readonly ALPHA_DISABLE: number;
  89824. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  89825. static readonly ALPHA_ADD: number;
  89826. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  89827. static readonly ALPHA_COMBINE: number;
  89828. /** Defines that alpha blending to DEST - SRC * DEST */
  89829. static readonly ALPHA_SUBTRACT: number;
  89830. /** Defines that alpha blending to SRC * DEST */
  89831. static readonly ALPHA_MULTIPLY: number;
  89832. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  89833. static readonly ALPHA_MAXIMIZED: number;
  89834. /** Defines that alpha blending to SRC + DEST */
  89835. static readonly ALPHA_ONEONE: number;
  89836. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  89837. static readonly ALPHA_PREMULTIPLIED: number;
  89838. /**
  89839. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  89840. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  89841. */
  89842. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  89843. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  89844. static readonly ALPHA_INTERPOLATE: number;
  89845. /**
  89846. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  89847. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  89848. */
  89849. static readonly ALPHA_SCREENMODE: number;
  89850. /** Defines that the ressource is not delayed*/
  89851. static readonly DELAYLOADSTATE_NONE: number;
  89852. /** Defines that the ressource was successfully delay loaded */
  89853. static readonly DELAYLOADSTATE_LOADED: number;
  89854. /** Defines that the ressource is currently delay loading */
  89855. static readonly DELAYLOADSTATE_LOADING: number;
  89856. /** Defines that the ressource is delayed and has not started loading */
  89857. static readonly DELAYLOADSTATE_NOTLOADED: number;
  89858. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  89859. static readonly NEVER: number;
  89860. /** 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 */
  89861. static readonly ALWAYS: number;
  89862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  89863. static readonly LESS: number;
  89864. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  89865. static readonly EQUAL: number;
  89866. /** 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 */
  89867. static readonly LEQUAL: number;
  89868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  89869. static readonly GREATER: number;
  89870. /** 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 */
  89871. static readonly GEQUAL: number;
  89872. /** 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 */
  89873. static readonly NOTEQUAL: number;
  89874. /** Passed to stencilOperation to specify that stencil value must be kept */
  89875. static readonly KEEP: number;
  89876. /** Passed to stencilOperation to specify that stencil value must be replaced */
  89877. static readonly REPLACE: number;
  89878. /** Passed to stencilOperation to specify that stencil value must be incremented */
  89879. static readonly INCR: number;
  89880. /** Passed to stencilOperation to specify that stencil value must be decremented */
  89881. static readonly DECR: number;
  89882. /** Passed to stencilOperation to specify that stencil value must be inverted */
  89883. static readonly INVERT: number;
  89884. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  89885. static readonly INCR_WRAP: number;
  89886. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  89887. static readonly DECR_WRAP: number;
  89888. /** Texture is not repeating outside of 0..1 UVs */
  89889. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  89890. /** Texture is repeating outside of 0..1 UVs */
  89891. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  89892. /** Texture is repeating and mirrored */
  89893. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  89894. /** ALPHA */
  89895. static readonly TEXTUREFORMAT_ALPHA: number;
  89896. /** LUMINANCE */
  89897. static readonly TEXTUREFORMAT_LUMINANCE: number;
  89898. /** LUMINANCE_ALPHA */
  89899. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  89900. /** RGB */
  89901. static readonly TEXTUREFORMAT_RGB: number;
  89902. /** RGBA */
  89903. static readonly TEXTUREFORMAT_RGBA: number;
  89904. /** RED */
  89905. static readonly TEXTUREFORMAT_RED: number;
  89906. /** RED (2nd reference) */
  89907. static readonly TEXTUREFORMAT_R: number;
  89908. /** RG */
  89909. static readonly TEXTUREFORMAT_RG: number;
  89910. /** RED_INTEGER */
  89911. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  89912. /** RED_INTEGER (2nd reference) */
  89913. static readonly TEXTUREFORMAT_R_INTEGER: number;
  89914. /** RG_INTEGER */
  89915. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  89916. /** RGB_INTEGER */
  89917. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  89918. /** RGBA_INTEGER */
  89919. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  89920. /** UNSIGNED_BYTE */
  89921. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  89922. /** UNSIGNED_BYTE (2nd reference) */
  89923. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  89924. /** FLOAT */
  89925. static readonly TEXTURETYPE_FLOAT: number;
  89926. /** HALF_FLOAT */
  89927. static readonly TEXTURETYPE_HALF_FLOAT: number;
  89928. /** BYTE */
  89929. static readonly TEXTURETYPE_BYTE: number;
  89930. /** SHORT */
  89931. static readonly TEXTURETYPE_SHORT: number;
  89932. /** UNSIGNED_SHORT */
  89933. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  89934. /** INT */
  89935. static readonly TEXTURETYPE_INT: number;
  89936. /** UNSIGNED_INT */
  89937. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  89938. /** UNSIGNED_SHORT_4_4_4_4 */
  89939. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  89940. /** UNSIGNED_SHORT_5_5_5_1 */
  89941. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  89942. /** UNSIGNED_SHORT_5_6_5 */
  89943. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  89944. /** UNSIGNED_INT_2_10_10_10_REV */
  89945. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  89946. /** UNSIGNED_INT_24_8 */
  89947. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  89948. /** UNSIGNED_INT_10F_11F_11F_REV */
  89949. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  89950. /** UNSIGNED_INT_5_9_9_9_REV */
  89951. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  89952. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  89953. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  89954. /** nearest is mag = nearest and min = nearest and mip = linear */
  89955. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  89956. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89957. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  89958. /** Trilinear is mag = linear and min = linear and mip = linear */
  89959. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  89960. /** nearest is mag = nearest and min = nearest and mip = linear */
  89961. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  89962. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89963. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  89964. /** Trilinear is mag = linear and min = linear and mip = linear */
  89965. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  89966. /** mag = nearest and min = nearest and mip = nearest */
  89967. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  89968. /** mag = nearest and min = linear and mip = nearest */
  89969. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  89970. /** mag = nearest and min = linear and mip = linear */
  89971. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  89972. /** mag = nearest and min = linear and mip = none */
  89973. static readonly TEXTURE_NEAREST_LINEAR: number;
  89974. /** mag = nearest and min = nearest and mip = none */
  89975. static readonly TEXTURE_NEAREST_NEAREST: number;
  89976. /** mag = linear and min = nearest and mip = nearest */
  89977. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  89978. /** mag = linear and min = nearest and mip = linear */
  89979. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  89980. /** mag = linear and min = linear and mip = none */
  89981. static readonly TEXTURE_LINEAR_LINEAR: number;
  89982. /** mag = linear and min = nearest and mip = none */
  89983. static readonly TEXTURE_LINEAR_NEAREST: number;
  89984. /** Explicit coordinates mode */
  89985. static readonly TEXTURE_EXPLICIT_MODE: number;
  89986. /** Spherical coordinates mode */
  89987. static readonly TEXTURE_SPHERICAL_MODE: number;
  89988. /** Planar coordinates mode */
  89989. static readonly TEXTURE_PLANAR_MODE: number;
  89990. /** Cubic coordinates mode */
  89991. static readonly TEXTURE_CUBIC_MODE: number;
  89992. /** Projection coordinates mode */
  89993. static readonly TEXTURE_PROJECTION_MODE: number;
  89994. /** Skybox coordinates mode */
  89995. static readonly TEXTURE_SKYBOX_MODE: number;
  89996. /** Inverse Cubic coordinates mode */
  89997. static readonly TEXTURE_INVCUBIC_MODE: number;
  89998. /** Equirectangular coordinates mode */
  89999. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90000. /** Equirectangular Fixed coordinates mode */
  90001. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90002. /** Equirectangular Fixed Mirrored coordinates mode */
  90003. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90004. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90005. static readonly SCALEMODE_FLOOR: number;
  90006. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90007. static readonly SCALEMODE_NEAREST: number;
  90008. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90009. static readonly SCALEMODE_CEILING: number;
  90010. /**
  90011. * Returns the current npm package of the sdk
  90012. */
  90013. static readonly NpmPackage: string;
  90014. /**
  90015. * Returns the current version of the framework
  90016. */
  90017. static readonly Version: string;
  90018. /**
  90019. * Returns a string describing the current engine
  90020. */
  90021. readonly description: string;
  90022. /**
  90023. * Gets or sets the epsilon value used by collision engine
  90024. */
  90025. static CollisionsEpsilon: number;
  90026. /**
  90027. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90028. */
  90029. static ShadersRepository: string;
  90030. /**
  90031. * Method called to create the default loading screen.
  90032. * This can be overriden in your own app.
  90033. * @param canvas The rendering canvas element
  90034. * @returns The loading screen
  90035. */
  90036. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90037. /**
  90038. * Method called to create the default rescale post process on each engine.
  90039. */
  90040. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90041. /** @hidden */
  90042. _shaderProcessor: IShaderProcessor;
  90043. /**
  90044. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90045. */
  90046. forcePOTTextures: boolean;
  90047. /**
  90048. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90049. */
  90050. isFullscreen: boolean;
  90051. /**
  90052. * Gets a boolean indicating if the pointer is currently locked
  90053. */
  90054. isPointerLock: boolean;
  90055. /**
  90056. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90057. */
  90058. cullBackFaces: boolean;
  90059. /**
  90060. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90061. */
  90062. renderEvenInBackground: boolean;
  90063. /**
  90064. * Gets or sets a boolean indicating that cache can be kept between frames
  90065. */
  90066. preventCacheWipeBetweenFrames: boolean;
  90067. /**
  90068. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90069. **/
  90070. enableOfflineSupport: boolean;
  90071. /**
  90072. * 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)
  90073. **/
  90074. disableManifestCheck: boolean;
  90075. /**
  90076. * Gets the list of created scenes
  90077. */
  90078. scenes: Scene[];
  90079. /**
  90080. * Event raised when a new scene is created
  90081. */
  90082. onNewSceneAddedObservable: Observable<Scene>;
  90083. /**
  90084. * Gets the list of created postprocesses
  90085. */
  90086. postProcesses: PostProcess[];
  90087. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90088. validateShaderPrograms: boolean;
  90089. /**
  90090. * Observable event triggered each time the rendering canvas is resized
  90091. */
  90092. onResizeObservable: Observable<Engine>;
  90093. /**
  90094. * Observable event triggered each time the canvas loses focus
  90095. */
  90096. onCanvasBlurObservable: Observable<Engine>;
  90097. /**
  90098. * Observable event triggered each time the canvas gains focus
  90099. */
  90100. onCanvasFocusObservable: Observable<Engine>;
  90101. /**
  90102. * Observable event triggered each time the canvas receives pointerout event
  90103. */
  90104. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90105. /**
  90106. * Observable event triggered before each texture is initialized
  90107. */
  90108. onBeforeTextureInitObservable: Observable<Texture>;
  90109. /**
  90110. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90111. */
  90112. disableUniformBuffers: boolean;
  90113. /** @hidden */
  90114. _uniformBuffers: UniformBuffer[];
  90115. /**
  90116. * Gets a boolean indicating that the engine supports uniform buffers
  90117. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90118. */
  90119. readonly supportsUniformBuffers: boolean;
  90120. /**
  90121. * Observable raised when the engine begins a new frame
  90122. */
  90123. onBeginFrameObservable: Observable<Engine>;
  90124. /**
  90125. * If set, will be used to request the next animation frame for the render loop
  90126. */
  90127. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90128. /**
  90129. * Observable raised when the engine ends the current frame
  90130. */
  90131. onEndFrameObservable: Observable<Engine>;
  90132. /**
  90133. * Observable raised when the engine is about to compile a shader
  90134. */
  90135. onBeforeShaderCompilationObservable: Observable<Engine>;
  90136. /**
  90137. * Observable raised when the engine has jsut compiled a shader
  90138. */
  90139. onAfterShaderCompilationObservable: Observable<Engine>;
  90140. /** @hidden */
  90141. _gl: WebGLRenderingContext;
  90142. private _renderingCanvas;
  90143. private _windowIsBackground;
  90144. private _webGLVersion;
  90145. protected _highPrecisionShadersAllowed: boolean;
  90146. /** @hidden */
  90147. readonly _shouldUseHighPrecisionShader: boolean;
  90148. /**
  90149. * Gets a boolean indicating that only power of 2 textures are supported
  90150. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90151. */
  90152. readonly needPOTTextures: boolean;
  90153. /** @hidden */
  90154. _badOS: boolean;
  90155. /** @hidden */
  90156. _badDesktopOS: boolean;
  90157. /**
  90158. * Gets the audio engine
  90159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90160. * @ignorenaming
  90161. */
  90162. static audioEngine: IAudioEngine;
  90163. /**
  90164. * Default AudioEngine factory responsible of creating the Audio Engine.
  90165. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90166. */
  90167. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90168. /**
  90169. * Default offline support factory responsible of creating a tool used to store data locally.
  90170. * By default, this will create a Database object if the workload has been embedded.
  90171. */
  90172. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90173. private _onFocus;
  90174. private _onBlur;
  90175. private _onCanvasPointerOut;
  90176. private _onCanvasBlur;
  90177. private _onCanvasFocus;
  90178. private _onFullscreenChange;
  90179. private _onPointerLockChange;
  90180. private _hardwareScalingLevel;
  90181. /** @hidden */
  90182. _caps: EngineCapabilities;
  90183. private _pointerLockRequested;
  90184. private _isStencilEnable;
  90185. private _colorWrite;
  90186. private _loadingScreen;
  90187. /** @hidden */
  90188. _drawCalls: PerfCounter;
  90189. private _glVersion;
  90190. private _glRenderer;
  90191. private _glVendor;
  90192. private _videoTextureSupported;
  90193. private _renderingQueueLaunched;
  90194. private _activeRenderLoops;
  90195. private _deterministicLockstep;
  90196. private _lockstepMaxSteps;
  90197. /**
  90198. * Observable signaled when a context lost event is raised
  90199. */
  90200. onContextLostObservable: Observable<Engine>;
  90201. /**
  90202. * Observable signaled when a context restored event is raised
  90203. */
  90204. onContextRestoredObservable: Observable<Engine>;
  90205. private _onContextLost;
  90206. private _onContextRestored;
  90207. private _contextWasLost;
  90208. /** @hidden */
  90209. _doNotHandleContextLost: boolean;
  90210. /**
  90211. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90213. */
  90214. doNotHandleContextLost: boolean;
  90215. private _performanceMonitor;
  90216. private _fps;
  90217. private _deltaTime;
  90218. /**
  90219. * Turn this value on if you want to pause FPS computation when in background
  90220. */
  90221. disablePerformanceMonitorInBackground: boolean;
  90222. /**
  90223. * Gets the performance monitor attached to this engine
  90224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90225. */
  90226. readonly performanceMonitor: PerformanceMonitor;
  90227. /**
  90228. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90229. */
  90230. disableVertexArrayObjects: boolean;
  90231. /** @hidden */
  90232. protected _depthCullingState: _DepthCullingState;
  90233. /** @hidden */
  90234. protected _stencilState: _StencilState;
  90235. /** @hidden */
  90236. protected _alphaState: _AlphaState;
  90237. /** @hidden */
  90238. protected _alphaMode: number;
  90239. /** @hidden */
  90240. _internalTexturesCache: InternalTexture[];
  90241. /** @hidden */
  90242. protected _activeChannel: number;
  90243. private _currentTextureChannel;
  90244. /** @hidden */
  90245. protected _boundTexturesCache: {
  90246. [key: string]: Nullable<InternalTexture>;
  90247. };
  90248. /** @hidden */
  90249. protected _currentEffect: Nullable<Effect>;
  90250. /** @hidden */
  90251. protected _currentProgram: Nullable<WebGLProgram>;
  90252. private _compiledEffects;
  90253. private _vertexAttribArraysEnabled;
  90254. /** @hidden */
  90255. protected _cachedViewport: Nullable<Viewport>;
  90256. private _cachedVertexArrayObject;
  90257. /** @hidden */
  90258. protected _cachedVertexBuffers: any;
  90259. /** @hidden */
  90260. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90261. /** @hidden */
  90262. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90263. /** @hidden */
  90264. _currentRenderTarget: Nullable<InternalTexture>;
  90265. private _uintIndicesCurrentlySet;
  90266. private _currentBoundBuffer;
  90267. /** @hidden */
  90268. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90269. private _currentBufferPointers;
  90270. private _currentInstanceLocations;
  90271. private _currentInstanceBuffers;
  90272. private _textureUnits;
  90273. /** @hidden */
  90274. _workingCanvas: Nullable<HTMLCanvasElement>;
  90275. /** @hidden */
  90276. _workingContext: Nullable<CanvasRenderingContext2D>;
  90277. private _rescalePostProcess;
  90278. private _dummyFramebuffer;
  90279. private _externalData;
  90280. /** @hidden */
  90281. _bindedRenderFunction: any;
  90282. private _vaoRecordInProgress;
  90283. private _mustWipeVertexAttributes;
  90284. private _emptyTexture;
  90285. private _emptyCubeTexture;
  90286. private _emptyTexture3D;
  90287. /** @hidden */
  90288. _frameHandler: number;
  90289. private _nextFreeTextureSlots;
  90290. private _maxSimultaneousTextures;
  90291. private _activeRequests;
  90292. private _texturesSupported;
  90293. /** @hidden */
  90294. _textureFormatInUse: Nullable<string>;
  90295. /**
  90296. * Gets the list of texture formats supported
  90297. */
  90298. readonly texturesSupported: Array<string>;
  90299. /**
  90300. * Gets the list of texture formats in use
  90301. */
  90302. readonly textureFormatInUse: Nullable<string>;
  90303. /**
  90304. * Gets the current viewport
  90305. */
  90306. readonly currentViewport: Nullable<Viewport>;
  90307. /**
  90308. * Gets the default empty texture
  90309. */
  90310. readonly emptyTexture: InternalTexture;
  90311. /**
  90312. * Gets the default empty 3D texture
  90313. */
  90314. readonly emptyTexture3D: InternalTexture;
  90315. /**
  90316. * Gets the default empty cube texture
  90317. */
  90318. readonly emptyCubeTexture: InternalTexture;
  90319. /**
  90320. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90321. */
  90322. readonly premultipliedAlpha: boolean;
  90323. /**
  90324. * Creates a new engine
  90325. * @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
  90326. * @param antialias defines enable antialiasing (default: false)
  90327. * @param options defines further options to be sent to the getContext() function
  90328. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90329. */
  90330. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90331. /**
  90332. * Initializes a webVR display and starts listening to display change events
  90333. * The onVRDisplayChangedObservable will be notified upon these changes
  90334. * @returns The onVRDisplayChangedObservable
  90335. */
  90336. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90337. /** @hidden */
  90338. _prepareVRComponent(): void;
  90339. /** @hidden */
  90340. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90341. /** @hidden */
  90342. _submitVRFrame(): void;
  90343. /**
  90344. * Call this function to leave webVR mode
  90345. * Will do nothing if webVR is not supported or if there is no webVR device
  90346. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90347. */
  90348. disableVR(): void;
  90349. /**
  90350. * Gets a boolean indicating that the system is in VR mode and is presenting
  90351. * @returns true if VR mode is engaged
  90352. */
  90353. isVRPresenting(): boolean;
  90354. /** @hidden */
  90355. _requestVRFrame(): void;
  90356. private _disableTouchAction;
  90357. private _rebuildInternalTextures;
  90358. private _rebuildEffects;
  90359. /**
  90360. * Gets a boolean indicating if all created effects are ready
  90361. * @returns true if all effects are ready
  90362. */
  90363. areAllEffectsReady(): boolean;
  90364. private _rebuildBuffers;
  90365. private _initGLContext;
  90366. /**
  90367. * Gets version of the current webGL context
  90368. */
  90369. readonly webGLVersion: number;
  90370. /**
  90371. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90372. */
  90373. readonly isStencilEnable: boolean;
  90374. /** @hidden */
  90375. _prepareWorkingCanvas(): void;
  90376. /**
  90377. * Reset the texture cache to empty state
  90378. */
  90379. resetTextureCache(): void;
  90380. /**
  90381. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90382. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90383. * @returns true if engine is in deterministic lock step mode
  90384. */
  90385. isDeterministicLockStep(): boolean;
  90386. /**
  90387. * Gets the max steps when engine is running in deterministic lock step
  90388. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90389. * @returns the max steps
  90390. */
  90391. getLockstepMaxSteps(): number;
  90392. /**
  90393. * Gets an object containing information about the current webGL context
  90394. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90395. */
  90396. getGlInfo(): {
  90397. vendor: string;
  90398. renderer: string;
  90399. version: string;
  90400. };
  90401. /**
  90402. * Gets current aspect ratio
  90403. * @param camera defines the camera to use to get the aspect ratio
  90404. * @param useScreen defines if screen size must be used (or the current render target if any)
  90405. * @returns a number defining the aspect ratio
  90406. */
  90407. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90408. /**
  90409. * Gets current screen aspect ratio
  90410. * @returns a number defining the aspect ratio
  90411. */
  90412. getScreenAspectRatio(): number;
  90413. /**
  90414. * Gets the current render width
  90415. * @param useScreen defines if screen size must be used (or the current render target if any)
  90416. * @returns a number defining the current render width
  90417. */
  90418. getRenderWidth(useScreen?: boolean): number;
  90419. /**
  90420. * Gets the current render height
  90421. * @param useScreen defines if screen size must be used (or the current render target if any)
  90422. * @returns a number defining the current render height
  90423. */
  90424. getRenderHeight(useScreen?: boolean): number;
  90425. /**
  90426. * Gets the HTML canvas attached with the current webGL context
  90427. * @returns a HTML canvas
  90428. */
  90429. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90430. /**
  90431. * Gets the client rect of the HTML canvas attached with the current webGL context
  90432. * @returns a client rectanglee
  90433. */
  90434. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90435. /**
  90436. * Defines the hardware scaling level.
  90437. * By default the hardware scaling level is computed from the window device ratio.
  90438. * 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.
  90439. * @param level defines the level to use
  90440. */
  90441. setHardwareScalingLevel(level: number): void;
  90442. /**
  90443. * Gets the current hardware scaling level.
  90444. * By default the hardware scaling level is computed from the window device ratio.
  90445. * 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.
  90446. * @returns a number indicating the current hardware scaling level
  90447. */
  90448. getHardwareScalingLevel(): number;
  90449. /**
  90450. * Gets the list of loaded textures
  90451. * @returns an array containing all loaded textures
  90452. */
  90453. getLoadedTexturesCache(): InternalTexture[];
  90454. /**
  90455. * Gets the object containing all engine capabilities
  90456. * @returns the EngineCapabilities object
  90457. */
  90458. getCaps(): EngineCapabilities;
  90459. /**
  90460. * Gets the current depth function
  90461. * @returns a number defining the depth function
  90462. */
  90463. getDepthFunction(): Nullable<number>;
  90464. /**
  90465. * Sets the current depth function
  90466. * @param depthFunc defines the function to use
  90467. */
  90468. setDepthFunction(depthFunc: number): void;
  90469. /**
  90470. * Sets the current depth function to GREATER
  90471. */
  90472. setDepthFunctionToGreater(): void;
  90473. /**
  90474. * Sets the current depth function to GEQUAL
  90475. */
  90476. setDepthFunctionToGreaterOrEqual(): void;
  90477. /**
  90478. * Sets the current depth function to LESS
  90479. */
  90480. setDepthFunctionToLess(): void;
  90481. private _cachedStencilBuffer;
  90482. private _cachedStencilFunction;
  90483. private _cachedStencilMask;
  90484. private _cachedStencilOperationPass;
  90485. private _cachedStencilOperationFail;
  90486. private _cachedStencilOperationDepthFail;
  90487. private _cachedStencilReference;
  90488. /**
  90489. * Caches the the state of the stencil buffer
  90490. */
  90491. cacheStencilState(): void;
  90492. /**
  90493. * Restores the state of the stencil buffer
  90494. */
  90495. restoreStencilState(): void;
  90496. /**
  90497. * Sets the current depth function to LEQUAL
  90498. */
  90499. setDepthFunctionToLessOrEqual(): void;
  90500. /**
  90501. * Gets a boolean indicating if stencil buffer is enabled
  90502. * @returns the current stencil buffer state
  90503. */
  90504. getStencilBuffer(): boolean;
  90505. /**
  90506. * Enable or disable the stencil buffer
  90507. * @param enable defines if the stencil buffer must be enabled or disabled
  90508. */
  90509. setStencilBuffer(enable: boolean): void;
  90510. /**
  90511. * Gets the current stencil mask
  90512. * @returns a number defining the new stencil mask to use
  90513. */
  90514. getStencilMask(): number;
  90515. /**
  90516. * Sets the current stencil mask
  90517. * @param mask defines the new stencil mask to use
  90518. */
  90519. setStencilMask(mask: number): void;
  90520. /**
  90521. * Gets the current stencil function
  90522. * @returns a number defining the stencil function to use
  90523. */
  90524. getStencilFunction(): number;
  90525. /**
  90526. * Gets the current stencil reference value
  90527. * @returns a number defining the stencil reference value to use
  90528. */
  90529. getStencilFunctionReference(): number;
  90530. /**
  90531. * Gets the current stencil mask
  90532. * @returns a number defining the stencil mask to use
  90533. */
  90534. getStencilFunctionMask(): number;
  90535. /**
  90536. * Sets the current stencil function
  90537. * @param stencilFunc defines the new stencil function to use
  90538. */
  90539. setStencilFunction(stencilFunc: number): void;
  90540. /**
  90541. * Sets the current stencil reference
  90542. * @param reference defines the new stencil reference to use
  90543. */
  90544. setStencilFunctionReference(reference: number): void;
  90545. /**
  90546. * Sets the current stencil mask
  90547. * @param mask defines the new stencil mask to use
  90548. */
  90549. setStencilFunctionMask(mask: number): void;
  90550. /**
  90551. * Gets the current stencil operation when stencil fails
  90552. * @returns a number defining stencil operation to use when stencil fails
  90553. */
  90554. getStencilOperationFail(): number;
  90555. /**
  90556. * Gets the current stencil operation when depth fails
  90557. * @returns a number defining stencil operation to use when depth fails
  90558. */
  90559. getStencilOperationDepthFail(): number;
  90560. /**
  90561. * Gets the current stencil operation when stencil passes
  90562. * @returns a number defining stencil operation to use when stencil passes
  90563. */
  90564. getStencilOperationPass(): number;
  90565. /**
  90566. * Sets the stencil operation to use when stencil fails
  90567. * @param operation defines the stencil operation to use when stencil fails
  90568. */
  90569. setStencilOperationFail(operation: number): void;
  90570. /**
  90571. * Sets the stencil operation to use when depth fails
  90572. * @param operation defines the stencil operation to use when depth fails
  90573. */
  90574. setStencilOperationDepthFail(operation: number): void;
  90575. /**
  90576. * Sets the stencil operation to use when stencil passes
  90577. * @param operation defines the stencil operation to use when stencil passes
  90578. */
  90579. setStencilOperationPass(operation: number): void;
  90580. /**
  90581. * Sets a boolean indicating if the dithering state is enabled or disabled
  90582. * @param value defines the dithering state
  90583. */
  90584. setDitheringState(value: boolean): void;
  90585. /**
  90586. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90587. * @param value defines the rasterizer state
  90588. */
  90589. setRasterizerState(value: boolean): void;
  90590. /**
  90591. * stop executing a render loop function and remove it from the execution array
  90592. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90593. */
  90594. stopRenderLoop(renderFunction?: () => void): void;
  90595. /** @hidden */
  90596. _renderLoop(): void;
  90597. /**
  90598. * Register and execute a render loop. The engine can have more than one render function
  90599. * @param renderFunction defines the function to continuously execute
  90600. */
  90601. runRenderLoop(renderFunction: () => void): void;
  90602. /**
  90603. * Toggle full screen mode
  90604. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90605. */
  90606. switchFullscreen(requestPointerLock: boolean): void;
  90607. /**
  90608. * Enters full screen mode
  90609. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90610. */
  90611. enterFullscreen(requestPointerLock: boolean): void;
  90612. /**
  90613. * Exits full screen mode
  90614. */
  90615. exitFullscreen(): void;
  90616. /**
  90617. * Enters Pointerlock mode
  90618. */
  90619. enterPointerlock(): void;
  90620. /**
  90621. * Exits Pointerlock mode
  90622. */
  90623. exitPointerlock(): void;
  90624. /**
  90625. * Clear the current render buffer or the current render target (if any is set up)
  90626. * @param color defines the color to use
  90627. * @param backBuffer defines if the back buffer must be cleared
  90628. * @param depth defines if the depth buffer must be cleared
  90629. * @param stencil defines if the stencil buffer must be cleared
  90630. */
  90631. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90632. /**
  90633. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90634. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90635. * @param y defines the y-coordinate of the corner of the clear rectangle
  90636. * @param width defines the width of the clear rectangle
  90637. * @param height defines the height of the clear rectangle
  90638. * @param clearColor defines the clear color
  90639. */
  90640. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90641. /**
  90642. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90643. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90644. * @param y defines the y-coordinate of the corner of the clear rectangle
  90645. * @param width defines the width of the clear rectangle
  90646. * @param height defines the height of the clear rectangle
  90647. */
  90648. enableScissor(x: number, y: number, width: number, height: number): void;
  90649. /**
  90650. * Disable previously set scissor test rectangle
  90651. */
  90652. disableScissor(): void;
  90653. private _viewportCached;
  90654. /** @hidden */
  90655. _viewport(x: number, y: number, width: number, height: number): void;
  90656. /**
  90657. * Set the WebGL's viewport
  90658. * @param viewport defines the viewport element to be used
  90659. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90660. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90661. */
  90662. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90663. /**
  90664. * Directly set the WebGL Viewport
  90665. * @param x defines the x coordinate of the viewport (in screen space)
  90666. * @param y defines the y coordinate of the viewport (in screen space)
  90667. * @param width defines the width of the viewport (in screen space)
  90668. * @param height defines the height of the viewport (in screen space)
  90669. * @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
  90670. */
  90671. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90672. /**
  90673. * Begin a new frame
  90674. */
  90675. beginFrame(): void;
  90676. /**
  90677. * Enf the current frame
  90678. */
  90679. endFrame(): void;
  90680. /**
  90681. * Resize the view according to the canvas' size
  90682. */
  90683. resize(): void;
  90684. /**
  90685. * Force a specific size of the canvas
  90686. * @param width defines the new canvas' width
  90687. * @param height defines the new canvas' height
  90688. */
  90689. setSize(width: number, height: number): void;
  90690. /**
  90691. * Binds the frame buffer to the specified texture.
  90692. * @param texture The texture to render to or null for the default canvas
  90693. * @param faceIndex The face of the texture to render to in case of cube texture
  90694. * @param requiredWidth The width of the target to render to
  90695. * @param requiredHeight The height of the target to render to
  90696. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90697. * @param depthStencilTexture The depth stencil texture to use to render
  90698. * @param lodLevel defines le lod level to bind to the frame buffer
  90699. */
  90700. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90701. /** @hidden */
  90702. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90703. /**
  90704. * Unbind the current render target texture from the webGL context
  90705. * @param texture defines the render target texture to unbind
  90706. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90707. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90708. */
  90709. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90710. /**
  90711. * Force the mipmap generation for the given render target texture
  90712. * @param texture defines the render target texture to use
  90713. */
  90714. generateMipMapsForCubemap(texture: InternalTexture): void;
  90715. /**
  90716. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90717. */
  90718. flushFramebuffer(): void;
  90719. /**
  90720. * Unbind the current render target and bind the default framebuffer
  90721. */
  90722. restoreDefaultFramebuffer(): void;
  90723. /**
  90724. * Create an uniform buffer
  90725. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90726. * @param elements defines the content of the uniform buffer
  90727. * @returns the webGL uniform buffer
  90728. */
  90729. createUniformBuffer(elements: FloatArray): DataBuffer;
  90730. /**
  90731. * Create a dynamic uniform buffer
  90732. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90733. * @param elements defines the content of the uniform buffer
  90734. * @returns the webGL uniform buffer
  90735. */
  90736. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90737. /**
  90738. * Update an existing uniform buffer
  90739. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90740. * @param uniformBuffer defines the target uniform buffer
  90741. * @param elements defines the content to update
  90742. * @param offset defines the offset in the uniform buffer where update should start
  90743. * @param count defines the size of the data to update
  90744. */
  90745. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90746. private _resetVertexBufferBinding;
  90747. /**
  90748. * Creates a vertex buffer
  90749. * @param data the data for the vertex buffer
  90750. * @returns the new WebGL static buffer
  90751. */
  90752. createVertexBuffer(data: DataArray): DataBuffer;
  90753. /**
  90754. * Creates a dynamic vertex buffer
  90755. * @param data the data for the dynamic vertex buffer
  90756. * @returns the new WebGL dynamic buffer
  90757. */
  90758. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90759. /**
  90760. * Update a dynamic index buffer
  90761. * @param indexBuffer defines the target index buffer
  90762. * @param indices defines the data to update
  90763. * @param offset defines the offset in the target index buffer where update should start
  90764. */
  90765. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90766. /**
  90767. * Updates a dynamic vertex buffer.
  90768. * @param vertexBuffer the vertex buffer to update
  90769. * @param data the data used to update the vertex buffer
  90770. * @param byteOffset the byte offset of the data
  90771. * @param byteLength the byte length of the data
  90772. */
  90773. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90774. private _resetIndexBufferBinding;
  90775. /**
  90776. * Creates a new index buffer
  90777. * @param indices defines the content of the index buffer
  90778. * @param updatable defines if the index buffer must be updatable
  90779. * @returns a new webGL buffer
  90780. */
  90781. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90782. /**
  90783. * Bind a webGL buffer to the webGL context
  90784. * @param buffer defines the buffer to bind
  90785. */
  90786. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90787. /**
  90788. * Bind an uniform buffer to the current webGL context
  90789. * @param buffer defines the buffer to bind
  90790. */
  90791. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90792. /**
  90793. * Bind a buffer to the current webGL context at a given location
  90794. * @param buffer defines the buffer to bind
  90795. * @param location defines the index where to bind the buffer
  90796. */
  90797. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90798. /**
  90799. * Bind a specific block at a given index in a specific shader program
  90800. * @param pipelineContext defines the pipeline context to use
  90801. * @param blockName defines the block name
  90802. * @param index defines the index where to bind the block
  90803. */
  90804. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90805. private bindIndexBuffer;
  90806. private bindBuffer;
  90807. /**
  90808. * update the bound buffer with the given data
  90809. * @param data defines the data to update
  90810. */
  90811. updateArrayBuffer(data: Float32Array): void;
  90812. private _vertexAttribPointer;
  90813. private _bindIndexBufferWithCache;
  90814. private _bindVertexBuffersAttributes;
  90815. /**
  90816. * Records a vertex array object
  90817. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90818. * @param vertexBuffers defines the list of vertex buffers to store
  90819. * @param indexBuffer defines the index buffer to store
  90820. * @param effect defines the effect to store
  90821. * @returns the new vertex array object
  90822. */
  90823. recordVertexArrayObject(vertexBuffers: {
  90824. [key: string]: VertexBuffer;
  90825. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  90826. /**
  90827. * Bind a specific vertex array object
  90828. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90829. * @param vertexArrayObject defines the vertex array object to bind
  90830. * @param indexBuffer defines the index buffer to bind
  90831. */
  90832. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  90833. /**
  90834. * Bind webGl buffers directly to the webGL context
  90835. * @param vertexBuffer defines the vertex buffer to bind
  90836. * @param indexBuffer defines the index buffer to bind
  90837. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  90838. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  90839. * @param effect defines the effect associated with the vertex buffer
  90840. */
  90841. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  90842. private _unbindVertexArrayObject;
  90843. /**
  90844. * Bind a list of vertex buffers to the webGL context
  90845. * @param vertexBuffers defines the list of vertex buffers to bind
  90846. * @param indexBuffer defines the index buffer to bind
  90847. * @param effect defines the effect associated with the vertex buffers
  90848. */
  90849. bindBuffers(vertexBuffers: {
  90850. [key: string]: Nullable<VertexBuffer>;
  90851. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  90852. /**
  90853. * Unbind all instance attributes
  90854. */
  90855. unbindInstanceAttributes(): void;
  90856. /**
  90857. * Release and free the memory of a vertex array object
  90858. * @param vao defines the vertex array object to delete
  90859. */
  90860. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  90861. /** @hidden */
  90862. _releaseBuffer(buffer: DataBuffer): boolean;
  90863. /**
  90864. * Creates a webGL buffer to use with instanciation
  90865. * @param capacity defines the size of the buffer
  90866. * @returns the webGL buffer
  90867. */
  90868. createInstancesBuffer(capacity: number): DataBuffer;
  90869. /**
  90870. * Delete a webGL buffer used with instanciation
  90871. * @param buffer defines the webGL buffer to delete
  90872. */
  90873. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  90874. /**
  90875. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  90876. * @param instancesBuffer defines the webGL buffer to update and bind
  90877. * @param data defines the data to store in the buffer
  90878. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  90879. */
  90880. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  90881. /**
  90882. * Apply all cached states (depth, culling, stencil and alpha)
  90883. */
  90884. applyStates(): void;
  90885. /**
  90886. * Send a draw order
  90887. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90888. * @param indexStart defines the starting index
  90889. * @param indexCount defines the number of index to draw
  90890. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90891. */
  90892. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  90893. /**
  90894. * Draw a list of points
  90895. * @param verticesStart defines the index of first vertex to draw
  90896. * @param verticesCount defines the count of vertices to draw
  90897. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90898. */
  90899. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90900. /**
  90901. * Draw a list of unindexed primitives
  90902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90903. * @param verticesStart defines the index of first vertex to draw
  90904. * @param verticesCount defines the count of vertices to draw
  90905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90906. */
  90907. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90908. /**
  90909. * Draw a list of indexed primitives
  90910. * @param fillMode defines the primitive to use
  90911. * @param indexStart defines the starting index
  90912. * @param indexCount defines the number of index to draw
  90913. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90914. */
  90915. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  90916. /**
  90917. * Draw a list of unindexed primitives
  90918. * @param fillMode defines the primitive to use
  90919. * @param verticesStart defines the index of first vertex to draw
  90920. * @param verticesCount defines the count of vertices to draw
  90921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90922. */
  90923. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90924. private _drawMode;
  90925. /** @hidden */
  90926. _releaseEffect(effect: Effect): void;
  90927. /** @hidden */
  90928. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  90929. /**
  90930. * Create a new effect (used to store vertex/fragment shaders)
  90931. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  90932. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  90933. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  90934. * @param samplers defines an array of string used to represent textures
  90935. * @param defines defines the string containing the defines to use to compile the shaders
  90936. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  90937. * @param onCompiled defines a function to call when the effect creation is successful
  90938. * @param onError defines a function to call when the effect creation has failed
  90939. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  90940. * @returns the new Effect
  90941. */
  90942. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  90943. private _compileShader;
  90944. private _compileRawShader;
  90945. /**
  90946. * Directly creates a webGL program
  90947. * @param pipelineContext defines the pipeline context to attach to
  90948. * @param vertexCode defines the vertex shader code to use
  90949. * @param fragmentCode defines the fragment shader code to use
  90950. * @param context defines the webGL context to use (if not set, the current one will be used)
  90951. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90952. * @returns the new webGL program
  90953. */
  90954. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90955. /**
  90956. * Creates a webGL program
  90957. * @param pipelineContext defines the pipeline context to attach to
  90958. * @param vertexCode defines the vertex shader code to use
  90959. * @param fragmentCode defines the fragment shader code to use
  90960. * @param defines defines the string containing the defines to use to compile the shaders
  90961. * @param context defines the webGL context to use (if not set, the current one will be used)
  90962. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90963. * @returns the new webGL program
  90964. */
  90965. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90966. /**
  90967. * Creates a new pipeline context
  90968. * @returns the new pipeline
  90969. */
  90970. createPipelineContext(): WebGLPipelineContext;
  90971. private _createShaderProgram;
  90972. private _finalizePipelineContext;
  90973. /** @hidden */
  90974. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  90975. /** @hidden */
  90976. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  90977. /** @hidden */
  90978. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  90979. /**
  90980. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  90981. * @param pipelineContext defines the pipeline context to use
  90982. * @param uniformsNames defines the list of uniform names
  90983. * @returns an array of webGL uniform locations
  90984. */
  90985. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  90986. /**
  90987. * Gets the lsit of active attributes for a given webGL program
  90988. * @param pipelineContext defines the pipeline context to use
  90989. * @param attributesNames defines the list of attribute names to get
  90990. * @returns an array of indices indicating the offset of each attribute
  90991. */
  90992. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  90993. /**
  90994. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  90995. * @param effect defines the effect to activate
  90996. */
  90997. enableEffect(effect: Nullable<Effect>): void;
  90998. /**
  90999. * Set the value of an uniform to an array of int32
  91000. * @param uniform defines the webGL uniform location where to store the value
  91001. * @param array defines the array of int32 to store
  91002. */
  91003. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91004. /**
  91005. * Set the value of an uniform to an array of int32 (stored as vec2)
  91006. * @param uniform defines the webGL uniform location where to store the value
  91007. * @param array defines the array of int32 to store
  91008. */
  91009. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91010. /**
  91011. * Set the value of an uniform to an array of int32 (stored as vec3)
  91012. * @param uniform defines the webGL uniform location where to store the value
  91013. * @param array defines the array of int32 to store
  91014. */
  91015. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91016. /**
  91017. * Set the value of an uniform to an array of int32 (stored as vec4)
  91018. * @param uniform defines the webGL uniform location where to store the value
  91019. * @param array defines the array of int32 to store
  91020. */
  91021. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91022. /**
  91023. * Set the value of an uniform to an array of float32
  91024. * @param uniform defines the webGL uniform location where to store the value
  91025. * @param array defines the array of float32 to store
  91026. */
  91027. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91028. /**
  91029. * Set the value of an uniform to an array of float32 (stored as vec2)
  91030. * @param uniform defines the webGL uniform location where to store the value
  91031. * @param array defines the array of float32 to store
  91032. */
  91033. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91034. /**
  91035. * Set the value of an uniform to an array of float32 (stored as vec3)
  91036. * @param uniform defines the webGL uniform location where to store the value
  91037. * @param array defines the array of float32 to store
  91038. */
  91039. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91040. /**
  91041. * Set the value of an uniform to an array of float32 (stored as vec4)
  91042. * @param uniform defines the webGL uniform location where to store the value
  91043. * @param array defines the array of float32 to store
  91044. */
  91045. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91046. /**
  91047. * Set the value of an uniform to an array of number
  91048. * @param uniform defines the webGL uniform location where to store the value
  91049. * @param array defines the array of number to store
  91050. */
  91051. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91052. /**
  91053. * Set the value of an uniform to an array of number (stored as vec2)
  91054. * @param uniform defines the webGL uniform location where to store the value
  91055. * @param array defines the array of number to store
  91056. */
  91057. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91058. /**
  91059. * Set the value of an uniform to an array of number (stored as vec3)
  91060. * @param uniform defines the webGL uniform location where to store the value
  91061. * @param array defines the array of number to store
  91062. */
  91063. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91064. /**
  91065. * Set the value of an uniform to an array of number (stored as vec4)
  91066. * @param uniform defines the webGL uniform location where to store the value
  91067. * @param array defines the array of number to store
  91068. */
  91069. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91070. /**
  91071. * Set the value of an uniform to an array of float32 (stored as matrices)
  91072. * @param uniform defines the webGL uniform location where to store the value
  91073. * @param matrices defines the array of float32 to store
  91074. */
  91075. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91076. /**
  91077. * Set the value of an uniform to a matrix
  91078. * @param uniform defines the webGL uniform location where to store the value
  91079. * @param matrix defines the matrix to store
  91080. */
  91081. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91082. /**
  91083. * Set the value of an uniform to a matrix (3x3)
  91084. * @param uniform defines the webGL uniform location where to store the value
  91085. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91086. */
  91087. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91088. /**
  91089. * Set the value of an uniform to a matrix (2x2)
  91090. * @param uniform defines the webGL uniform location where to store the value
  91091. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91092. */
  91093. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91094. /**
  91095. * Set the value of an uniform to a number (int)
  91096. * @param uniform defines the webGL uniform location where to store the value
  91097. * @param value defines the int number to store
  91098. */
  91099. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91100. /**
  91101. * Set the value of an uniform to a number (float)
  91102. * @param uniform defines the webGL uniform location where to store the value
  91103. * @param value defines the float number to store
  91104. */
  91105. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91106. /**
  91107. * Set the value of an uniform to a vec2
  91108. * @param uniform defines the webGL uniform location where to store the value
  91109. * @param x defines the 1st component of the value
  91110. * @param y defines the 2nd component of the value
  91111. */
  91112. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91113. /**
  91114. * Set the value of an uniform to a vec3
  91115. * @param uniform defines the webGL uniform location where to store the value
  91116. * @param x defines the 1st component of the value
  91117. * @param y defines the 2nd component of the value
  91118. * @param z defines the 3rd component of the value
  91119. */
  91120. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91121. /**
  91122. * Set the value of an uniform to a boolean
  91123. * @param uniform defines the webGL uniform location where to store the value
  91124. * @param bool defines the boolean to store
  91125. */
  91126. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91127. /**
  91128. * Set the value of an uniform to a vec4
  91129. * @param uniform defines the webGL uniform location where to store the value
  91130. * @param x defines the 1st component of the value
  91131. * @param y defines the 2nd component of the value
  91132. * @param z defines the 3rd component of the value
  91133. * @param w defines the 4th component of the value
  91134. */
  91135. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91136. /**
  91137. * Set the value of an uniform to a Color3
  91138. * @param uniform defines the webGL uniform location where to store the value
  91139. * @param color3 defines the color to store
  91140. */
  91141. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91142. /**
  91143. * Set the value of an uniform to a Color3 and an alpha value
  91144. * @param uniform defines the webGL uniform location where to store the value
  91145. * @param color3 defines the color to store
  91146. * @param alpha defines the alpha component to store
  91147. */
  91148. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91149. /**
  91150. * Sets a Color4 on a uniform variable
  91151. * @param uniform defines the uniform location
  91152. * @param color4 defines the value to be set
  91153. */
  91154. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91155. /**
  91156. * Set various states to the webGL context
  91157. * @param culling defines backface culling state
  91158. * @param zOffset defines the value to apply to zOffset (0 by default)
  91159. * @param force defines if states must be applied even if cache is up to date
  91160. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91161. */
  91162. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91163. /**
  91164. * Set the z offset to apply to current rendering
  91165. * @param value defines the offset to apply
  91166. */
  91167. setZOffset(value: number): void;
  91168. /**
  91169. * Gets the current value of the zOffset
  91170. * @returns the current zOffset state
  91171. */
  91172. getZOffset(): number;
  91173. /**
  91174. * Enable or disable depth buffering
  91175. * @param enable defines the state to set
  91176. */
  91177. setDepthBuffer(enable: boolean): void;
  91178. /**
  91179. * Gets a boolean indicating if depth writing is enabled
  91180. * @returns the current depth writing state
  91181. */
  91182. getDepthWrite(): boolean;
  91183. /**
  91184. * Enable or disable depth writing
  91185. * @param enable defines the state to set
  91186. */
  91187. setDepthWrite(enable: boolean): void;
  91188. /**
  91189. * Enable or disable color writing
  91190. * @param enable defines the state to set
  91191. */
  91192. setColorWrite(enable: boolean): void;
  91193. /**
  91194. * Gets a boolean indicating if color writing is enabled
  91195. * @returns the current color writing state
  91196. */
  91197. getColorWrite(): boolean;
  91198. /**
  91199. * Sets alpha constants used by some alpha blending modes
  91200. * @param r defines the red component
  91201. * @param g defines the green component
  91202. * @param b defines the blue component
  91203. * @param a defines the alpha component
  91204. */
  91205. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91206. /**
  91207. * Sets the current alpha mode
  91208. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91209. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91211. */
  91212. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91213. /**
  91214. * Gets the current alpha mode
  91215. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91216. * @returns the current alpha mode
  91217. */
  91218. getAlphaMode(): number;
  91219. /**
  91220. * Clears the list of texture accessible through engine.
  91221. * This can help preventing texture load conflict due to name collision.
  91222. */
  91223. clearInternalTexturesCache(): void;
  91224. /**
  91225. * Force the entire cache to be cleared
  91226. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91227. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91228. */
  91229. wipeCaches(bruteForce?: boolean): void;
  91230. /**
  91231. * Set the compressed texture format to use, based on the formats you have, and the formats
  91232. * supported by the hardware / browser.
  91233. *
  91234. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91235. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91236. * to API arguments needed to compressed textures. This puts the burden on the container
  91237. * generator to house the arcane code for determining these for current & future formats.
  91238. *
  91239. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91240. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91241. *
  91242. * Note: The result of this call is not taken into account when a texture is base64.
  91243. *
  91244. * @param formatsAvailable defines the list of those format families you have created
  91245. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91246. *
  91247. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91248. * @returns The extension selected.
  91249. */
  91250. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91251. /** @hidden */
  91252. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91253. min: number;
  91254. mag: number;
  91255. };
  91256. /** @hidden */
  91257. _createTexture(): WebGLTexture;
  91258. /**
  91259. * Usually called from Texture.ts.
  91260. * Passed information to create a WebGLTexture
  91261. * @param urlArg defines a value which contains one of the following:
  91262. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91263. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91264. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91265. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91266. * @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)
  91267. * @param scene needed for loading to the correct scene
  91268. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91269. * @param onLoad optional callback to be called upon successful completion
  91270. * @param onError optional callback to be called upon failure
  91271. * @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
  91272. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91273. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91274. * @param forcedExtension defines the extension to use to pick the right loader
  91275. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91276. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91277. */
  91278. 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;
  91279. private _rescaleTexture;
  91280. private _unpackFlipYCached;
  91281. /**
  91282. * In case you are sharing the context with other applications, it might
  91283. * be interested to not cache the unpack flip y state to ensure a consistent
  91284. * value would be set.
  91285. */
  91286. enableUnpackFlipYCached: boolean;
  91287. /** @hidden */
  91288. _unpackFlipY(value: boolean): void;
  91289. /** @hidden */
  91290. _getUnpackAlignement(): number;
  91291. /**
  91292. * Creates a dynamic texture
  91293. * @param width defines the width of the texture
  91294. * @param height defines the height of the texture
  91295. * @param generateMipMaps defines if the engine should generate the mip levels
  91296. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91297. * @returns the dynamic texture inside an InternalTexture
  91298. */
  91299. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91300. /**
  91301. * Update the sampling mode of a given texture
  91302. * @param samplingMode defines the required sampling mode
  91303. * @param texture defines the texture to update
  91304. */
  91305. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91306. /**
  91307. * Update the content of a dynamic texture
  91308. * @param texture defines the texture to update
  91309. * @param canvas defines the canvas containing the source
  91310. * @param invertY defines if data must be stored with Y axis inverted
  91311. * @param premulAlpha defines if alpha is stored as premultiplied
  91312. * @param format defines the format of the data
  91313. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91314. */
  91315. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91316. /**
  91317. * Update a video texture
  91318. * @param texture defines the texture to update
  91319. * @param video defines the video element to use
  91320. * @param invertY defines if data must be stored with Y axis inverted
  91321. */
  91322. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91323. /**
  91324. * Updates a depth texture Comparison Mode and Function.
  91325. * If the comparison Function is equal to 0, the mode will be set to none.
  91326. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91327. * @param texture The texture to set the comparison function for
  91328. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91329. */
  91330. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91331. /** @hidden */
  91332. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91333. width: number;
  91334. height: number;
  91335. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91336. /**
  91337. * Creates a depth stencil texture.
  91338. * This is only available in WebGL 2 or with the depth texture extension available.
  91339. * @param size The size of face edge in the texture.
  91340. * @param options The options defining the texture.
  91341. * @returns The texture
  91342. */
  91343. createDepthStencilTexture(size: number | {
  91344. width: number;
  91345. height: number;
  91346. }, options: DepthTextureCreationOptions): InternalTexture;
  91347. /**
  91348. * Creates a depth stencil texture.
  91349. * This is only available in WebGL 2 or with the depth texture extension available.
  91350. * @param size The size of face edge in the texture.
  91351. * @param options The options defining the texture.
  91352. * @returns The texture
  91353. */
  91354. private _createDepthStencilTexture;
  91355. /**
  91356. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91357. * @param renderTarget The render target to set the frame buffer for
  91358. */
  91359. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91360. /**
  91361. * Creates a new render target texture
  91362. * @param size defines the size of the texture
  91363. * @param options defines the options used to create the texture
  91364. * @returns a new render target texture stored in an InternalTexture
  91365. */
  91366. createRenderTargetTexture(size: number | {
  91367. width: number;
  91368. height: number;
  91369. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91370. /** @hidden */
  91371. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91372. /**
  91373. * Updates the sample count of a render target texture
  91374. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91375. * @param texture defines the texture to update
  91376. * @param samples defines the sample count to set
  91377. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91378. */
  91379. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91380. /** @hidden */
  91381. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91382. /** @hidden */
  91383. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91384. /** @hidden */
  91385. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91386. /** @hidden */
  91387. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91388. /**
  91389. * @hidden
  91390. */
  91391. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91392. private _prepareWebGLTextureContinuation;
  91393. private _prepareWebGLTexture;
  91394. /** @hidden */
  91395. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91396. /** @hidden */
  91397. _releaseFramebufferObjects(texture: InternalTexture): void;
  91398. /** @hidden */
  91399. _releaseTexture(texture: InternalTexture): void;
  91400. private setProgram;
  91401. private _boundUniforms;
  91402. /**
  91403. * Binds an effect to the webGL context
  91404. * @param effect defines the effect to bind
  91405. */
  91406. bindSamplers(effect: Effect): void;
  91407. private _activateCurrentTexture;
  91408. /** @hidden */
  91409. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91410. /** @hidden */
  91411. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91412. /**
  91413. * Sets a texture to the webGL context from a postprocess
  91414. * @param channel defines the channel to use
  91415. * @param postProcess defines the source postprocess
  91416. */
  91417. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91418. /**
  91419. * Binds the output of the passed in post process to the texture channel specified
  91420. * @param channel The channel the texture should be bound to
  91421. * @param postProcess The post process which's output should be bound
  91422. */
  91423. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91424. /**
  91425. * Unbind all textures from the webGL context
  91426. */
  91427. unbindAllTextures(): void;
  91428. /**
  91429. * Sets a texture to the according uniform.
  91430. * @param channel The texture channel
  91431. * @param uniform The uniform to set
  91432. * @param texture The texture to apply
  91433. */
  91434. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91435. /**
  91436. * Sets a depth stencil texture from a render target to the according uniform.
  91437. * @param channel The texture channel
  91438. * @param uniform The uniform to set
  91439. * @param texture The render target texture containing the depth stencil texture to apply
  91440. */
  91441. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91442. private _bindSamplerUniformToChannel;
  91443. private _getTextureWrapMode;
  91444. private _setTexture;
  91445. /**
  91446. * Sets an array of texture to the webGL context
  91447. * @param channel defines the channel where the texture array must be set
  91448. * @param uniform defines the associated uniform location
  91449. * @param textures defines the array of textures to bind
  91450. */
  91451. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91452. /** @hidden */
  91453. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91454. private _setTextureParameterFloat;
  91455. private _setTextureParameterInteger;
  91456. /**
  91457. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91458. * @param x defines the x coordinate of the rectangle where pixels must be read
  91459. * @param y defines the y coordinate of the rectangle where pixels must be read
  91460. * @param width defines the width of the rectangle where pixels must be read
  91461. * @param height defines the height of the rectangle where pixels must be read
  91462. * @returns a Uint8Array containing RGBA colors
  91463. */
  91464. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91465. /**
  91466. * Add an externaly attached data from its key.
  91467. * This method call will fail and return false, if such key already exists.
  91468. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91469. * @param key the unique key that identifies the data
  91470. * @param data the data object to associate to the key for this Engine instance
  91471. * @return true if no such key were already present and the data was added successfully, false otherwise
  91472. */
  91473. addExternalData<T>(key: string, data: T): boolean;
  91474. /**
  91475. * Get an externaly attached data from its key
  91476. * @param key the unique key that identifies the data
  91477. * @return the associated data, if present (can be null), or undefined if not present
  91478. */
  91479. getExternalData<T>(key: string): T;
  91480. /**
  91481. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91482. * @param key the unique key that identifies the data
  91483. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91484. * @return the associated data, can be null if the factory returned null.
  91485. */
  91486. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91487. /**
  91488. * Remove an externaly attached data from the Engine instance
  91489. * @param key the unique key that identifies the data
  91490. * @return true if the data was successfully removed, false if it doesn't exist
  91491. */
  91492. removeExternalData(key: string): boolean;
  91493. /**
  91494. * Unbind all vertex attributes from the webGL context
  91495. */
  91496. unbindAllAttributes(): void;
  91497. /**
  91498. * 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
  91499. */
  91500. releaseEffects(): void;
  91501. /**
  91502. * Dispose and release all associated resources
  91503. */
  91504. dispose(): void;
  91505. /**
  91506. * Display the loading screen
  91507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91508. */
  91509. displayLoadingUI(): void;
  91510. /**
  91511. * Hide the loading screen
  91512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91513. */
  91514. hideLoadingUI(): void;
  91515. /**
  91516. * Gets the current loading screen object
  91517. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91518. */
  91519. /**
  91520. * Sets the current loading screen object
  91521. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91522. */
  91523. loadingScreen: ILoadingScreen;
  91524. /**
  91525. * Sets the current loading screen text
  91526. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91527. */
  91528. loadingUIText: string;
  91529. /**
  91530. * Sets the current loading screen background color
  91531. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91532. */
  91533. loadingUIBackgroundColor: string;
  91534. /**
  91535. * Attach a new callback raised when context lost event is fired
  91536. * @param callback defines the callback to call
  91537. */
  91538. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91539. /**
  91540. * Attach a new callback raised when context restored event is fired
  91541. * @param callback defines the callback to call
  91542. */
  91543. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91544. /**
  91545. * Gets the source code of the vertex shader associated with a specific webGL program
  91546. * @param program defines the program to use
  91547. * @returns a string containing the source code of the vertex shader associated with the program
  91548. */
  91549. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91550. /**
  91551. * Gets the source code of the fragment shader associated with a specific webGL program
  91552. * @param program defines the program to use
  91553. * @returns a string containing the source code of the fragment shader associated with the program
  91554. */
  91555. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91556. /**
  91557. * Get the current error code of the webGL context
  91558. * @returns the error code
  91559. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91560. */
  91561. getError(): number;
  91562. /**
  91563. * Gets the current framerate
  91564. * @returns a number representing the framerate
  91565. */
  91566. getFps(): number;
  91567. /**
  91568. * Gets the time spent between current and previous frame
  91569. * @returns a number representing the delta time in ms
  91570. */
  91571. getDeltaTime(): number;
  91572. private _measureFps;
  91573. /** @hidden */
  91574. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91575. private _canRenderToFloatFramebuffer;
  91576. private _canRenderToHalfFloatFramebuffer;
  91577. private _canRenderToFramebuffer;
  91578. /** @hidden */
  91579. _getWebGLTextureType(type: number): number;
  91580. /** @hidden */
  91581. _getInternalFormat(format: number): number;
  91582. /** @hidden */
  91583. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91584. /** @hidden */
  91585. _getRGBAMultiSampleBufferFormat(type: number): number;
  91586. /** @hidden */
  91587. _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;
  91588. /** @hidden */
  91589. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91590. /**
  91591. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91592. * @returns true if the engine can be created
  91593. * @ignorenaming
  91594. */
  91595. static isSupported(): boolean;
  91596. }
  91597. }
  91598. declare module BABYLON {
  91599. /**
  91600. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91601. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91602. */
  91603. export class EffectFallbacks {
  91604. private _defines;
  91605. private _currentRank;
  91606. private _maxRank;
  91607. private _mesh;
  91608. /**
  91609. * Removes the fallback from the bound mesh.
  91610. */
  91611. unBindMesh(): void;
  91612. /**
  91613. * Adds a fallback on the specified property.
  91614. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91615. * @param define The name of the define in the shader
  91616. */
  91617. addFallback(rank: number, define: string): void;
  91618. /**
  91619. * Sets the mesh to use CPU skinning when needing to fallback.
  91620. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91621. * @param mesh The mesh to use the fallbacks.
  91622. */
  91623. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91624. /**
  91625. * Checks to see if more fallbacks are still availible.
  91626. */
  91627. readonly isMoreFallbacks: boolean;
  91628. /**
  91629. * Removes the defines that should be removed when falling back.
  91630. * @param currentDefines defines the current define statements for the shader.
  91631. * @param effect defines the current effect we try to compile
  91632. * @returns The resulting defines with defines of the current rank removed.
  91633. */
  91634. reduce(currentDefines: string, effect: Effect): string;
  91635. }
  91636. /**
  91637. * Options to be used when creating an effect.
  91638. */
  91639. export class EffectCreationOptions {
  91640. /**
  91641. * Atrributes that will be used in the shader.
  91642. */
  91643. attributes: string[];
  91644. /**
  91645. * Uniform varible names that will be set in the shader.
  91646. */
  91647. uniformsNames: string[];
  91648. /**
  91649. * Uniform buffer varible names that will be set in the shader.
  91650. */
  91651. uniformBuffersNames: string[];
  91652. /**
  91653. * Sampler texture variable names that will be set in the shader.
  91654. */
  91655. samplers: string[];
  91656. /**
  91657. * Define statements that will be set in the shader.
  91658. */
  91659. defines: any;
  91660. /**
  91661. * Possible fallbacks for this effect to improve performance when needed.
  91662. */
  91663. fallbacks: Nullable<EffectFallbacks>;
  91664. /**
  91665. * Callback that will be called when the shader is compiled.
  91666. */
  91667. onCompiled: Nullable<(effect: Effect) => void>;
  91668. /**
  91669. * Callback that will be called if an error occurs during shader compilation.
  91670. */
  91671. onError: Nullable<(effect: Effect, errors: string) => void>;
  91672. /**
  91673. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91674. */
  91675. indexParameters: any;
  91676. /**
  91677. * Max number of lights that can be used in the shader.
  91678. */
  91679. maxSimultaneousLights: number;
  91680. /**
  91681. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91682. */
  91683. transformFeedbackVaryings: Nullable<string[]>;
  91684. }
  91685. /**
  91686. * Effect containing vertex and fragment shader that can be executed on an object.
  91687. */
  91688. export class Effect implements IDisposable {
  91689. /**
  91690. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91691. */
  91692. static ShadersRepository: string;
  91693. /**
  91694. * Name of the effect.
  91695. */
  91696. name: any;
  91697. /**
  91698. * String container all the define statements that should be set on the shader.
  91699. */
  91700. defines: string;
  91701. /**
  91702. * Callback that will be called when the shader is compiled.
  91703. */
  91704. onCompiled: Nullable<(effect: Effect) => void>;
  91705. /**
  91706. * Callback that will be called if an error occurs during shader compilation.
  91707. */
  91708. onError: Nullable<(effect: Effect, errors: string) => void>;
  91709. /**
  91710. * Callback that will be called when effect is bound.
  91711. */
  91712. onBind: Nullable<(effect: Effect) => void>;
  91713. /**
  91714. * Unique ID of the effect.
  91715. */
  91716. uniqueId: number;
  91717. /**
  91718. * Observable that will be called when the shader is compiled.
  91719. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91720. */
  91721. onCompileObservable: Observable<Effect>;
  91722. /**
  91723. * Observable that will be called if an error occurs during shader compilation.
  91724. */
  91725. onErrorObservable: Observable<Effect>;
  91726. /** @hidden */
  91727. _onBindObservable: Nullable<Observable<Effect>>;
  91728. /**
  91729. * Observable that will be called when effect is bound.
  91730. */
  91731. readonly onBindObservable: Observable<Effect>;
  91732. /** @hidden */
  91733. _bonesComputationForcedToCPU: boolean;
  91734. private static _uniqueIdSeed;
  91735. private _engine;
  91736. private _uniformBuffersNames;
  91737. private _uniformsNames;
  91738. private _samplerList;
  91739. private _samplers;
  91740. private _isReady;
  91741. private _compilationError;
  91742. private _attributesNames;
  91743. private _attributes;
  91744. private _uniforms;
  91745. /**
  91746. * Key for the effect.
  91747. * @hidden
  91748. */
  91749. _key: string;
  91750. private _indexParameters;
  91751. private _fallbacks;
  91752. private _vertexSourceCode;
  91753. private _fragmentSourceCode;
  91754. private _vertexSourceCodeOverride;
  91755. private _fragmentSourceCodeOverride;
  91756. private _transformFeedbackVaryings;
  91757. /**
  91758. * Compiled shader to webGL program.
  91759. * @hidden
  91760. */
  91761. _pipelineContext: Nullable<IPipelineContext>;
  91762. private _valueCache;
  91763. private static _baseCache;
  91764. /**
  91765. * Instantiates an effect.
  91766. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91767. * @param baseName Name of the effect.
  91768. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91769. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91770. * @param samplers List of sampler variables that will be passed to the shader.
  91771. * @param engine Engine to be used to render the effect
  91772. * @param defines Define statements to be added to the shader.
  91773. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91774. * @param onCompiled Callback that will be called when the shader is compiled.
  91775. * @param onError Callback that will be called if an error occurs during shader compilation.
  91776. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91777. */
  91778. 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);
  91779. private _useFinalCode;
  91780. /**
  91781. * Unique key for this effect
  91782. */
  91783. readonly key: string;
  91784. /**
  91785. * If the effect has been compiled and prepared.
  91786. * @returns if the effect is compiled and prepared.
  91787. */
  91788. isReady(): boolean;
  91789. /**
  91790. * The engine the effect was initialized with.
  91791. * @returns the engine.
  91792. */
  91793. getEngine(): Engine;
  91794. /**
  91795. * The pipeline context for this effect
  91796. * @returns the associated pipeline context
  91797. */
  91798. getPipelineContext(): Nullable<IPipelineContext>;
  91799. /**
  91800. * The set of names of attribute variables for the shader.
  91801. * @returns An array of attribute names.
  91802. */
  91803. getAttributesNames(): string[];
  91804. /**
  91805. * Returns the attribute at the given index.
  91806. * @param index The index of the attribute.
  91807. * @returns The location of the attribute.
  91808. */
  91809. getAttributeLocation(index: number): number;
  91810. /**
  91811. * Returns the attribute based on the name of the variable.
  91812. * @param name of the attribute to look up.
  91813. * @returns the attribute location.
  91814. */
  91815. getAttributeLocationByName(name: string): number;
  91816. /**
  91817. * The number of attributes.
  91818. * @returns the numnber of attributes.
  91819. */
  91820. getAttributesCount(): number;
  91821. /**
  91822. * Gets the index of a uniform variable.
  91823. * @param uniformName of the uniform to look up.
  91824. * @returns the index.
  91825. */
  91826. getUniformIndex(uniformName: string): number;
  91827. /**
  91828. * Returns the attribute based on the name of the variable.
  91829. * @param uniformName of the uniform to look up.
  91830. * @returns the location of the uniform.
  91831. */
  91832. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91833. /**
  91834. * Returns an array of sampler variable names
  91835. * @returns The array of sampler variable neames.
  91836. */
  91837. getSamplers(): string[];
  91838. /**
  91839. * The error from the last compilation.
  91840. * @returns the error string.
  91841. */
  91842. getCompilationError(): string;
  91843. /**
  91844. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91845. * @param func The callback to be used.
  91846. */
  91847. executeWhenCompiled(func: (effect: Effect) => void): void;
  91848. private _checkIsReady;
  91849. /** @hidden */
  91850. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91851. /** @hidden */
  91852. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91853. /** @hidden */
  91854. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91855. /**
  91856. * Recompiles the webGL program
  91857. * @param vertexSourceCode The source code for the vertex shader.
  91858. * @param fragmentSourceCode The source code for the fragment shader.
  91859. * @param onCompiled Callback called when completed.
  91860. * @param onError Callback called on error.
  91861. * @hidden
  91862. */
  91863. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91864. /**
  91865. * Prepares the effect
  91866. * @hidden
  91867. */
  91868. _prepareEffect(): void;
  91869. /**
  91870. * Checks if the effect is supported. (Must be called after compilation)
  91871. */
  91872. readonly isSupported: boolean;
  91873. /**
  91874. * Binds a texture to the engine to be used as output of the shader.
  91875. * @param channel Name of the output variable.
  91876. * @param texture Texture to bind.
  91877. * @hidden
  91878. */
  91879. _bindTexture(channel: string, texture: InternalTexture): void;
  91880. /**
  91881. * Sets a texture on the engine to be used in the shader.
  91882. * @param channel Name of the sampler variable.
  91883. * @param texture Texture to set.
  91884. */
  91885. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  91886. /**
  91887. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  91888. * @param channel Name of the sampler variable.
  91889. * @param texture Texture to set.
  91890. */
  91891. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  91892. /**
  91893. * Sets an array of textures on the engine to be used in the shader.
  91894. * @param channel Name of the variable.
  91895. * @param textures Textures to set.
  91896. */
  91897. setTextureArray(channel: string, textures: BaseTexture[]): void;
  91898. /**
  91899. * 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)
  91900. * @param channel Name of the sampler variable.
  91901. * @param postProcess Post process to get the input texture from.
  91902. */
  91903. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  91904. /**
  91905. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  91906. * 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)
  91907. * @param channel Name of the sampler variable.
  91908. * @param postProcess Post process to get the output texture from.
  91909. */
  91910. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  91911. /** @hidden */
  91912. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  91913. /** @hidden */
  91914. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  91915. /** @hidden */
  91916. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  91917. /** @hidden */
  91918. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  91919. /**
  91920. * Binds a buffer to a uniform.
  91921. * @param buffer Buffer to bind.
  91922. * @param name Name of the uniform variable to bind to.
  91923. */
  91924. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  91925. /**
  91926. * Binds block to a uniform.
  91927. * @param blockName Name of the block to bind.
  91928. * @param index Index to bind.
  91929. */
  91930. bindUniformBlock(blockName: string, index: number): void;
  91931. /**
  91932. * Sets an interger value on a uniform variable.
  91933. * @param uniformName Name of the variable.
  91934. * @param value Value to be set.
  91935. * @returns this effect.
  91936. */
  91937. setInt(uniformName: string, value: number): Effect;
  91938. /**
  91939. * Sets an int array on a uniform variable.
  91940. * @param uniformName Name of the variable.
  91941. * @param array array to be set.
  91942. * @returns this effect.
  91943. */
  91944. setIntArray(uniformName: string, array: Int32Array): Effect;
  91945. /**
  91946. * 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)
  91947. * @param uniformName Name of the variable.
  91948. * @param array array to be set.
  91949. * @returns this effect.
  91950. */
  91951. setIntArray2(uniformName: string, array: Int32Array): Effect;
  91952. /**
  91953. * 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)
  91954. * @param uniformName Name of the variable.
  91955. * @param array array to be set.
  91956. * @returns this effect.
  91957. */
  91958. setIntArray3(uniformName: string, array: Int32Array): Effect;
  91959. /**
  91960. * 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)
  91961. * @param uniformName Name of the variable.
  91962. * @param array array to be set.
  91963. * @returns this effect.
  91964. */
  91965. setIntArray4(uniformName: string, array: Int32Array): Effect;
  91966. /**
  91967. * Sets an float array on a uniform variable.
  91968. * @param uniformName Name of the variable.
  91969. * @param array array to be set.
  91970. * @returns this effect.
  91971. */
  91972. setFloatArray(uniformName: string, array: Float32Array): Effect;
  91973. /**
  91974. * 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)
  91975. * @param uniformName Name of the variable.
  91976. * @param array array to be set.
  91977. * @returns this effect.
  91978. */
  91979. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  91980. /**
  91981. * 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)
  91982. * @param uniformName Name of the variable.
  91983. * @param array array to be set.
  91984. * @returns this effect.
  91985. */
  91986. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  91987. /**
  91988. * 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)
  91989. * @param uniformName Name of the variable.
  91990. * @param array array to be set.
  91991. * @returns this effect.
  91992. */
  91993. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  91994. /**
  91995. * Sets an array on a uniform variable.
  91996. * @param uniformName Name of the variable.
  91997. * @param array array to be set.
  91998. * @returns this effect.
  91999. */
  92000. setArray(uniformName: string, array: number[]): Effect;
  92001. /**
  92002. * 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)
  92003. * @param uniformName Name of the variable.
  92004. * @param array array to be set.
  92005. * @returns this effect.
  92006. */
  92007. setArray2(uniformName: string, array: number[]): Effect;
  92008. /**
  92009. * 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)
  92010. * @param uniformName Name of the variable.
  92011. * @param array array to be set.
  92012. * @returns this effect.
  92013. */
  92014. setArray3(uniformName: string, array: number[]): Effect;
  92015. /**
  92016. * 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)
  92017. * @param uniformName Name of the variable.
  92018. * @param array array to be set.
  92019. * @returns this effect.
  92020. */
  92021. setArray4(uniformName: string, array: number[]): Effect;
  92022. /**
  92023. * Sets matrices on a uniform variable.
  92024. * @param uniformName Name of the variable.
  92025. * @param matrices matrices to be set.
  92026. * @returns this effect.
  92027. */
  92028. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92029. /**
  92030. * Sets matrix on a uniform variable.
  92031. * @param uniformName Name of the variable.
  92032. * @param matrix matrix to be set.
  92033. * @returns this effect.
  92034. */
  92035. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92036. /**
  92037. * 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)
  92038. * @param uniformName Name of the variable.
  92039. * @param matrix matrix to be set.
  92040. * @returns this effect.
  92041. */
  92042. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92043. /**
  92044. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92045. * @param uniformName Name of the variable.
  92046. * @param matrix matrix to be set.
  92047. * @returns this effect.
  92048. */
  92049. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92050. /**
  92051. * Sets a float on a uniform variable.
  92052. * @param uniformName Name of the variable.
  92053. * @param value value to be set.
  92054. * @returns this effect.
  92055. */
  92056. setFloat(uniformName: string, value: number): Effect;
  92057. /**
  92058. * Sets a boolean on a uniform variable.
  92059. * @param uniformName Name of the variable.
  92060. * @param bool value to be set.
  92061. * @returns this effect.
  92062. */
  92063. setBool(uniformName: string, bool: boolean): Effect;
  92064. /**
  92065. * Sets a Vector2 on a uniform variable.
  92066. * @param uniformName Name of the variable.
  92067. * @param vector2 vector2 to be set.
  92068. * @returns this effect.
  92069. */
  92070. setVector2(uniformName: string, vector2: Vector2): Effect;
  92071. /**
  92072. * Sets a float2 on a uniform variable.
  92073. * @param uniformName Name of the variable.
  92074. * @param x First float in float2.
  92075. * @param y Second float in float2.
  92076. * @returns this effect.
  92077. */
  92078. setFloat2(uniformName: string, x: number, y: number): Effect;
  92079. /**
  92080. * Sets a Vector3 on a uniform variable.
  92081. * @param uniformName Name of the variable.
  92082. * @param vector3 Value to be set.
  92083. * @returns this effect.
  92084. */
  92085. setVector3(uniformName: string, vector3: Vector3): Effect;
  92086. /**
  92087. * Sets a float3 on a uniform variable.
  92088. * @param uniformName Name of the variable.
  92089. * @param x First float in float3.
  92090. * @param y Second float in float3.
  92091. * @param z Third float in float3.
  92092. * @returns this effect.
  92093. */
  92094. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92095. /**
  92096. * Sets a Vector4 on a uniform variable.
  92097. * @param uniformName Name of the variable.
  92098. * @param vector4 Value to be set.
  92099. * @returns this effect.
  92100. */
  92101. setVector4(uniformName: string, vector4: Vector4): Effect;
  92102. /**
  92103. * Sets a float4 on a uniform variable.
  92104. * @param uniformName Name of the variable.
  92105. * @param x First float in float4.
  92106. * @param y Second float in float4.
  92107. * @param z Third float in float4.
  92108. * @param w Fourth float in float4.
  92109. * @returns this effect.
  92110. */
  92111. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92112. /**
  92113. * Sets a Color3 on a uniform variable.
  92114. * @param uniformName Name of the variable.
  92115. * @param color3 Value to be set.
  92116. * @returns this effect.
  92117. */
  92118. setColor3(uniformName: string, color3: Color3): Effect;
  92119. /**
  92120. * Sets a Color4 on a uniform variable.
  92121. * @param uniformName Name of the variable.
  92122. * @param color3 Value to be set.
  92123. * @param alpha Alpha value to be set.
  92124. * @returns this effect.
  92125. */
  92126. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92127. /**
  92128. * Sets a Color4 on a uniform variable
  92129. * @param uniformName defines the name of the variable
  92130. * @param color4 defines the value to be set
  92131. * @returns this effect.
  92132. */
  92133. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92134. /** Release all associated resources */
  92135. dispose(): void;
  92136. /**
  92137. * This function will add a new shader to the shader store
  92138. * @param name the name of the shader
  92139. * @param pixelShader optional pixel shader content
  92140. * @param vertexShader optional vertex shader content
  92141. */
  92142. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92143. /**
  92144. * Store of each shader (The can be looked up using effect.key)
  92145. */
  92146. static ShadersStore: {
  92147. [key: string]: string;
  92148. };
  92149. /**
  92150. * Store of each included file for a shader (The can be looked up using effect.key)
  92151. */
  92152. static IncludesShadersStore: {
  92153. [key: string]: string;
  92154. };
  92155. /**
  92156. * Resets the cache of effects.
  92157. */
  92158. static ResetCache(): void;
  92159. }
  92160. }
  92161. declare module BABYLON {
  92162. /**
  92163. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92164. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92165. * 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;
  92166. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92167. */
  92168. export class ColorCurves {
  92169. private _dirty;
  92170. private _tempColor;
  92171. private _globalCurve;
  92172. private _highlightsCurve;
  92173. private _midtonesCurve;
  92174. private _shadowsCurve;
  92175. private _positiveCurve;
  92176. private _negativeCurve;
  92177. private _globalHue;
  92178. private _globalDensity;
  92179. private _globalSaturation;
  92180. private _globalExposure;
  92181. /**
  92182. * Gets the global Hue value.
  92183. * 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).
  92184. */
  92185. /**
  92186. * Sets the global Hue value.
  92187. * 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).
  92188. */
  92189. globalHue: number;
  92190. /**
  92191. * Gets the global Density value.
  92192. * 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.
  92193. * Values less than zero provide a filter of opposite hue.
  92194. */
  92195. /**
  92196. * Sets the global Density value.
  92197. * 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.
  92198. * Values less than zero provide a filter of opposite hue.
  92199. */
  92200. globalDensity: number;
  92201. /**
  92202. * Gets the global Saturation value.
  92203. * 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.
  92204. */
  92205. /**
  92206. * Sets the global Saturation value.
  92207. * 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.
  92208. */
  92209. globalSaturation: number;
  92210. /**
  92211. * Gets the global Exposure value.
  92212. * 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.
  92213. */
  92214. /**
  92215. * Sets the global Exposure value.
  92216. * 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.
  92217. */
  92218. globalExposure: number;
  92219. private _highlightsHue;
  92220. private _highlightsDensity;
  92221. private _highlightsSaturation;
  92222. private _highlightsExposure;
  92223. /**
  92224. * Gets the highlights Hue value.
  92225. * 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).
  92226. */
  92227. /**
  92228. * Sets the highlights Hue value.
  92229. * 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).
  92230. */
  92231. highlightsHue: number;
  92232. /**
  92233. * Gets the highlights Density value.
  92234. * 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.
  92235. * Values less than zero provide a filter of opposite hue.
  92236. */
  92237. /**
  92238. * Sets the highlights Density value.
  92239. * 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.
  92240. * Values less than zero provide a filter of opposite hue.
  92241. */
  92242. highlightsDensity: number;
  92243. /**
  92244. * Gets the highlights Saturation value.
  92245. * 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.
  92246. */
  92247. /**
  92248. * Sets the highlights Saturation value.
  92249. * 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.
  92250. */
  92251. highlightsSaturation: number;
  92252. /**
  92253. * Gets the highlights Exposure value.
  92254. * 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.
  92255. */
  92256. /**
  92257. * Sets the highlights Exposure value.
  92258. * 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.
  92259. */
  92260. highlightsExposure: number;
  92261. private _midtonesHue;
  92262. private _midtonesDensity;
  92263. private _midtonesSaturation;
  92264. private _midtonesExposure;
  92265. /**
  92266. * Gets the midtones Hue value.
  92267. * 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).
  92268. */
  92269. /**
  92270. * Sets the midtones Hue value.
  92271. * 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).
  92272. */
  92273. midtonesHue: number;
  92274. /**
  92275. * Gets the midtones Density value.
  92276. * 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.
  92277. * Values less than zero provide a filter of opposite hue.
  92278. */
  92279. /**
  92280. * Sets the midtones Density value.
  92281. * 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.
  92282. * Values less than zero provide a filter of opposite hue.
  92283. */
  92284. midtonesDensity: number;
  92285. /**
  92286. * Gets the midtones Saturation value.
  92287. * 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.
  92288. */
  92289. /**
  92290. * Sets the midtones Saturation value.
  92291. * 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.
  92292. */
  92293. midtonesSaturation: number;
  92294. /**
  92295. * Gets the midtones Exposure value.
  92296. * 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.
  92297. */
  92298. /**
  92299. * Sets the midtones Exposure value.
  92300. * 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.
  92301. */
  92302. midtonesExposure: number;
  92303. private _shadowsHue;
  92304. private _shadowsDensity;
  92305. private _shadowsSaturation;
  92306. private _shadowsExposure;
  92307. /**
  92308. * Gets the shadows Hue value.
  92309. * 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).
  92310. */
  92311. /**
  92312. * Sets the shadows Hue value.
  92313. * 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).
  92314. */
  92315. shadowsHue: number;
  92316. /**
  92317. * Gets the shadows Density value.
  92318. * 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.
  92319. * Values less than zero provide a filter of opposite hue.
  92320. */
  92321. /**
  92322. * Sets the shadows Density value.
  92323. * 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.
  92324. * Values less than zero provide a filter of opposite hue.
  92325. */
  92326. shadowsDensity: number;
  92327. /**
  92328. * Gets the shadows Saturation value.
  92329. * 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.
  92330. */
  92331. /**
  92332. * Sets the shadows Saturation value.
  92333. * 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.
  92334. */
  92335. shadowsSaturation: number;
  92336. /**
  92337. * Gets the shadows Exposure value.
  92338. * 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.
  92339. */
  92340. /**
  92341. * Sets the shadows Exposure value.
  92342. * 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.
  92343. */
  92344. shadowsExposure: number;
  92345. /**
  92346. * Returns the class name
  92347. * @returns The class name
  92348. */
  92349. getClassName(): string;
  92350. /**
  92351. * Binds the color curves to the shader.
  92352. * @param colorCurves The color curve to bind
  92353. * @param effect The effect to bind to
  92354. * @param positiveUniform The positive uniform shader parameter
  92355. * @param neutralUniform The neutral uniform shader parameter
  92356. * @param negativeUniform The negative uniform shader parameter
  92357. */
  92358. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92359. /**
  92360. * Prepare the list of uniforms associated with the ColorCurves effects.
  92361. * @param uniformsList The list of uniforms used in the effect
  92362. */
  92363. static PrepareUniforms(uniformsList: string[]): void;
  92364. /**
  92365. * Returns color grading data based on a hue, density, saturation and exposure value.
  92366. * @param filterHue The hue of the color filter.
  92367. * @param filterDensity The density of the color filter.
  92368. * @param saturation The saturation.
  92369. * @param exposure The exposure.
  92370. * @param result The result data container.
  92371. */
  92372. private getColorGradingDataToRef;
  92373. /**
  92374. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92375. * @param value The input slider value in range [-100,100].
  92376. * @returns Adjusted value.
  92377. */
  92378. private static applyColorGradingSliderNonlinear;
  92379. /**
  92380. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92381. * @param hue The hue (H) input.
  92382. * @param saturation The saturation (S) input.
  92383. * @param brightness The brightness (B) input.
  92384. * @result An RGBA color represented as Vector4.
  92385. */
  92386. private static fromHSBToRef;
  92387. /**
  92388. * Returns a value clamped between min and max
  92389. * @param value The value to clamp
  92390. * @param min The minimum of value
  92391. * @param max The maximum of value
  92392. * @returns The clamped value.
  92393. */
  92394. private static clamp;
  92395. /**
  92396. * Clones the current color curve instance.
  92397. * @return The cloned curves
  92398. */
  92399. clone(): ColorCurves;
  92400. /**
  92401. * Serializes the current color curve instance to a json representation.
  92402. * @return a JSON representation
  92403. */
  92404. serialize(): any;
  92405. /**
  92406. * Parses the color curve from a json representation.
  92407. * @param source the JSON source to parse
  92408. * @return The parsed curves
  92409. */
  92410. static Parse(source: any): ColorCurves;
  92411. }
  92412. }
  92413. declare module BABYLON {
  92414. /**
  92415. * Interface to follow in your material defines to integrate easily the
  92416. * Image proccessing functions.
  92417. * @hidden
  92418. */
  92419. export interface IImageProcessingConfigurationDefines {
  92420. IMAGEPROCESSING: boolean;
  92421. VIGNETTE: boolean;
  92422. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92423. VIGNETTEBLENDMODEOPAQUE: boolean;
  92424. TONEMAPPING: boolean;
  92425. TONEMAPPING_ACES: boolean;
  92426. CONTRAST: boolean;
  92427. EXPOSURE: boolean;
  92428. COLORCURVES: boolean;
  92429. COLORGRADING: boolean;
  92430. COLORGRADING3D: boolean;
  92431. SAMPLER3DGREENDEPTH: boolean;
  92432. SAMPLER3DBGRMAP: boolean;
  92433. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92434. }
  92435. /**
  92436. * @hidden
  92437. */
  92438. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92439. IMAGEPROCESSING: boolean;
  92440. VIGNETTE: boolean;
  92441. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92442. VIGNETTEBLENDMODEOPAQUE: boolean;
  92443. TONEMAPPING: boolean;
  92444. TONEMAPPING_ACES: boolean;
  92445. CONTRAST: boolean;
  92446. COLORCURVES: boolean;
  92447. COLORGRADING: boolean;
  92448. COLORGRADING3D: boolean;
  92449. SAMPLER3DGREENDEPTH: boolean;
  92450. SAMPLER3DBGRMAP: boolean;
  92451. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92452. EXPOSURE: boolean;
  92453. constructor();
  92454. }
  92455. /**
  92456. * This groups together the common properties used for image processing either in direct forward pass
  92457. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92458. * or not.
  92459. */
  92460. export class ImageProcessingConfiguration {
  92461. /**
  92462. * Default tone mapping applied in BabylonJS.
  92463. */
  92464. static readonly TONEMAPPING_STANDARD: number;
  92465. /**
  92466. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92467. * to other engines rendering to increase portability.
  92468. */
  92469. static readonly TONEMAPPING_ACES: number;
  92470. /**
  92471. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92472. */
  92473. colorCurves: Nullable<ColorCurves>;
  92474. private _colorCurvesEnabled;
  92475. /**
  92476. * Gets wether the color curves effect is enabled.
  92477. */
  92478. /**
  92479. * Sets wether the color curves effect is enabled.
  92480. */
  92481. colorCurvesEnabled: boolean;
  92482. private _colorGradingTexture;
  92483. /**
  92484. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92485. */
  92486. /**
  92487. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92488. */
  92489. colorGradingTexture: Nullable<BaseTexture>;
  92490. private _colorGradingEnabled;
  92491. /**
  92492. * Gets wether the color grading effect is enabled.
  92493. */
  92494. /**
  92495. * Sets wether the color grading effect is enabled.
  92496. */
  92497. colorGradingEnabled: boolean;
  92498. private _colorGradingWithGreenDepth;
  92499. /**
  92500. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92501. */
  92502. /**
  92503. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92504. */
  92505. colorGradingWithGreenDepth: boolean;
  92506. private _colorGradingBGR;
  92507. /**
  92508. * Gets wether the color grading texture contains BGR values.
  92509. */
  92510. /**
  92511. * Sets wether the color grading texture contains BGR values.
  92512. */
  92513. colorGradingBGR: boolean;
  92514. /** @hidden */
  92515. _exposure: number;
  92516. /**
  92517. * Gets the Exposure used in the effect.
  92518. */
  92519. /**
  92520. * Sets the Exposure used in the effect.
  92521. */
  92522. exposure: number;
  92523. private _toneMappingEnabled;
  92524. /**
  92525. * Gets wether the tone mapping effect is enabled.
  92526. */
  92527. /**
  92528. * Sets wether the tone mapping effect is enabled.
  92529. */
  92530. toneMappingEnabled: boolean;
  92531. private _toneMappingType;
  92532. /**
  92533. * Gets the type of tone mapping effect.
  92534. */
  92535. /**
  92536. * Sets the type of tone mapping effect used in BabylonJS.
  92537. */
  92538. toneMappingType: number;
  92539. protected _contrast: number;
  92540. /**
  92541. * Gets the contrast used in the effect.
  92542. */
  92543. /**
  92544. * Sets the contrast used in the effect.
  92545. */
  92546. contrast: number;
  92547. /**
  92548. * Vignette stretch size.
  92549. */
  92550. vignetteStretch: number;
  92551. /**
  92552. * Vignette centre X Offset.
  92553. */
  92554. vignetteCentreX: number;
  92555. /**
  92556. * Vignette centre Y Offset.
  92557. */
  92558. vignetteCentreY: number;
  92559. /**
  92560. * Vignette weight or intensity of the vignette effect.
  92561. */
  92562. vignetteWeight: number;
  92563. /**
  92564. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92565. * if vignetteEnabled is set to true.
  92566. */
  92567. vignetteColor: Color4;
  92568. /**
  92569. * Camera field of view used by the Vignette effect.
  92570. */
  92571. vignetteCameraFov: number;
  92572. private _vignetteBlendMode;
  92573. /**
  92574. * Gets the vignette blend mode allowing different kind of effect.
  92575. */
  92576. /**
  92577. * Sets the vignette blend mode allowing different kind of effect.
  92578. */
  92579. vignetteBlendMode: number;
  92580. private _vignetteEnabled;
  92581. /**
  92582. * Gets wether the vignette effect is enabled.
  92583. */
  92584. /**
  92585. * Sets wether the vignette effect is enabled.
  92586. */
  92587. vignetteEnabled: boolean;
  92588. private _applyByPostProcess;
  92589. /**
  92590. * Gets wether the image processing is applied through a post process or not.
  92591. */
  92592. /**
  92593. * Sets wether the image processing is applied through a post process or not.
  92594. */
  92595. applyByPostProcess: boolean;
  92596. private _isEnabled;
  92597. /**
  92598. * Gets wether the image processing is enabled or not.
  92599. */
  92600. /**
  92601. * Sets wether the image processing is enabled or not.
  92602. */
  92603. isEnabled: boolean;
  92604. /**
  92605. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92606. */
  92607. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92608. /**
  92609. * Method called each time the image processing information changes requires to recompile the effect.
  92610. */
  92611. protected _updateParameters(): void;
  92612. /**
  92613. * Gets the current class name.
  92614. * @return "ImageProcessingConfiguration"
  92615. */
  92616. getClassName(): string;
  92617. /**
  92618. * Prepare the list of uniforms associated with the Image Processing effects.
  92619. * @param uniforms The list of uniforms used in the effect
  92620. * @param defines the list of defines currently in use
  92621. */
  92622. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92623. /**
  92624. * Prepare the list of samplers associated with the Image Processing effects.
  92625. * @param samplersList The list of uniforms used in the effect
  92626. * @param defines the list of defines currently in use
  92627. */
  92628. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92629. /**
  92630. * Prepare the list of defines associated to the shader.
  92631. * @param defines the list of defines to complete
  92632. * @param forPostProcess Define if we are currently in post process mode or not
  92633. */
  92634. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92635. /**
  92636. * Returns true if all the image processing information are ready.
  92637. * @returns True if ready, otherwise, false
  92638. */
  92639. isReady(): boolean;
  92640. /**
  92641. * Binds the image processing to the shader.
  92642. * @param effect The effect to bind to
  92643. * @param aspectRatio Define the current aspect ratio of the effect
  92644. */
  92645. bind(effect: Effect, aspectRatio?: number): void;
  92646. /**
  92647. * Clones the current image processing instance.
  92648. * @return The cloned image processing
  92649. */
  92650. clone(): ImageProcessingConfiguration;
  92651. /**
  92652. * Serializes the current image processing instance to a json representation.
  92653. * @return a JSON representation
  92654. */
  92655. serialize(): any;
  92656. /**
  92657. * Parses the image processing from a json representation.
  92658. * @param source the JSON source to parse
  92659. * @return The parsed image processing
  92660. */
  92661. static Parse(source: any): ImageProcessingConfiguration;
  92662. private static _VIGNETTEMODE_MULTIPLY;
  92663. private static _VIGNETTEMODE_OPAQUE;
  92664. /**
  92665. * Used to apply the vignette as a mix with the pixel color.
  92666. */
  92667. static readonly VIGNETTEMODE_MULTIPLY: number;
  92668. /**
  92669. * Used to apply the vignette as a replacement of the pixel color.
  92670. */
  92671. static readonly VIGNETTEMODE_OPAQUE: number;
  92672. }
  92673. }
  92674. declare module BABYLON {
  92675. /**
  92676. * This represents all the required information to add a fresnel effect on a material:
  92677. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92678. */
  92679. export class FresnelParameters {
  92680. private _isEnabled;
  92681. /**
  92682. * Define if the fresnel effect is enable or not.
  92683. */
  92684. isEnabled: boolean;
  92685. /**
  92686. * Define the color used on edges (grazing angle)
  92687. */
  92688. leftColor: Color3;
  92689. /**
  92690. * Define the color used on center
  92691. */
  92692. rightColor: Color3;
  92693. /**
  92694. * Define bias applied to computed fresnel term
  92695. */
  92696. bias: number;
  92697. /**
  92698. * Defined the power exponent applied to fresnel term
  92699. */
  92700. power: number;
  92701. /**
  92702. * Clones the current fresnel and its valuues
  92703. * @returns a clone fresnel configuration
  92704. */
  92705. clone(): FresnelParameters;
  92706. /**
  92707. * Serializes the current fresnel parameters to a JSON representation.
  92708. * @return the JSON serialization
  92709. */
  92710. serialize(): any;
  92711. /**
  92712. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92713. * @param parsedFresnelParameters Define the JSON representation
  92714. * @returns the parsed parameters
  92715. */
  92716. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92717. }
  92718. }
  92719. declare module BABYLON {
  92720. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92721. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92722. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92723. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92724. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92725. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92726. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92727. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92728. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92729. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92730. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92731. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92732. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92733. /**
  92734. * Decorator used to define property that can be serialized as reference to a camera
  92735. * @param sourceName defines the name of the property to decorate
  92736. */
  92737. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92738. /**
  92739. * Class used to help serialization objects
  92740. */
  92741. export class SerializationHelper {
  92742. /** @hidden */
  92743. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92744. /** @hidden */
  92745. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92746. /** @hidden */
  92747. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92748. /** @hidden */
  92749. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92750. /**
  92751. * Appends the serialized animations from the source animations
  92752. * @param source Source containing the animations
  92753. * @param destination Target to store the animations
  92754. */
  92755. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92756. /**
  92757. * Static function used to serialized a specific entity
  92758. * @param entity defines the entity to serialize
  92759. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92760. * @returns a JSON compatible object representing the serialization of the entity
  92761. */
  92762. static Serialize<T>(entity: T, serializationObject?: any): any;
  92763. /**
  92764. * Creates a new entity from a serialization data object
  92765. * @param creationFunction defines a function used to instanciated the new entity
  92766. * @param source defines the source serialization data
  92767. * @param scene defines the hosting scene
  92768. * @param rootUrl defines the root url for resources
  92769. * @returns a new entity
  92770. */
  92771. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92772. /**
  92773. * Clones an object
  92774. * @param creationFunction defines the function used to instanciate the new object
  92775. * @param source defines the source object
  92776. * @returns the cloned object
  92777. */
  92778. static Clone<T>(creationFunction: () => T, source: T): T;
  92779. /**
  92780. * Instanciates a new object based on a source one (some data will be shared between both object)
  92781. * @param creationFunction defines the function used to instanciate the new object
  92782. * @param source defines the source object
  92783. * @returns the new object
  92784. */
  92785. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92786. }
  92787. }
  92788. declare module BABYLON {
  92789. /**
  92790. * This is the base class of all the camera used in the application.
  92791. * @see http://doc.babylonjs.com/features/cameras
  92792. */
  92793. export class Camera extends Node {
  92794. /** @hidden */
  92795. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92796. /**
  92797. * This is the default projection mode used by the cameras.
  92798. * It helps recreating a feeling of perspective and better appreciate depth.
  92799. * This is the best way to simulate real life cameras.
  92800. */
  92801. static readonly PERSPECTIVE_CAMERA: number;
  92802. /**
  92803. * This helps creating camera with an orthographic mode.
  92804. * 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.
  92805. */
  92806. static readonly ORTHOGRAPHIC_CAMERA: number;
  92807. /**
  92808. * This is the default FOV mode for perspective cameras.
  92809. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92810. */
  92811. static readonly FOVMODE_VERTICAL_FIXED: number;
  92812. /**
  92813. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92814. */
  92815. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92816. /**
  92817. * This specifies ther is no need for a camera rig.
  92818. * Basically only one eye is rendered corresponding to the camera.
  92819. */
  92820. static readonly RIG_MODE_NONE: number;
  92821. /**
  92822. * Simulates a camera Rig with one blue eye and one red eye.
  92823. * This can be use with 3d blue and red glasses.
  92824. */
  92825. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92826. /**
  92827. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92828. */
  92829. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92830. /**
  92831. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92832. */
  92833. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92834. /**
  92835. * Defines that both eyes of the camera will be rendered over under each other.
  92836. */
  92837. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92838. /**
  92839. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92840. */
  92841. static readonly RIG_MODE_VR: number;
  92842. /**
  92843. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92844. */
  92845. static readonly RIG_MODE_WEBVR: number;
  92846. /**
  92847. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92848. */
  92849. static readonly RIG_MODE_CUSTOM: number;
  92850. /**
  92851. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92852. */
  92853. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92854. /**
  92855. * Define the input manager associated with the camera.
  92856. */
  92857. inputs: CameraInputsManager<Camera>;
  92858. /** @hidden */
  92859. _position: Vector3;
  92860. /**
  92861. * Define the current local position of the camera in the scene
  92862. */
  92863. position: Vector3;
  92864. /**
  92865. * The vector the camera should consider as up.
  92866. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92867. */
  92868. upVector: Vector3;
  92869. /**
  92870. * Define the current limit on the left side for an orthographic camera
  92871. * In scene unit
  92872. */
  92873. orthoLeft: Nullable<number>;
  92874. /**
  92875. * Define the current limit on the right side for an orthographic camera
  92876. * In scene unit
  92877. */
  92878. orthoRight: Nullable<number>;
  92879. /**
  92880. * Define the current limit on the bottom side for an orthographic camera
  92881. * In scene unit
  92882. */
  92883. orthoBottom: Nullable<number>;
  92884. /**
  92885. * Define the current limit on the top side for an orthographic camera
  92886. * In scene unit
  92887. */
  92888. orthoTop: Nullable<number>;
  92889. /**
  92890. * Field Of View is set in Radians. (default is 0.8)
  92891. */
  92892. fov: number;
  92893. /**
  92894. * Define the minimum distance the camera can see from.
  92895. * This is important to note that the depth buffer are not infinite and the closer it starts
  92896. * the more your scene might encounter depth fighting issue.
  92897. */
  92898. minZ: number;
  92899. /**
  92900. * Define the maximum distance the camera can see to.
  92901. * This is important to note that the depth buffer are not infinite and the further it end
  92902. * the more your scene might encounter depth fighting issue.
  92903. */
  92904. maxZ: number;
  92905. /**
  92906. * Define the default inertia of the camera.
  92907. * This helps giving a smooth feeling to the camera movement.
  92908. */
  92909. inertia: number;
  92910. /**
  92911. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  92912. */
  92913. mode: number;
  92914. /**
  92915. * Define wether the camera is intermediate.
  92916. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92917. */
  92918. isIntermediate: boolean;
  92919. /**
  92920. * Define the viewport of the camera.
  92921. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92922. */
  92923. viewport: Viewport;
  92924. /**
  92925. * Restricts the camera to viewing objects with the same layerMask.
  92926. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92927. */
  92928. layerMask: number;
  92929. /**
  92930. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92931. */
  92932. fovMode: number;
  92933. /**
  92934. * Rig mode of the camera.
  92935. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92936. * This is normally controlled byt the camera themselves as internal use.
  92937. */
  92938. cameraRigMode: number;
  92939. /**
  92940. * Defines the distance between both "eyes" in case of a RIG
  92941. */
  92942. interaxialDistance: number;
  92943. /**
  92944. * Defines if stereoscopic rendering is done side by side or over under.
  92945. */
  92946. isStereoscopicSideBySide: boolean;
  92947. /**
  92948. * 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
  92949. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92950. * else in the scene.
  92951. */
  92952. customRenderTargets: RenderTargetTexture[];
  92953. /**
  92954. * When set, the camera will render to this render target instead of the default canvas
  92955. */
  92956. outputRenderTarget: Nullable<RenderTargetTexture>;
  92957. /**
  92958. * Observable triggered when the camera view matrix has changed.
  92959. */
  92960. onViewMatrixChangedObservable: Observable<Camera>;
  92961. /**
  92962. * Observable triggered when the camera Projection matrix has changed.
  92963. */
  92964. onProjectionMatrixChangedObservable: Observable<Camera>;
  92965. /**
  92966. * Observable triggered when the inputs have been processed.
  92967. */
  92968. onAfterCheckInputsObservable: Observable<Camera>;
  92969. /**
  92970. * Observable triggered when reset has been called and applied to the camera.
  92971. */
  92972. onRestoreStateObservable: Observable<Camera>;
  92973. /** @hidden */
  92974. _cameraRigParams: any;
  92975. /** @hidden */
  92976. _rigCameras: Camera[];
  92977. /** @hidden */
  92978. _rigPostProcess: Nullable<PostProcess>;
  92979. protected _webvrViewMatrix: Matrix;
  92980. /** @hidden */
  92981. _skipRendering: boolean;
  92982. /** @hidden */
  92983. _projectionMatrix: Matrix;
  92984. /** @hidden */
  92985. _postProcesses: Nullable<PostProcess>[];
  92986. /** @hidden */
  92987. _activeMeshes: SmartArray<AbstractMesh>;
  92988. protected _globalPosition: Vector3;
  92989. /** @hidden */
  92990. _computedViewMatrix: Matrix;
  92991. private _doNotComputeProjectionMatrix;
  92992. private _transformMatrix;
  92993. private _frustumPlanes;
  92994. private _refreshFrustumPlanes;
  92995. private _storedFov;
  92996. private _stateStored;
  92997. /**
  92998. * Instantiates a new camera object.
  92999. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93000. * @see http://doc.babylonjs.com/features/cameras
  93001. * @param name Defines the name of the camera in the scene
  93002. * @param position Defines the position of the camera
  93003. * @param scene Defines the scene the camera belongs too
  93004. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93005. */
  93006. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93007. /**
  93008. * Store current camera state (fov, position, etc..)
  93009. * @returns the camera
  93010. */
  93011. storeState(): Camera;
  93012. /**
  93013. * Restores the camera state values if it has been stored. You must call storeState() first
  93014. */
  93015. protected _restoreStateValues(): boolean;
  93016. /**
  93017. * Restored camera state. You must call storeState() first.
  93018. * @returns true if restored and false otherwise
  93019. */
  93020. restoreState(): boolean;
  93021. /**
  93022. * Gets the class name of the camera.
  93023. * @returns the class name
  93024. */
  93025. getClassName(): string;
  93026. /** @hidden */
  93027. readonly _isCamera: boolean;
  93028. /**
  93029. * Gets a string representation of the camera useful for debug purpose.
  93030. * @param fullDetails Defines that a more verboe level of logging is required
  93031. * @returns the string representation
  93032. */
  93033. toString(fullDetails?: boolean): string;
  93034. /**
  93035. * Gets the current world space position of the camera.
  93036. */
  93037. readonly globalPosition: Vector3;
  93038. /**
  93039. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93040. * @returns the active meshe list
  93041. */
  93042. getActiveMeshes(): SmartArray<AbstractMesh>;
  93043. /**
  93044. * Check wether a mesh is part of the current active mesh list of the camera
  93045. * @param mesh Defines the mesh to check
  93046. * @returns true if active, false otherwise
  93047. */
  93048. isActiveMesh(mesh: Mesh): boolean;
  93049. /**
  93050. * Is this camera ready to be used/rendered
  93051. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93052. * @return true if the camera is ready
  93053. */
  93054. isReady(completeCheck?: boolean): boolean;
  93055. /** @hidden */
  93056. _initCache(): void;
  93057. /** @hidden */
  93058. _updateCache(ignoreParentClass?: boolean): void;
  93059. /** @hidden */
  93060. _isSynchronized(): boolean;
  93061. /** @hidden */
  93062. _isSynchronizedViewMatrix(): boolean;
  93063. /** @hidden */
  93064. _isSynchronizedProjectionMatrix(): boolean;
  93065. /**
  93066. * Attach the input controls to a specific dom element to get the input from.
  93067. * @param element Defines the element the controls should be listened from
  93068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93069. */
  93070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93071. /**
  93072. * Detach the current controls from the specified dom element.
  93073. * @param element Defines the element to stop listening the inputs from
  93074. */
  93075. detachControl(element: HTMLElement): void;
  93076. /**
  93077. * Update the camera state according to the different inputs gathered during the frame.
  93078. */
  93079. update(): void;
  93080. /** @hidden */
  93081. _checkInputs(): void;
  93082. /** @hidden */
  93083. readonly rigCameras: Camera[];
  93084. /**
  93085. * Gets the post process used by the rig cameras
  93086. */
  93087. readonly rigPostProcess: Nullable<PostProcess>;
  93088. /**
  93089. * Internal, gets the first post proces.
  93090. * @returns the first post process to be run on this camera.
  93091. */
  93092. _getFirstPostProcess(): Nullable<PostProcess>;
  93093. private _cascadePostProcessesToRigCams;
  93094. /**
  93095. * Attach a post process to the camera.
  93096. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93097. * @param postProcess The post process to attach to the camera
  93098. * @param insertAt The position of the post process in case several of them are in use in the scene
  93099. * @returns the position the post process has been inserted at
  93100. */
  93101. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93102. /**
  93103. * Detach a post process to the camera.
  93104. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93105. * @param postProcess The post process to detach from the camera
  93106. */
  93107. detachPostProcess(postProcess: PostProcess): void;
  93108. /**
  93109. * Gets the current world matrix of the camera
  93110. */
  93111. getWorldMatrix(): Matrix;
  93112. /** @hidden */
  93113. _getViewMatrix(): Matrix;
  93114. /**
  93115. * Gets the current view matrix of the camera.
  93116. * @param force forces the camera to recompute the matrix without looking at the cached state
  93117. * @returns the view matrix
  93118. */
  93119. getViewMatrix(force?: boolean): Matrix;
  93120. /**
  93121. * Freeze the projection matrix.
  93122. * It will prevent the cache check of the camera projection compute and can speed up perf
  93123. * if no parameter of the camera are meant to change
  93124. * @param projection Defines manually a projection if necessary
  93125. */
  93126. freezeProjectionMatrix(projection?: Matrix): void;
  93127. /**
  93128. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93129. */
  93130. unfreezeProjectionMatrix(): void;
  93131. /**
  93132. * Gets the current projection matrix of the camera.
  93133. * @param force forces the camera to recompute the matrix without looking at the cached state
  93134. * @returns the projection matrix
  93135. */
  93136. getProjectionMatrix(force?: boolean): Matrix;
  93137. /**
  93138. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93139. * @returns a Matrix
  93140. */
  93141. getTransformationMatrix(): Matrix;
  93142. private _updateFrustumPlanes;
  93143. /**
  93144. * Checks if a cullable object (mesh...) is in the camera frustum
  93145. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93146. * @param target The object to check
  93147. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93148. * @returns true if the object is in frustum otherwise false
  93149. */
  93150. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93151. /**
  93152. * Checks if a cullable object (mesh...) is in the camera frustum
  93153. * Unlike isInFrustum this cheks the full bounding box
  93154. * @param target The object to check
  93155. * @returns true if the object is in frustum otherwise false
  93156. */
  93157. isCompletelyInFrustum(target: ICullable): boolean;
  93158. /**
  93159. * Gets a ray in the forward direction from the camera.
  93160. * @param length Defines the length of the ray to create
  93161. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93162. * @param origin Defines the start point of the ray which defaults to the camera position
  93163. * @returns the forward ray
  93164. */
  93165. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93166. /**
  93167. * Releases resources associated with this node.
  93168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93170. */
  93171. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93172. /** @hidden */
  93173. _isLeftCamera: boolean;
  93174. /**
  93175. * Gets the left camera of a rig setup in case of Rigged Camera
  93176. */
  93177. readonly isLeftCamera: boolean;
  93178. /** @hidden */
  93179. _isRightCamera: boolean;
  93180. /**
  93181. * Gets the right camera of a rig setup in case of Rigged Camera
  93182. */
  93183. readonly isRightCamera: boolean;
  93184. /**
  93185. * Gets the left camera of a rig setup in case of Rigged Camera
  93186. */
  93187. readonly leftCamera: Nullable<FreeCamera>;
  93188. /**
  93189. * Gets the right camera of a rig setup in case of Rigged Camera
  93190. */
  93191. readonly rightCamera: Nullable<FreeCamera>;
  93192. /**
  93193. * Gets the left camera target of a rig setup in case of Rigged Camera
  93194. * @returns the target position
  93195. */
  93196. getLeftTarget(): Nullable<Vector3>;
  93197. /**
  93198. * Gets the right camera target of a rig setup in case of Rigged Camera
  93199. * @returns the target position
  93200. */
  93201. getRightTarget(): Nullable<Vector3>;
  93202. /**
  93203. * @hidden
  93204. */
  93205. setCameraRigMode(mode: number, rigParams: any): void;
  93206. /** @hidden */
  93207. static _setStereoscopicRigMode(camera: Camera): void;
  93208. /** @hidden */
  93209. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93210. /** @hidden */
  93211. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93212. /** @hidden */
  93213. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93214. /** @hidden */
  93215. _getVRProjectionMatrix(): Matrix;
  93216. protected _updateCameraRotationMatrix(): void;
  93217. protected _updateWebVRCameraRotationMatrix(): void;
  93218. /**
  93219. * This function MUST be overwritten by the different WebVR cameras available.
  93220. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93221. * @hidden
  93222. */
  93223. _getWebVRProjectionMatrix(): Matrix;
  93224. /**
  93225. * This function MUST be overwritten by the different WebVR cameras available.
  93226. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93227. * @hidden
  93228. */
  93229. _getWebVRViewMatrix(): Matrix;
  93230. /** @hidden */
  93231. setCameraRigParameter(name: string, value: any): void;
  93232. /**
  93233. * needs to be overridden by children so sub has required properties to be copied
  93234. * @hidden
  93235. */
  93236. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93237. /**
  93238. * May need to be overridden by children
  93239. * @hidden
  93240. */
  93241. _updateRigCameras(): void;
  93242. /** @hidden */
  93243. _setupInputs(): void;
  93244. /**
  93245. * Serialiaze the camera setup to a json represention
  93246. * @returns the JSON representation
  93247. */
  93248. serialize(): any;
  93249. /**
  93250. * Clones the current camera.
  93251. * @param name The cloned camera name
  93252. * @returns the cloned camera
  93253. */
  93254. clone(name: string): Camera;
  93255. /**
  93256. * Gets the direction of the camera relative to a given local axis.
  93257. * @param localAxis Defines the reference axis to provide a relative direction.
  93258. * @return the direction
  93259. */
  93260. getDirection(localAxis: Vector3): Vector3;
  93261. /**
  93262. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93263. * @param localAxis Defines the reference axis to provide a relative direction.
  93264. * @param result Defines the vector to store the result in
  93265. */
  93266. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93267. /**
  93268. * Gets a camera constructor for a given camera type
  93269. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93270. * @param name The name of the camera the result will be able to instantiate
  93271. * @param scene The scene the result will construct the camera in
  93272. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93273. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93274. * @returns a factory method to construc the camera
  93275. */
  93276. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93277. /**
  93278. * Compute the world matrix of the camera.
  93279. * @returns the camera workd matrix
  93280. */
  93281. computeWorldMatrix(): Matrix;
  93282. /**
  93283. * Parse a JSON and creates the camera from the parsed information
  93284. * @param parsedCamera The JSON to parse
  93285. * @param scene The scene to instantiate the camera in
  93286. * @returns the newly constructed camera
  93287. */
  93288. static Parse(parsedCamera: any, scene: Scene): Camera;
  93289. }
  93290. }
  93291. declare module BABYLON {
  93292. /**
  93293. * Interface for any object that can request an animation frame
  93294. */
  93295. export interface ICustomAnimationFrameRequester {
  93296. /**
  93297. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93298. */
  93299. renderFunction?: Function;
  93300. /**
  93301. * Called to request the next frame to render to
  93302. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93303. */
  93304. requestAnimationFrame: Function;
  93305. /**
  93306. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93307. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93308. */
  93309. requestID?: number;
  93310. }
  93311. /**
  93312. * Interface containing an array of animations
  93313. */
  93314. export interface IAnimatable {
  93315. /**
  93316. * Array of animations
  93317. */
  93318. animations: Nullable<Array<Animation>>;
  93319. }
  93320. /** Interface used by value gradients (color, factor, ...) */
  93321. export interface IValueGradient {
  93322. /**
  93323. * Gets or sets the gradient value (between 0 and 1)
  93324. */
  93325. gradient: number;
  93326. }
  93327. /** Class used to store color4 gradient */
  93328. export class ColorGradient implements IValueGradient {
  93329. /**
  93330. * Gets or sets the gradient value (between 0 and 1)
  93331. */
  93332. gradient: number;
  93333. /**
  93334. * Gets or sets first associated color
  93335. */
  93336. color1: Color4;
  93337. /**
  93338. * Gets or sets second associated color
  93339. */
  93340. color2?: Color4;
  93341. /**
  93342. * Will get a color picked randomly between color1 and color2.
  93343. * If color2 is undefined then color1 will be used
  93344. * @param result defines the target Color4 to store the result in
  93345. */
  93346. getColorToRef(result: Color4): void;
  93347. }
  93348. /** Class used to store color 3 gradient */
  93349. export class Color3Gradient implements IValueGradient {
  93350. /**
  93351. * Gets or sets the gradient value (between 0 and 1)
  93352. */
  93353. gradient: number;
  93354. /**
  93355. * Gets or sets the associated color
  93356. */
  93357. color: Color3;
  93358. }
  93359. /** Class used to store factor gradient */
  93360. export class FactorGradient implements IValueGradient {
  93361. /**
  93362. * Gets or sets the gradient value (between 0 and 1)
  93363. */
  93364. gradient: number;
  93365. /**
  93366. * Gets or sets first associated factor
  93367. */
  93368. factor1: number;
  93369. /**
  93370. * Gets or sets second associated factor
  93371. */
  93372. factor2?: number;
  93373. /**
  93374. * Will get a number picked randomly between factor1 and factor2.
  93375. * If factor2 is undefined then factor1 will be used
  93376. * @returns the picked number
  93377. */
  93378. getFactor(): number;
  93379. }
  93380. /**
  93381. * @ignore
  93382. * Application error to support additional information when loading a file
  93383. */
  93384. export class LoadFileError extends Error {
  93385. /** defines the optional web request */
  93386. request?: WebRequest | undefined;
  93387. private static _setPrototypeOf;
  93388. /**
  93389. * Creates a new LoadFileError
  93390. * @param message defines the message of the error
  93391. * @param request defines the optional web request
  93392. */
  93393. constructor(message: string,
  93394. /** defines the optional web request */
  93395. request?: WebRequest | undefined);
  93396. }
  93397. /**
  93398. * Class used to define a retry strategy when error happens while loading assets
  93399. */
  93400. export class RetryStrategy {
  93401. /**
  93402. * Function used to defines an exponential back off strategy
  93403. * @param maxRetries defines the maximum number of retries (3 by default)
  93404. * @param baseInterval defines the interval between retries
  93405. * @returns the strategy function to use
  93406. */
  93407. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93408. }
  93409. /**
  93410. * File request interface
  93411. */
  93412. export interface IFileRequest {
  93413. /**
  93414. * Raised when the request is complete (success or error).
  93415. */
  93416. onCompleteObservable: Observable<IFileRequest>;
  93417. /**
  93418. * Aborts the request for a file.
  93419. */
  93420. abort: () => void;
  93421. }
  93422. /**
  93423. * Class containing a set of static utilities functions
  93424. */
  93425. export class Tools {
  93426. /**
  93427. * Gets or sets the base URL to use to load assets
  93428. */
  93429. static BaseUrl: string;
  93430. /**
  93431. * Enable/Disable Custom HTTP Request Headers globally.
  93432. * default = false
  93433. * @see CustomRequestHeaders
  93434. */
  93435. static UseCustomRequestHeaders: boolean;
  93436. /**
  93437. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93438. * i.e. when loading files, where the server/service expects an Authorization header
  93439. */
  93440. static CustomRequestHeaders: {
  93441. [key: string]: string;
  93442. };
  93443. /**
  93444. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93445. */
  93446. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93447. /**
  93448. * Default behaviour for cors in the application.
  93449. * It can be a string if the expected behavior is identical in the entire app.
  93450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93451. */
  93452. static CorsBehavior: string | ((url: string | string[]) => string);
  93453. /**
  93454. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93455. * @ignorenaming
  93456. */
  93457. static UseFallbackTexture: boolean;
  93458. /**
  93459. * Use this object to register external classes like custom textures or material
  93460. * to allow the laoders to instantiate them
  93461. */
  93462. static RegisteredExternalClasses: {
  93463. [key: string]: Object;
  93464. };
  93465. /**
  93466. * Texture content used if a texture cannot loaded
  93467. * @ignorenaming
  93468. */
  93469. static fallbackTexture: string;
  93470. /**
  93471. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93472. * @param u defines the coordinate on X axis
  93473. * @param v defines the coordinate on Y axis
  93474. * @param width defines the width of the source data
  93475. * @param height defines the height of the source data
  93476. * @param pixels defines the source byte array
  93477. * @param color defines the output color
  93478. */
  93479. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93480. /**
  93481. * Interpolates between a and b via alpha
  93482. * @param a The lower value (returned when alpha = 0)
  93483. * @param b The upper value (returned when alpha = 1)
  93484. * @param alpha The interpolation-factor
  93485. * @return The mixed value
  93486. */
  93487. static Mix(a: number, b: number, alpha: number): number;
  93488. /**
  93489. * Tries to instantiate a new object from a given class name
  93490. * @param className defines the class name to instantiate
  93491. * @returns the new object or null if the system was not able to do the instantiation
  93492. */
  93493. static Instantiate(className: string): any;
  93494. /**
  93495. * Provides a slice function that will work even on IE
  93496. * @param data defines the array to slice
  93497. * @param start defines the start of the data (optional)
  93498. * @param end defines the end of the data (optional)
  93499. * @returns the new sliced array
  93500. */
  93501. static Slice<T>(data: T, start?: number, end?: number): T;
  93502. /**
  93503. * Polyfill for setImmediate
  93504. * @param action defines the action to execute after the current execution block
  93505. */
  93506. static SetImmediate(action: () => void): void;
  93507. /**
  93508. * Function indicating if a number is an exponent of 2
  93509. * @param value defines the value to test
  93510. * @returns true if the value is an exponent of 2
  93511. */
  93512. static IsExponentOfTwo(value: number): boolean;
  93513. private static _tmpFloatArray;
  93514. /**
  93515. * Returns the nearest 32-bit single precision float representation of a Number
  93516. * @param value A Number. If the parameter is of a different type, it will get converted
  93517. * to a number or to NaN if it cannot be converted
  93518. * @returns number
  93519. */
  93520. static FloatRound(value: number): number;
  93521. /**
  93522. * Find the next highest power of two.
  93523. * @param x Number to start search from.
  93524. * @return Next highest power of two.
  93525. */
  93526. static CeilingPOT(x: number): number;
  93527. /**
  93528. * Find the next lowest power of two.
  93529. * @param x Number to start search from.
  93530. * @return Next lowest power of two.
  93531. */
  93532. static FloorPOT(x: number): number;
  93533. /**
  93534. * Find the nearest power of two.
  93535. * @param x Number to start search from.
  93536. * @return Next nearest power of two.
  93537. */
  93538. static NearestPOT(x: number): number;
  93539. /**
  93540. * Get the closest exponent of two
  93541. * @param value defines the value to approximate
  93542. * @param max defines the maximum value to return
  93543. * @param mode defines how to define the closest value
  93544. * @returns closest exponent of two of the given value
  93545. */
  93546. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93547. /**
  93548. * Extracts the filename from a path
  93549. * @param path defines the path to use
  93550. * @returns the filename
  93551. */
  93552. static GetFilename(path: string): string;
  93553. /**
  93554. * Extracts the "folder" part of a path (everything before the filename).
  93555. * @param uri The URI to extract the info from
  93556. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93557. * @returns The "folder" part of the path
  93558. */
  93559. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93560. /**
  93561. * Extracts text content from a DOM element hierarchy
  93562. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93563. */
  93564. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93565. /**
  93566. * Convert an angle in radians to degrees
  93567. * @param angle defines the angle to convert
  93568. * @returns the angle in degrees
  93569. */
  93570. static ToDegrees(angle: number): number;
  93571. /**
  93572. * Convert an angle in degrees to radians
  93573. * @param angle defines the angle to convert
  93574. * @returns the angle in radians
  93575. */
  93576. static ToRadians(angle: number): number;
  93577. /**
  93578. * Encode a buffer to a base64 string
  93579. * @param buffer defines the buffer to encode
  93580. * @returns the encoded string
  93581. */
  93582. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93583. /**
  93584. * Extracts minimum and maximum values from a list of indexed positions
  93585. * @param positions defines the positions to use
  93586. * @param indices defines the indices to the positions
  93587. * @param indexStart defines the start index
  93588. * @param indexCount defines the end index
  93589. * @param bias defines bias value to add to the result
  93590. * @return minimum and maximum values
  93591. */
  93592. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93593. minimum: Vector3;
  93594. maximum: Vector3;
  93595. };
  93596. /**
  93597. * Extracts minimum and maximum values from a list of positions
  93598. * @param positions defines the positions to use
  93599. * @param start defines the start index in the positions array
  93600. * @param count defines the number of positions to handle
  93601. * @param bias defines bias value to add to the result
  93602. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93603. * @return minimum and maximum values
  93604. */
  93605. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93606. minimum: Vector3;
  93607. maximum: Vector3;
  93608. };
  93609. /**
  93610. * Returns an array if obj is not an array
  93611. * @param obj defines the object to evaluate as an array
  93612. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93613. * @returns either obj directly if obj is an array or a new array containing obj
  93614. */
  93615. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93616. /**
  93617. * Gets the pointer prefix to use
  93618. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93619. */
  93620. static GetPointerPrefix(): string;
  93621. /**
  93622. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93623. * @param func - the function to be called
  93624. * @param requester - the object that will request the next frame. Falls back to window.
  93625. * @returns frame number
  93626. */
  93627. static QueueNewFrame(func: () => void, requester?: any): number;
  93628. /**
  93629. * Ask the browser to promote the current element to fullscreen rendering mode
  93630. * @param element defines the DOM element to promote
  93631. */
  93632. static RequestFullscreen(element: HTMLElement): void;
  93633. /**
  93634. * Asks the browser to exit fullscreen mode
  93635. */
  93636. static ExitFullscreen(): void;
  93637. /**
  93638. * Ask the browser to promote the current element to pointerlock mode
  93639. * @param element defines the DOM element to promote
  93640. */
  93641. static RequestPointerlock(element: HTMLElement): void;
  93642. /**
  93643. * Asks the browser to exit pointerlock mode
  93644. */
  93645. static ExitPointerlock(): void;
  93646. /**
  93647. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93648. * @param url define the url we are trying
  93649. * @param element define the dom element where to configure the cors policy
  93650. */
  93651. static SetCorsBehavior(url: string | string[], element: {
  93652. crossOrigin: string | null;
  93653. }): void;
  93654. /**
  93655. * Removes unwanted characters from an url
  93656. * @param url defines the url to clean
  93657. * @returns the cleaned url
  93658. */
  93659. static CleanUrl(url: string): string;
  93660. /**
  93661. * Gets or sets a function used to pre-process url before using them to load assets
  93662. */
  93663. static PreprocessUrl: (url: string) => string;
  93664. /**
  93665. * Loads an image as an HTMLImageElement.
  93666. * @param input url string, ArrayBuffer, or Blob to load
  93667. * @param onLoad callback called when the image successfully loads
  93668. * @param onError callback called when the image fails to load
  93669. * @param offlineProvider offline provider for caching
  93670. * @returns the HTMLImageElement of the loaded image
  93671. */
  93672. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93673. /**
  93674. * Loads a file
  93675. * @param url url string, ArrayBuffer, or Blob to load
  93676. * @param onSuccess callback called when the file successfully loads
  93677. * @param onProgress callback called while file is loading (if the server supports this mode)
  93678. * @param offlineProvider defines the offline provider for caching
  93679. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93680. * @param onError callback called when the file fails to load
  93681. * @returns a file request object
  93682. */
  93683. 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;
  93684. /**
  93685. * Load a script (identified by an url). When the url returns, the
  93686. * content of this file is added into a new script element, attached to the DOM (body element)
  93687. * @param scriptUrl defines the url of the script to laod
  93688. * @param onSuccess defines the callback called when the script is loaded
  93689. * @param onError defines the callback to call if an error occurs
  93690. * @param scriptId defines the id of the script element
  93691. */
  93692. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93693. /**
  93694. * Load an asynchronous script (identified by an url). When the url returns, the
  93695. * content of this file is added into a new script element, attached to the DOM (body element)
  93696. * @param scriptUrl defines the url of the script to laod
  93697. * @param scriptId defines the id of the script element
  93698. * @returns a promise request object
  93699. */
  93700. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  93701. /**
  93702. * Loads a file from a blob
  93703. * @param fileToLoad defines the blob to use
  93704. * @param callback defines the callback to call when data is loaded
  93705. * @param progressCallback defines the callback to call during loading process
  93706. * @returns a file request object
  93707. */
  93708. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93709. /**
  93710. * Loads a file
  93711. * @param fileToLoad defines the file to load
  93712. * @param callback defines the callback to call when data is loaded
  93713. * @param progressCallBack defines the callback to call during loading process
  93714. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93715. * @returns a file request object
  93716. */
  93717. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93718. /**
  93719. * Creates a data url from a given string content
  93720. * @param content defines the content to convert
  93721. * @returns the new data url link
  93722. */
  93723. static FileAsURL(content: string): string;
  93724. /**
  93725. * Format the given number to a specific decimal format
  93726. * @param value defines the number to format
  93727. * @param decimals defines the number of decimals to use
  93728. * @returns the formatted string
  93729. */
  93730. static Format(value: number, decimals?: number): string;
  93731. /**
  93732. * Checks if a given vector is inside a specific range
  93733. * @param v defines the vector to test
  93734. * @param min defines the minimum range
  93735. * @param max defines the maximum range
  93736. */
  93737. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93738. /**
  93739. * Tries to copy an object by duplicating every property
  93740. * @param source defines the source object
  93741. * @param destination defines the target object
  93742. * @param doNotCopyList defines a list of properties to avoid
  93743. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93744. */
  93745. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93746. /**
  93747. * Gets a boolean indicating if the given object has no own property
  93748. * @param obj defines the object to test
  93749. * @returns true if object has no own property
  93750. */
  93751. static IsEmpty(obj: any): boolean;
  93752. /**
  93753. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93754. * @param str Source string
  93755. * @param suffix Suffix to search for in the source string
  93756. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93757. */
  93758. static EndsWith(str: string, suffix: string): boolean;
  93759. /**
  93760. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  93761. * @param str Source string
  93762. * @param suffix Suffix to search for in the source string
  93763. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93764. */
  93765. static StartsWith(str: string, suffix: string): boolean;
  93766. /**
  93767. * Function used to register events at window level
  93768. * @param events defines the events to register
  93769. */
  93770. static RegisterTopRootEvents(events: {
  93771. name: string;
  93772. handler: Nullable<(e: FocusEvent) => any>;
  93773. }[]): void;
  93774. /**
  93775. * Function used to unregister events from window level
  93776. * @param events defines the events to unregister
  93777. */
  93778. static UnregisterTopRootEvents(events: {
  93779. name: string;
  93780. handler: Nullable<(e: FocusEvent) => any>;
  93781. }[]): void;
  93782. /**
  93783. * @ignore
  93784. */
  93785. static _ScreenshotCanvas: HTMLCanvasElement;
  93786. /**
  93787. * Dumps the current bound framebuffer
  93788. * @param width defines the rendering width
  93789. * @param height defines the rendering height
  93790. * @param engine defines the hosting engine
  93791. * @param successCallback defines the callback triggered once the data are available
  93792. * @param mimeType defines the mime type of the result
  93793. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93794. */
  93795. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93796. /**
  93797. * Converts the canvas data to blob.
  93798. * This acts as a polyfill for browsers not supporting the to blob function.
  93799. * @param canvas Defines the canvas to extract the data from
  93800. * @param successCallback Defines the callback triggered once the data are available
  93801. * @param mimeType Defines the mime type of the result
  93802. */
  93803. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  93804. /**
  93805. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  93806. * @param successCallback defines the callback triggered once the data are available
  93807. * @param mimeType defines the mime type of the result
  93808. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  93809. */
  93810. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93811. /**
  93812. * Downloads a blob in the browser
  93813. * @param blob defines the blob to download
  93814. * @param fileName defines the name of the downloaded file
  93815. */
  93816. static Download(blob: Blob, fileName: string): void;
  93817. /**
  93818. * Captures a screenshot of the current rendering
  93819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93820. * @param engine defines the rendering engine
  93821. * @param camera defines the source camera
  93822. * @param size This parameter can be set to a single number or to an object with the
  93823. * following (optional) properties: precision, width, height. If a single number is passed,
  93824. * it will be used for both width and height. If an object is passed, the screenshot size
  93825. * will be derived from the parameters. The precision property is a multiplier allowing
  93826. * rendering at a higher or lower resolution
  93827. * @param successCallback defines the callback receives a single parameter which contains the
  93828. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93829. * src parameter of an <img> to display it
  93830. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  93831. * Check your browser for supported MIME types
  93832. */
  93833. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  93834. /**
  93835. * Generates an image screenshot from the specified camera.
  93836. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93837. * @param engine The engine to use for rendering
  93838. * @param camera The camera to use for rendering
  93839. * @param size This parameter can be set to a single number or to an object with the
  93840. * following (optional) properties: precision, width, height. If a single number is passed,
  93841. * it will be used for both width and height. If an object is passed, the screenshot size
  93842. * will be derived from the parameters. The precision property is a multiplier allowing
  93843. * rendering at a higher or lower resolution
  93844. * @param successCallback The callback receives a single parameter which contains the
  93845. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93846. * src parameter of an <img> to display it
  93847. * @param mimeType The MIME type of the screenshot image (default: image/png).
  93848. * Check your browser for supported MIME types
  93849. * @param samples Texture samples (default: 1)
  93850. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  93851. * @param fileName A name for for the downloaded file.
  93852. */
  93853. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  93854. /**
  93855. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93856. * Be aware Math.random() could cause collisions, but:
  93857. * "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"
  93858. * @returns a pseudo random id
  93859. */
  93860. static RandomId(): string;
  93861. /**
  93862. * Test if the given uri is a base64 string
  93863. * @param uri The uri to test
  93864. * @return True if the uri is a base64 string or false otherwise
  93865. */
  93866. static IsBase64(uri: string): boolean;
  93867. /**
  93868. * Decode the given base64 uri.
  93869. * @param uri The uri to decode
  93870. * @return The decoded base64 data.
  93871. */
  93872. static DecodeBase64(uri: string): ArrayBuffer;
  93873. /**
  93874. * Gets the absolute url.
  93875. * @param url the input url
  93876. * @return the absolute url
  93877. */
  93878. static GetAbsoluteUrl(url: string): string;
  93879. /**
  93880. * No log
  93881. */
  93882. static readonly NoneLogLevel: number;
  93883. /**
  93884. * Only message logs
  93885. */
  93886. static readonly MessageLogLevel: number;
  93887. /**
  93888. * Only warning logs
  93889. */
  93890. static readonly WarningLogLevel: number;
  93891. /**
  93892. * Only error logs
  93893. */
  93894. static readonly ErrorLogLevel: number;
  93895. /**
  93896. * All logs
  93897. */
  93898. static readonly AllLogLevel: number;
  93899. /**
  93900. * Gets a value indicating the number of loading errors
  93901. * @ignorenaming
  93902. */
  93903. static readonly errorsCount: number;
  93904. /**
  93905. * Callback called when a new log is added
  93906. */
  93907. static OnNewCacheEntry: (entry: string) => void;
  93908. /**
  93909. * Log a message to the console
  93910. * @param message defines the message to log
  93911. */
  93912. static Log(message: string): void;
  93913. /**
  93914. * Write a warning message to the console
  93915. * @param message defines the message to log
  93916. */
  93917. static Warn(message: string): void;
  93918. /**
  93919. * Write an error message to the console
  93920. * @param message defines the message to log
  93921. */
  93922. static Error(message: string): void;
  93923. /**
  93924. * Gets current log cache (list of logs)
  93925. */
  93926. static readonly LogCache: string;
  93927. /**
  93928. * Clears the log cache
  93929. */
  93930. static ClearLogCache(): void;
  93931. /**
  93932. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93933. */
  93934. static LogLevels: number;
  93935. /**
  93936. * Checks if the loaded document was accessed via `file:`-Protocol.
  93937. * @returns boolean
  93938. */
  93939. static IsFileURL(): boolean;
  93940. /**
  93941. * Checks if the window object exists
  93942. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  93943. */
  93944. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  93945. /**
  93946. * No performance log
  93947. */
  93948. static readonly PerformanceNoneLogLevel: number;
  93949. /**
  93950. * Use user marks to log performance
  93951. */
  93952. static readonly PerformanceUserMarkLogLevel: number;
  93953. /**
  93954. * Log performance to the console
  93955. */
  93956. static readonly PerformanceConsoleLogLevel: number;
  93957. private static _performance;
  93958. /**
  93959. * Sets the current performance log level
  93960. */
  93961. static PerformanceLogLevel: number;
  93962. private static _StartPerformanceCounterDisabled;
  93963. private static _EndPerformanceCounterDisabled;
  93964. private static _StartUserMark;
  93965. private static _EndUserMark;
  93966. private static _StartPerformanceConsole;
  93967. private static _EndPerformanceConsole;
  93968. /**
  93969. * Starts a performance counter
  93970. */
  93971. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93972. /**
  93973. * Ends a specific performance coutner
  93974. */
  93975. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93976. /**
  93977. * Gets either window.performance.now() if supported or Date.now() else
  93978. */
  93979. static readonly Now: number;
  93980. /**
  93981. * This method will return the name of the class used to create the instance of the given object.
  93982. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  93983. * @param object the object to get the class name from
  93984. * @param isType defines if the object is actually a type
  93985. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  93986. */
  93987. static GetClassName(object: any, isType?: boolean): string;
  93988. /**
  93989. * Gets the first element of an array satisfying a given predicate
  93990. * @param array defines the array to browse
  93991. * @param predicate defines the predicate to use
  93992. * @returns null if not found or the element
  93993. */
  93994. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  93995. /**
  93996. * This method will return the name of the full name of the class, including its owning module (if any).
  93997. * 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).
  93998. * @param object the object to get the class name from
  93999. * @param isType defines if the object is actually a type
  94000. * @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.
  94001. * @ignorenaming
  94002. */
  94003. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94004. /**
  94005. * Returns a promise that resolves after the given amount of time.
  94006. * @param delay Number of milliseconds to delay
  94007. * @returns Promise that resolves after the given amount of time
  94008. */
  94009. static DelayAsync(delay: number): Promise<void>;
  94010. /**
  94011. * Gets the current gradient from an array of IValueGradient
  94012. * @param ratio defines the current ratio to get
  94013. * @param gradients defines the array of IValueGradient
  94014. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94015. */
  94016. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94017. }
  94018. /**
  94019. * This class is used to track a performance counter which is number based.
  94020. * The user has access to many properties which give statistics of different nature.
  94021. *
  94022. * The implementer can track two kinds of Performance Counter: time and count.
  94023. * 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.
  94024. * 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.
  94025. */
  94026. export class PerfCounter {
  94027. /**
  94028. * Gets or sets a global boolean to turn on and off all the counters
  94029. */
  94030. static Enabled: boolean;
  94031. /**
  94032. * Returns the smallest value ever
  94033. */
  94034. readonly min: number;
  94035. /**
  94036. * Returns the biggest value ever
  94037. */
  94038. readonly max: number;
  94039. /**
  94040. * Returns the average value since the performance counter is running
  94041. */
  94042. readonly average: number;
  94043. /**
  94044. * Returns the average value of the last second the counter was monitored
  94045. */
  94046. readonly lastSecAverage: number;
  94047. /**
  94048. * Returns the current value
  94049. */
  94050. readonly current: number;
  94051. /**
  94052. * Gets the accumulated total
  94053. */
  94054. readonly total: number;
  94055. /**
  94056. * Gets the total value count
  94057. */
  94058. readonly count: number;
  94059. /**
  94060. * Creates a new counter
  94061. */
  94062. constructor();
  94063. /**
  94064. * Call this method to start monitoring a new frame.
  94065. * 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.
  94066. */
  94067. fetchNewFrame(): void;
  94068. /**
  94069. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94070. * @param newCount the count value to add to the monitored count
  94071. * @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.
  94072. */
  94073. addCount(newCount: number, fetchResult: boolean): void;
  94074. /**
  94075. * Start monitoring this performance counter
  94076. */
  94077. beginMonitoring(): void;
  94078. /**
  94079. * Compute the time lapsed since the previous beginMonitoring() call.
  94080. * @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
  94081. */
  94082. endMonitoring(newFrame?: boolean): void;
  94083. private _fetchResult;
  94084. private _startMonitoringTime;
  94085. private _min;
  94086. private _max;
  94087. private _average;
  94088. private _current;
  94089. private _totalValueCount;
  94090. private _totalAccumulated;
  94091. private _lastSecAverage;
  94092. private _lastSecAccumulated;
  94093. private _lastSecTime;
  94094. private _lastSecValueCount;
  94095. }
  94096. /**
  94097. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94098. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94099. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94100. * @param name The name of the class, case should be preserved
  94101. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94102. */
  94103. export function className(name: string, module?: string): (target: Object) => void;
  94104. /**
  94105. * An implementation of a loop for asynchronous functions.
  94106. */
  94107. export class AsyncLoop {
  94108. /**
  94109. * Defines the number of iterations for the loop
  94110. */
  94111. iterations: number;
  94112. /**
  94113. * Defines the current index of the loop.
  94114. */
  94115. index: number;
  94116. private _done;
  94117. private _fn;
  94118. private _successCallback;
  94119. /**
  94120. * Constructor.
  94121. * @param iterations the number of iterations.
  94122. * @param func the function to run each iteration
  94123. * @param successCallback the callback that will be called upon succesful execution
  94124. * @param offset starting offset.
  94125. */
  94126. constructor(
  94127. /**
  94128. * Defines the number of iterations for the loop
  94129. */
  94130. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94131. /**
  94132. * Execute the next iteration. Must be called after the last iteration was finished.
  94133. */
  94134. executeNext(): void;
  94135. /**
  94136. * Break the loop and run the success callback.
  94137. */
  94138. breakLoop(): void;
  94139. /**
  94140. * Create and run an async loop.
  94141. * @param iterations the number of iterations.
  94142. * @param fn the function to run each iteration
  94143. * @param successCallback the callback that will be called upon succesful execution
  94144. * @param offset starting offset.
  94145. * @returns the created async loop object
  94146. */
  94147. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94148. /**
  94149. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94150. * @param iterations total number of iterations
  94151. * @param syncedIterations number of synchronous iterations in each async iteration.
  94152. * @param fn the function to call each iteration.
  94153. * @param callback a success call back that will be called when iterating stops.
  94154. * @param breakFunction a break condition (optional)
  94155. * @param timeout timeout settings for the setTimeout function. default - 0.
  94156. * @returns the created async loop object
  94157. */
  94158. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94159. }
  94160. }
  94161. declare module BABYLON {
  94162. /** @hidden */
  94163. export interface ICollisionCoordinator {
  94164. createCollider(): Collider;
  94165. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94166. init(scene: Scene): void;
  94167. }
  94168. /** @hidden */
  94169. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94170. private _scene;
  94171. private _scaledPosition;
  94172. private _scaledVelocity;
  94173. private _finalPosition;
  94174. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94175. createCollider(): Collider;
  94176. init(scene: Scene): void;
  94177. private _collideWithWorld;
  94178. }
  94179. }
  94180. declare module BABYLON {
  94181. /**
  94182. * Class used to manage all inputs for the scene.
  94183. */
  94184. export class InputManager {
  94185. /** The distance in pixel that you have to move to prevent some events */
  94186. static DragMovementThreshold: number;
  94187. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94188. static LongPressDelay: number;
  94189. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94190. static DoubleClickDelay: number;
  94191. /** If you need to check double click without raising a single click at first click, enable this flag */
  94192. static ExclusiveDoubleClickMode: boolean;
  94193. private _wheelEventName;
  94194. private _onPointerMove;
  94195. private _onPointerDown;
  94196. private _onPointerUp;
  94197. private _initClickEvent;
  94198. private _initActionManager;
  94199. private _delayedSimpleClick;
  94200. private _delayedSimpleClickTimeout;
  94201. private _previousDelayedSimpleClickTimeout;
  94202. private _meshPickProceed;
  94203. private _previousButtonPressed;
  94204. private _currentPickResult;
  94205. private _previousPickResult;
  94206. private _totalPointersPressed;
  94207. private _doubleClickOccured;
  94208. private _pointerOverMesh;
  94209. private _pickedDownMesh;
  94210. private _pickedUpMesh;
  94211. private _pointerX;
  94212. private _pointerY;
  94213. private _unTranslatedPointerX;
  94214. private _unTranslatedPointerY;
  94215. private _startingPointerPosition;
  94216. private _previousStartingPointerPosition;
  94217. private _startingPointerTime;
  94218. private _previousStartingPointerTime;
  94219. private _pointerCaptures;
  94220. private _onKeyDown;
  94221. private _onKeyUp;
  94222. private _onCanvasFocusObserver;
  94223. private _onCanvasBlurObserver;
  94224. private _scene;
  94225. /**
  94226. * Creates a new InputManager
  94227. * @param scene defines the hosting scene
  94228. */
  94229. constructor(scene: Scene);
  94230. /**
  94231. * Gets the mesh that is currently under the pointer
  94232. */
  94233. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94234. /**
  94235. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94236. */
  94237. readonly unTranslatedPointer: Vector2;
  94238. /**
  94239. * Gets or sets the current on-screen X position of the pointer
  94240. */
  94241. pointerX: number;
  94242. /**
  94243. * Gets or sets the current on-screen Y position of the pointer
  94244. */
  94245. pointerY: number;
  94246. private _updatePointerPosition;
  94247. private _processPointerMove;
  94248. private _setRayOnPointerInfo;
  94249. private _checkPrePointerObservable;
  94250. /**
  94251. * Use this method to simulate a pointer move on a mesh
  94252. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94253. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94254. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94255. */
  94256. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94257. /**
  94258. * Use this method to simulate a pointer down on a mesh
  94259. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94260. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94261. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94262. */
  94263. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94264. private _processPointerDown;
  94265. /** @hidden */
  94266. _isPointerSwiping(): boolean;
  94267. /**
  94268. * Use this method to simulate a pointer up on a mesh
  94269. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94270. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94271. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94272. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94273. */
  94274. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94275. private _processPointerUp;
  94276. /**
  94277. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94278. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94279. * @returns true if the pointer was captured
  94280. */
  94281. isPointerCaptured(pointerId?: number): boolean;
  94282. /**
  94283. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94284. * @param attachUp defines if you want to attach events to pointerup
  94285. * @param attachDown defines if you want to attach events to pointerdown
  94286. * @param attachMove defines if you want to attach events to pointermove
  94287. */
  94288. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94289. /**
  94290. * Detaches all event handlers
  94291. */
  94292. detachControl(): void;
  94293. /**
  94294. * Force the value of meshUnderPointer
  94295. * @param mesh defines the mesh to use
  94296. */
  94297. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94298. /**
  94299. * Gets the mesh under the pointer
  94300. * @returns a Mesh or null if no mesh is under the pointer
  94301. */
  94302. getPointerOverMesh(): Nullable<AbstractMesh>;
  94303. }
  94304. }
  94305. declare module BABYLON {
  94306. /**
  94307. * This class defines the direct association between an animation and a target
  94308. */
  94309. export class TargetedAnimation {
  94310. /**
  94311. * Animation to perform
  94312. */
  94313. animation: Animation;
  94314. /**
  94315. * Target to animate
  94316. */
  94317. target: any;
  94318. /**
  94319. * Serialize the object
  94320. * @returns the JSON object representing the current entity
  94321. */
  94322. serialize(): any;
  94323. }
  94324. /**
  94325. * Use this class to create coordinated animations on multiple targets
  94326. */
  94327. export class AnimationGroup implements IDisposable {
  94328. /** The name of the animation group */
  94329. name: string;
  94330. private _scene;
  94331. private _targetedAnimations;
  94332. private _animatables;
  94333. private _from;
  94334. private _to;
  94335. private _isStarted;
  94336. private _isPaused;
  94337. private _speedRatio;
  94338. private _loopAnimation;
  94339. /**
  94340. * Gets or sets the unique id of the node
  94341. */
  94342. uniqueId: number;
  94343. /**
  94344. * This observable will notify when one animation have ended
  94345. */
  94346. onAnimationEndObservable: Observable<TargetedAnimation>;
  94347. /**
  94348. * Observer raised when one animation loops
  94349. */
  94350. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94351. /**
  94352. * This observable will notify when all animations have ended.
  94353. */
  94354. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94355. /**
  94356. * This observable will notify when all animations have paused.
  94357. */
  94358. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94359. /**
  94360. * This observable will notify when all animations are playing.
  94361. */
  94362. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94363. /**
  94364. * Gets the first frame
  94365. */
  94366. readonly from: number;
  94367. /**
  94368. * Gets the last frame
  94369. */
  94370. readonly to: number;
  94371. /**
  94372. * Define if the animations are started
  94373. */
  94374. readonly isStarted: boolean;
  94375. /**
  94376. * Gets a value indicating that the current group is playing
  94377. */
  94378. readonly isPlaying: boolean;
  94379. /**
  94380. * Gets or sets the speed ratio to use for all animations
  94381. */
  94382. /**
  94383. * Gets or sets the speed ratio to use for all animations
  94384. */
  94385. speedRatio: number;
  94386. /**
  94387. * Gets or sets if all animations should loop or not
  94388. */
  94389. loopAnimation: boolean;
  94390. /**
  94391. * Gets the targeted animations for this animation group
  94392. */
  94393. readonly targetedAnimations: Array<TargetedAnimation>;
  94394. /**
  94395. * returning the list of animatables controlled by this animation group.
  94396. */
  94397. readonly animatables: Array<Animatable>;
  94398. /**
  94399. * Instantiates a new Animation Group.
  94400. * This helps managing several animations at once.
  94401. * @see http://doc.babylonjs.com/how_to/group
  94402. * @param name Defines the name of the group
  94403. * @param scene Defines the scene the group belongs to
  94404. */
  94405. constructor(
  94406. /** The name of the animation group */
  94407. name: string, scene?: Nullable<Scene>);
  94408. /**
  94409. * Add an animation (with its target) in the group
  94410. * @param animation defines the animation we want to add
  94411. * @param target defines the target of the animation
  94412. * @returns the TargetedAnimation object
  94413. */
  94414. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94415. /**
  94416. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94417. * It can add constant keys at begin or end
  94418. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94419. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94420. * @returns the animation group
  94421. */
  94422. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94423. /**
  94424. * Start all animations on given targets
  94425. * @param loop defines if animations must loop
  94426. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94427. * @param from defines the from key (optional)
  94428. * @param to defines the to key (optional)
  94429. * @returns the current animation group
  94430. */
  94431. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94432. /**
  94433. * Pause all animations
  94434. * @returns the animation group
  94435. */
  94436. pause(): AnimationGroup;
  94437. /**
  94438. * Play all animations to initial state
  94439. * This function will start() the animations if they were not started or will restart() them if they were paused
  94440. * @param loop defines if animations must loop
  94441. * @returns the animation group
  94442. */
  94443. play(loop?: boolean): AnimationGroup;
  94444. /**
  94445. * Reset all animations to initial state
  94446. * @returns the animation group
  94447. */
  94448. reset(): AnimationGroup;
  94449. /**
  94450. * Restart animations from key 0
  94451. * @returns the animation group
  94452. */
  94453. restart(): AnimationGroup;
  94454. /**
  94455. * Stop all animations
  94456. * @returns the animation group
  94457. */
  94458. stop(): AnimationGroup;
  94459. /**
  94460. * Set animation weight for all animatables
  94461. * @param weight defines the weight to use
  94462. * @return the animationGroup
  94463. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94464. */
  94465. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94466. /**
  94467. * Synchronize and normalize all animatables with a source animatable
  94468. * @param root defines the root animatable to synchronize with
  94469. * @return the animationGroup
  94470. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94471. */
  94472. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94473. /**
  94474. * Goes to a specific frame in this animation group
  94475. * @param frame the frame number to go to
  94476. * @return the animationGroup
  94477. */
  94478. goToFrame(frame: number): AnimationGroup;
  94479. /**
  94480. * Dispose all associated resources
  94481. */
  94482. dispose(): void;
  94483. private _checkAnimationGroupEnded;
  94484. /**
  94485. * Clone the current animation group and returns a copy
  94486. * @param newName defines the name of the new group
  94487. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94488. * @returns the new aniamtion group
  94489. */
  94490. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94491. /**
  94492. * Serializes the animationGroup to an object
  94493. * @returns Serialized object
  94494. */
  94495. serialize(): any;
  94496. /**
  94497. * Returns a new AnimationGroup object parsed from the source provided.
  94498. * @param parsedAnimationGroup defines the source
  94499. * @param scene defines the scene that will receive the animationGroup
  94500. * @returns a new AnimationGroup
  94501. */
  94502. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94503. /**
  94504. * Returns the string "AnimationGroup"
  94505. * @returns "AnimationGroup"
  94506. */
  94507. getClassName(): string;
  94508. /**
  94509. * Creates a detailled string about the object
  94510. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94511. * @returns a string representing the object
  94512. */
  94513. toString(fullDetails?: boolean): string;
  94514. }
  94515. }
  94516. declare module BABYLON {
  94517. /**
  94518. * Define an interface for all classes that will hold resources
  94519. */
  94520. export interface IDisposable {
  94521. /**
  94522. * Releases all held resources
  94523. */
  94524. dispose(): void;
  94525. }
  94526. /** Interface defining initialization parameters for Scene class */
  94527. export interface SceneOptions {
  94528. /**
  94529. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94530. * It will improve performance when the number of geometries becomes important.
  94531. */
  94532. useGeometryUniqueIdsMap?: boolean;
  94533. /**
  94534. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94535. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94536. */
  94537. useMaterialMeshMap?: boolean;
  94538. /**
  94539. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94540. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94541. */
  94542. useClonedMeshhMap?: boolean;
  94543. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94544. virtual?: boolean;
  94545. }
  94546. /**
  94547. * Represents a scene to be rendered by the engine.
  94548. * @see http://doc.babylonjs.com/features/scene
  94549. */
  94550. export class Scene extends AbstractScene implements IAnimatable {
  94551. private static _uniqueIdCounter;
  94552. /** The fog is deactivated */
  94553. static readonly FOGMODE_NONE: number;
  94554. /** The fog density is following an exponential function */
  94555. static readonly FOGMODE_EXP: number;
  94556. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94557. static readonly FOGMODE_EXP2: number;
  94558. /** The fog density is following a linear function. */
  94559. static readonly FOGMODE_LINEAR: number;
  94560. /**
  94561. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94562. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94563. */
  94564. static MinDeltaTime: number;
  94565. /**
  94566. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94567. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94568. */
  94569. static MaxDeltaTime: number;
  94570. /**
  94571. * Factory used to create the default material.
  94572. * @param name The name of the material to create
  94573. * @param scene The scene to create the material for
  94574. * @returns The default material
  94575. */
  94576. static DefaultMaterialFactory(scene: Scene): Material;
  94577. /**
  94578. * Factory used to create the a collision coordinator.
  94579. * @returns The collision coordinator
  94580. */
  94581. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94582. /** @hidden */
  94583. _inputManager: InputManager;
  94584. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94585. cameraToUseForPointers: Nullable<Camera>;
  94586. /** @hidden */
  94587. readonly _isScene: boolean;
  94588. /**
  94589. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94590. */
  94591. autoClear: boolean;
  94592. /**
  94593. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94594. */
  94595. autoClearDepthAndStencil: boolean;
  94596. /**
  94597. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94598. */
  94599. clearColor: Color4;
  94600. /**
  94601. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94602. */
  94603. ambientColor: Color3;
  94604. /**
  94605. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94606. * It should only be one of the following (if not the default embedded one):
  94607. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94608. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94609. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94610. * The material properties need to be setup according to the type of texture in use.
  94611. */
  94612. environmentBRDFTexture: BaseTexture;
  94613. /** @hidden */
  94614. protected _environmentTexture: Nullable<BaseTexture>;
  94615. /**
  94616. * Texture used in all pbr material as the reflection texture.
  94617. * As in the majority of the scene they are the same (exception for multi room and so on),
  94618. * this is easier to reference from here than from all the materials.
  94619. */
  94620. /**
  94621. * Texture used in all pbr material as the reflection texture.
  94622. * As in the majority of the scene they are the same (exception for multi room and so on),
  94623. * this is easier to set here than in all the materials.
  94624. */
  94625. environmentTexture: Nullable<BaseTexture>;
  94626. /** @hidden */
  94627. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94628. /**
  94629. * Default image processing configuration used either in the rendering
  94630. * Forward main pass or through the imageProcessingPostProcess if present.
  94631. * As in the majority of the scene they are the same (exception for multi camera),
  94632. * this is easier to reference from here than from all the materials and post process.
  94633. *
  94634. * No setter as we it is a shared configuration, you can set the values instead.
  94635. */
  94636. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94637. private _forceWireframe;
  94638. /**
  94639. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94640. */
  94641. forceWireframe: boolean;
  94642. private _forcePointsCloud;
  94643. /**
  94644. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94645. */
  94646. forcePointsCloud: boolean;
  94647. /**
  94648. * Gets or sets the active clipplane 1
  94649. */
  94650. clipPlane: Nullable<Plane>;
  94651. /**
  94652. * Gets or sets the active clipplane 2
  94653. */
  94654. clipPlane2: Nullable<Plane>;
  94655. /**
  94656. * Gets or sets the active clipplane 3
  94657. */
  94658. clipPlane3: Nullable<Plane>;
  94659. /**
  94660. * Gets or sets the active clipplane 4
  94661. */
  94662. clipPlane4: Nullable<Plane>;
  94663. /**
  94664. * Gets or sets a boolean indicating if animations are enabled
  94665. */
  94666. animationsEnabled: boolean;
  94667. private _animationPropertiesOverride;
  94668. /**
  94669. * Gets or sets the animation properties override
  94670. */
  94671. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94672. /**
  94673. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94674. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94675. */
  94676. useConstantAnimationDeltaTime: boolean;
  94677. /**
  94678. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94679. * Please note that it requires to run a ray cast through the scene on every frame
  94680. */
  94681. constantlyUpdateMeshUnderPointer: boolean;
  94682. /**
  94683. * Defines the HTML cursor to use when hovering over interactive elements
  94684. */
  94685. hoverCursor: string;
  94686. /**
  94687. * Defines the HTML default cursor to use (empty by default)
  94688. */
  94689. defaultCursor: string;
  94690. /**
  94691. * This is used to call preventDefault() on pointer down
  94692. * in order to block unwanted artifacts like system double clicks
  94693. */
  94694. preventDefaultOnPointerDown: boolean;
  94695. /**
  94696. * This is used to call preventDefault() on pointer up
  94697. * in order to block unwanted artifacts like system double clicks
  94698. */
  94699. preventDefaultOnPointerUp: boolean;
  94700. /**
  94701. * Gets or sets user defined metadata
  94702. */
  94703. metadata: any;
  94704. /**
  94705. * For internal use only. Please do not use.
  94706. */
  94707. reservedDataStore: any;
  94708. /**
  94709. * Gets the name of the plugin used to load this scene (null by default)
  94710. */
  94711. loadingPluginName: string;
  94712. /**
  94713. * Use this array to add regular expressions used to disable offline support for specific urls
  94714. */
  94715. disableOfflineSupportExceptionRules: RegExp[];
  94716. /**
  94717. * An event triggered when the scene is disposed.
  94718. */
  94719. onDisposeObservable: Observable<Scene>;
  94720. private _onDisposeObserver;
  94721. /** Sets a function to be executed when this scene is disposed. */
  94722. onDispose: () => void;
  94723. /**
  94724. * An event triggered before rendering the scene (right after animations and physics)
  94725. */
  94726. onBeforeRenderObservable: Observable<Scene>;
  94727. private _onBeforeRenderObserver;
  94728. /** Sets a function to be executed before rendering this scene */
  94729. beforeRender: Nullable<() => void>;
  94730. /**
  94731. * An event triggered after rendering the scene
  94732. */
  94733. onAfterRenderObservable: Observable<Scene>;
  94734. /**
  94735. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  94736. */
  94737. onAfterRenderCameraObservable: Observable<Camera>;
  94738. private _onAfterRenderObserver;
  94739. /** Sets a function to be executed after rendering this scene */
  94740. afterRender: Nullable<() => void>;
  94741. /**
  94742. * An event triggered before animating the scene
  94743. */
  94744. onBeforeAnimationsObservable: Observable<Scene>;
  94745. /**
  94746. * An event triggered after animations processing
  94747. */
  94748. onAfterAnimationsObservable: Observable<Scene>;
  94749. /**
  94750. * An event triggered before draw calls are ready to be sent
  94751. */
  94752. onBeforeDrawPhaseObservable: Observable<Scene>;
  94753. /**
  94754. * An event triggered after draw calls have been sent
  94755. */
  94756. onAfterDrawPhaseObservable: Observable<Scene>;
  94757. /**
  94758. * An event triggered when the scene is ready
  94759. */
  94760. onReadyObservable: Observable<Scene>;
  94761. /**
  94762. * An event triggered before rendering a camera
  94763. */
  94764. onBeforeCameraRenderObservable: Observable<Camera>;
  94765. private _onBeforeCameraRenderObserver;
  94766. /** Sets a function to be executed before rendering a camera*/
  94767. beforeCameraRender: () => void;
  94768. /**
  94769. * An event triggered after rendering a camera
  94770. */
  94771. onAfterCameraRenderObservable: Observable<Camera>;
  94772. private _onAfterCameraRenderObserver;
  94773. /** Sets a function to be executed after rendering a camera*/
  94774. afterCameraRender: () => void;
  94775. /**
  94776. * An event triggered when active meshes evaluation is about to start
  94777. */
  94778. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94779. /**
  94780. * An event triggered when active meshes evaluation is done
  94781. */
  94782. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94783. /**
  94784. * An event triggered when particles rendering is about to start
  94785. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94786. */
  94787. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94788. /**
  94789. * An event triggered when particles rendering is done
  94790. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94791. */
  94792. onAfterParticlesRenderingObservable: Observable<Scene>;
  94793. /**
  94794. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94795. */
  94796. onDataLoadedObservable: Observable<Scene>;
  94797. /**
  94798. * An event triggered when a camera is created
  94799. */
  94800. onNewCameraAddedObservable: Observable<Camera>;
  94801. /**
  94802. * An event triggered when a camera is removed
  94803. */
  94804. onCameraRemovedObservable: Observable<Camera>;
  94805. /**
  94806. * An event triggered when a light is created
  94807. */
  94808. onNewLightAddedObservable: Observable<Light>;
  94809. /**
  94810. * An event triggered when a light is removed
  94811. */
  94812. onLightRemovedObservable: Observable<Light>;
  94813. /**
  94814. * An event triggered when a geometry is created
  94815. */
  94816. onNewGeometryAddedObservable: Observable<Geometry>;
  94817. /**
  94818. * An event triggered when a geometry is removed
  94819. */
  94820. onGeometryRemovedObservable: Observable<Geometry>;
  94821. /**
  94822. * An event triggered when a transform node is created
  94823. */
  94824. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  94825. /**
  94826. * An event triggered when a transform node is removed
  94827. */
  94828. onTransformNodeRemovedObservable: Observable<TransformNode>;
  94829. /**
  94830. * An event triggered when a mesh is created
  94831. */
  94832. onNewMeshAddedObservable: Observable<AbstractMesh>;
  94833. /**
  94834. * An event triggered when a mesh is removed
  94835. */
  94836. onMeshRemovedObservable: Observable<AbstractMesh>;
  94837. /**
  94838. * An event triggered when a skeleton is created
  94839. */
  94840. onNewSkeletonAddedObservable: Observable<Skeleton>;
  94841. /**
  94842. * An event triggered when a skeleton is removed
  94843. */
  94844. onSkeletonRemovedObservable: Observable<Skeleton>;
  94845. /**
  94846. * An event triggered when a material is created
  94847. */
  94848. onNewMaterialAddedObservable: Observable<Material>;
  94849. /**
  94850. * An event triggered when a material is removed
  94851. */
  94852. onMaterialRemovedObservable: Observable<Material>;
  94853. /**
  94854. * An event triggered when a texture is created
  94855. */
  94856. onNewTextureAddedObservable: Observable<BaseTexture>;
  94857. /**
  94858. * An event triggered when a texture is removed
  94859. */
  94860. onTextureRemovedObservable: Observable<BaseTexture>;
  94861. /**
  94862. * An event triggered when render targets are about to be rendered
  94863. * Can happen multiple times per frame.
  94864. */
  94865. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  94866. /**
  94867. * An event triggered when render targets were rendered.
  94868. * Can happen multiple times per frame.
  94869. */
  94870. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  94871. /**
  94872. * An event triggered before calculating deterministic simulation step
  94873. */
  94874. onBeforeStepObservable: Observable<Scene>;
  94875. /**
  94876. * An event triggered after calculating deterministic simulation step
  94877. */
  94878. onAfterStepObservable: Observable<Scene>;
  94879. /**
  94880. * An event triggered when the activeCamera property is updated
  94881. */
  94882. onActiveCameraChanged: Observable<Scene>;
  94883. /**
  94884. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  94885. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94886. * 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)
  94887. */
  94888. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94889. /**
  94890. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  94891. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94892. * 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)
  94893. */
  94894. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94895. /**
  94896. * This Observable will when a mesh has been imported into the scene.
  94897. */
  94898. onMeshImportedObservable: Observable<AbstractMesh>;
  94899. /**
  94900. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  94901. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  94902. */
  94903. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  94904. /** @hidden */
  94905. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  94906. /**
  94907. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  94908. */
  94909. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  94910. /**
  94911. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  94912. */
  94913. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  94914. /**
  94915. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  94916. */
  94917. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  94918. /** Callback called when a pointer move is detected */
  94919. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94920. /** Callback called when a pointer down is detected */
  94921. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94922. /** Callback called when a pointer up is detected */
  94923. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  94924. /** Callback called when a pointer pick is detected */
  94925. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  94926. /**
  94927. * 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).
  94928. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  94929. */
  94930. onPrePointerObservable: Observable<PointerInfoPre>;
  94931. /**
  94932. * Observable event triggered each time an input event is received from the rendering canvas
  94933. */
  94934. onPointerObservable: Observable<PointerInfo>;
  94935. /**
  94936. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  94937. */
  94938. readonly unTranslatedPointer: Vector2;
  94939. /**
  94940. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  94941. */
  94942. static DragMovementThreshold: number;
  94943. /**
  94944. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  94945. */
  94946. static LongPressDelay: number;
  94947. /**
  94948. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  94949. */
  94950. static DoubleClickDelay: number;
  94951. /** If you need to check double click without raising a single click at first click, enable this flag */
  94952. static ExclusiveDoubleClickMode: boolean;
  94953. /** @hidden */
  94954. _mirroredCameraPosition: Nullable<Vector3>;
  94955. /**
  94956. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  94957. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  94958. */
  94959. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  94960. /**
  94961. * Observable event triggered each time an keyboard event is received from the hosting window
  94962. */
  94963. onKeyboardObservable: Observable<KeyboardInfo>;
  94964. private _useRightHandedSystem;
  94965. /**
  94966. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  94967. */
  94968. useRightHandedSystem: boolean;
  94969. private _timeAccumulator;
  94970. private _currentStepId;
  94971. private _currentInternalStep;
  94972. /**
  94973. * Sets the step Id used by deterministic lock step
  94974. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94975. * @param newStepId defines the step Id
  94976. */
  94977. setStepId(newStepId: number): void;
  94978. /**
  94979. * Gets the step Id used by deterministic lock step
  94980. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94981. * @returns the step Id
  94982. */
  94983. getStepId(): number;
  94984. /**
  94985. * Gets the internal step used by deterministic lock step
  94986. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94987. * @returns the internal step
  94988. */
  94989. getInternalStep(): number;
  94990. private _fogEnabled;
  94991. /**
  94992. * Gets or sets a boolean indicating if fog is enabled on this scene
  94993. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94994. * (Default is true)
  94995. */
  94996. fogEnabled: boolean;
  94997. private _fogMode;
  94998. /**
  94999. * Gets or sets the fog mode to use
  95000. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95001. * | mode | value |
  95002. * | --- | --- |
  95003. * | FOGMODE_NONE | 0 |
  95004. * | FOGMODE_EXP | 1 |
  95005. * | FOGMODE_EXP2 | 2 |
  95006. * | FOGMODE_LINEAR | 3 |
  95007. */
  95008. fogMode: number;
  95009. /**
  95010. * Gets or sets the fog color to use
  95011. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95012. * (Default is Color3(0.2, 0.2, 0.3))
  95013. */
  95014. fogColor: Color3;
  95015. /**
  95016. * Gets or sets the fog density to use
  95017. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95018. * (Default is 0.1)
  95019. */
  95020. fogDensity: number;
  95021. /**
  95022. * Gets or sets the fog start distance to use
  95023. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95024. * (Default is 0)
  95025. */
  95026. fogStart: number;
  95027. /**
  95028. * Gets or sets the fog end distance to use
  95029. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95030. * (Default is 1000)
  95031. */
  95032. fogEnd: number;
  95033. private _shadowsEnabled;
  95034. /**
  95035. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95036. */
  95037. shadowsEnabled: boolean;
  95038. private _lightsEnabled;
  95039. /**
  95040. * Gets or sets a boolean indicating if lights are enabled on this scene
  95041. */
  95042. lightsEnabled: boolean;
  95043. /** All of the active cameras added to this scene. */
  95044. activeCameras: Camera[];
  95045. /** @hidden */
  95046. _activeCamera: Nullable<Camera>;
  95047. /** Gets or sets the current active camera */
  95048. activeCamera: Nullable<Camera>;
  95049. private _defaultMaterial;
  95050. /** The default material used on meshes when no material is affected */
  95051. /** The default material used on meshes when no material is affected */
  95052. defaultMaterial: Material;
  95053. private _texturesEnabled;
  95054. /**
  95055. * Gets or sets a boolean indicating if textures are enabled on this scene
  95056. */
  95057. texturesEnabled: boolean;
  95058. /**
  95059. * Gets or sets a boolean indicating if particles are enabled on this scene
  95060. */
  95061. particlesEnabled: boolean;
  95062. /**
  95063. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95064. */
  95065. spritesEnabled: boolean;
  95066. private _skeletonsEnabled;
  95067. /**
  95068. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95069. */
  95070. skeletonsEnabled: boolean;
  95071. /**
  95072. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95073. */
  95074. lensFlaresEnabled: boolean;
  95075. /**
  95076. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95078. */
  95079. collisionsEnabled: boolean;
  95080. private _collisionCoordinator;
  95081. /** @hidden */
  95082. readonly collisionCoordinator: ICollisionCoordinator;
  95083. /**
  95084. * Defines the gravity applied to this scene (used only for collisions)
  95085. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95086. */
  95087. gravity: Vector3;
  95088. /**
  95089. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95090. */
  95091. postProcessesEnabled: boolean;
  95092. /**
  95093. * The list of postprocesses added to the scene
  95094. */
  95095. postProcesses: PostProcess[];
  95096. /**
  95097. * Gets the current postprocess manager
  95098. */
  95099. postProcessManager: PostProcessManager;
  95100. /**
  95101. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95102. */
  95103. renderTargetsEnabled: boolean;
  95104. /**
  95105. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95106. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95107. */
  95108. dumpNextRenderTargets: boolean;
  95109. /**
  95110. * The list of user defined render targets added to the scene
  95111. */
  95112. customRenderTargets: RenderTargetTexture[];
  95113. /**
  95114. * Defines if texture loading must be delayed
  95115. * If true, textures will only be loaded when they need to be rendered
  95116. */
  95117. useDelayedTextureLoading: boolean;
  95118. /**
  95119. * Gets the list of meshes imported to the scene through SceneLoader
  95120. */
  95121. importedMeshesFiles: String[];
  95122. /**
  95123. * Gets or sets a boolean indicating if probes are enabled on this scene
  95124. */
  95125. probesEnabled: boolean;
  95126. /**
  95127. * Gets or sets the current offline provider to use to store scene data
  95128. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95129. */
  95130. offlineProvider: IOfflineProvider;
  95131. /**
  95132. * Gets or sets the action manager associated with the scene
  95133. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95134. */
  95135. actionManager: AbstractActionManager;
  95136. private _meshesForIntersections;
  95137. /**
  95138. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95139. */
  95140. proceduralTexturesEnabled: boolean;
  95141. private _engine;
  95142. private _totalVertices;
  95143. /** @hidden */
  95144. _activeIndices: PerfCounter;
  95145. /** @hidden */
  95146. _activeParticles: PerfCounter;
  95147. /** @hidden */
  95148. _activeBones: PerfCounter;
  95149. private _animationRatio;
  95150. /** @hidden */
  95151. _animationTimeLast: number;
  95152. /** @hidden */
  95153. _animationTime: number;
  95154. /**
  95155. * Gets or sets a general scale for animation speed
  95156. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95157. */
  95158. animationTimeScale: number;
  95159. /** @hidden */
  95160. _cachedMaterial: Nullable<Material>;
  95161. /** @hidden */
  95162. _cachedEffect: Nullable<Effect>;
  95163. /** @hidden */
  95164. _cachedVisibility: Nullable<number>;
  95165. private _renderId;
  95166. private _frameId;
  95167. private _executeWhenReadyTimeoutId;
  95168. private _intermediateRendering;
  95169. private _viewUpdateFlag;
  95170. private _projectionUpdateFlag;
  95171. /** @hidden */
  95172. _toBeDisposed: Nullable<IDisposable>[];
  95173. private _activeRequests;
  95174. /** @hidden */
  95175. _pendingData: any[];
  95176. private _isDisposed;
  95177. /**
  95178. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95179. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95180. */
  95181. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95182. private _activeMeshes;
  95183. private _processedMaterials;
  95184. private _renderTargets;
  95185. /** @hidden */
  95186. _activeParticleSystems: SmartArray<IParticleSystem>;
  95187. private _activeSkeletons;
  95188. private _softwareSkinnedMeshes;
  95189. private _renderingManager;
  95190. /** @hidden */
  95191. _activeAnimatables: Animatable[];
  95192. private _transformMatrix;
  95193. private _sceneUbo;
  95194. /** @hidden */
  95195. _viewMatrix: Matrix;
  95196. private _projectionMatrix;
  95197. /** @hidden */
  95198. _forcedViewPosition: Nullable<Vector3>;
  95199. /** @hidden */
  95200. _frustumPlanes: Plane[];
  95201. /**
  95202. * Gets the list of frustum planes (built from the active camera)
  95203. */
  95204. readonly frustumPlanes: Plane[];
  95205. /**
  95206. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95207. * This is useful if there are more lights that the maximum simulteanous authorized
  95208. */
  95209. requireLightSorting: boolean;
  95210. /** @hidden */
  95211. readonly useMaterialMeshMap: boolean;
  95212. /** @hidden */
  95213. readonly useClonedMeshhMap: boolean;
  95214. private _externalData;
  95215. private _uid;
  95216. /**
  95217. * @hidden
  95218. * Backing store of defined scene components.
  95219. */
  95220. _components: ISceneComponent[];
  95221. /**
  95222. * @hidden
  95223. * Backing store of defined scene components.
  95224. */
  95225. _serializableComponents: ISceneSerializableComponent[];
  95226. /**
  95227. * List of components to register on the next registration step.
  95228. */
  95229. private _transientComponents;
  95230. /**
  95231. * Registers the transient components if needed.
  95232. */
  95233. private _registerTransientComponents;
  95234. /**
  95235. * @hidden
  95236. * Add a component to the scene.
  95237. * Note that the ccomponent could be registered on th next frame if this is called after
  95238. * the register component stage.
  95239. * @param component Defines the component to add to the scene
  95240. */
  95241. _addComponent(component: ISceneComponent): void;
  95242. /**
  95243. * @hidden
  95244. * Gets a component from the scene.
  95245. * @param name defines the name of the component to retrieve
  95246. * @returns the component or null if not present
  95247. */
  95248. _getComponent(name: string): Nullable<ISceneComponent>;
  95249. /**
  95250. * @hidden
  95251. * Defines the actions happening before camera updates.
  95252. */
  95253. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95254. /**
  95255. * @hidden
  95256. * Defines the actions happening before clear the canvas.
  95257. */
  95258. _beforeClearStage: Stage<SimpleStageAction>;
  95259. /**
  95260. * @hidden
  95261. * Defines the actions when collecting render targets for the frame.
  95262. */
  95263. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95264. /**
  95265. * @hidden
  95266. * Defines the actions happening for one camera in the frame.
  95267. */
  95268. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95269. /**
  95270. * @hidden
  95271. * Defines the actions happening during the per mesh ready checks.
  95272. */
  95273. _isReadyForMeshStage: Stage<MeshStageAction>;
  95274. /**
  95275. * @hidden
  95276. * Defines the actions happening before evaluate active mesh checks.
  95277. */
  95278. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95279. /**
  95280. * @hidden
  95281. * Defines the actions happening during the evaluate sub mesh checks.
  95282. */
  95283. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95284. /**
  95285. * @hidden
  95286. * Defines the actions happening during the active mesh stage.
  95287. */
  95288. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95289. /**
  95290. * @hidden
  95291. * Defines the actions happening during the per camera render target step.
  95292. */
  95293. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95294. /**
  95295. * @hidden
  95296. * Defines the actions happening just before the active camera is drawing.
  95297. */
  95298. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95299. /**
  95300. * @hidden
  95301. * Defines the actions happening just before a render target is drawing.
  95302. */
  95303. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95304. /**
  95305. * @hidden
  95306. * Defines the actions happening just before a rendering group is drawing.
  95307. */
  95308. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95309. /**
  95310. * @hidden
  95311. * Defines the actions happening just before a mesh is drawing.
  95312. */
  95313. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95314. /**
  95315. * @hidden
  95316. * Defines the actions happening just after a mesh has been drawn.
  95317. */
  95318. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95319. /**
  95320. * @hidden
  95321. * Defines the actions happening just after a rendering group has been drawn.
  95322. */
  95323. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95324. /**
  95325. * @hidden
  95326. * Defines the actions happening just after the active camera has been drawn.
  95327. */
  95328. _afterCameraDrawStage: Stage<CameraStageAction>;
  95329. /**
  95330. * @hidden
  95331. * Defines the actions happening just after a render target has been drawn.
  95332. */
  95333. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95334. /**
  95335. * @hidden
  95336. * Defines the actions happening just after rendering all cameras and computing intersections.
  95337. */
  95338. _afterRenderStage: Stage<SimpleStageAction>;
  95339. /**
  95340. * @hidden
  95341. * Defines the actions happening when a pointer move event happens.
  95342. */
  95343. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95344. /**
  95345. * @hidden
  95346. * Defines the actions happening when a pointer down event happens.
  95347. */
  95348. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95349. /**
  95350. * @hidden
  95351. * Defines the actions happening when a pointer up event happens.
  95352. */
  95353. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95354. /**
  95355. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95356. */
  95357. private geometriesByUniqueId;
  95358. /**
  95359. * Creates a new Scene
  95360. * @param engine defines the engine to use to render this scene
  95361. * @param options defines the scene options
  95362. */
  95363. constructor(engine: Engine, options?: SceneOptions);
  95364. /**
  95365. * Gets a string idenfifying the name of the class
  95366. * @returns "Scene" string
  95367. */
  95368. getClassName(): string;
  95369. private _defaultMeshCandidates;
  95370. /**
  95371. * @hidden
  95372. */
  95373. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95374. private _defaultSubMeshCandidates;
  95375. /**
  95376. * @hidden
  95377. */
  95378. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95379. /**
  95380. * Sets the default candidate providers for the scene.
  95381. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95382. * and getCollidingSubMeshCandidates to their default function
  95383. */
  95384. setDefaultCandidateProviders(): void;
  95385. /**
  95386. * Gets the mesh that is currently under the pointer
  95387. */
  95388. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95389. /**
  95390. * Gets or sets the current on-screen X position of the pointer
  95391. */
  95392. pointerX: number;
  95393. /**
  95394. * Gets or sets the current on-screen Y position of the pointer
  95395. */
  95396. pointerY: number;
  95397. /**
  95398. * Gets the cached material (ie. the latest rendered one)
  95399. * @returns the cached material
  95400. */
  95401. getCachedMaterial(): Nullable<Material>;
  95402. /**
  95403. * Gets the cached effect (ie. the latest rendered one)
  95404. * @returns the cached effect
  95405. */
  95406. getCachedEffect(): Nullable<Effect>;
  95407. /**
  95408. * Gets the cached visibility state (ie. the latest rendered one)
  95409. * @returns the cached visibility state
  95410. */
  95411. getCachedVisibility(): Nullable<number>;
  95412. /**
  95413. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95414. * @param material defines the current material
  95415. * @param effect defines the current effect
  95416. * @param visibility defines the current visibility state
  95417. * @returns true if one parameter is not cached
  95418. */
  95419. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95420. /**
  95421. * Gets the engine associated with the scene
  95422. * @returns an Engine
  95423. */
  95424. getEngine(): Engine;
  95425. /**
  95426. * Gets the total number of vertices rendered per frame
  95427. * @returns the total number of vertices rendered per frame
  95428. */
  95429. getTotalVertices(): number;
  95430. /**
  95431. * Gets the performance counter for total vertices
  95432. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95433. */
  95434. readonly totalVerticesPerfCounter: PerfCounter;
  95435. /**
  95436. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95437. * @returns the total number of active indices rendered per frame
  95438. */
  95439. getActiveIndices(): number;
  95440. /**
  95441. * Gets the performance counter for active indices
  95442. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95443. */
  95444. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95445. /**
  95446. * Gets the total number of active particles rendered per frame
  95447. * @returns the total number of active particles rendered per frame
  95448. */
  95449. getActiveParticles(): number;
  95450. /**
  95451. * Gets the performance counter for active particles
  95452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95453. */
  95454. readonly activeParticlesPerfCounter: PerfCounter;
  95455. /**
  95456. * Gets the total number of active bones rendered per frame
  95457. * @returns the total number of active bones rendered per frame
  95458. */
  95459. getActiveBones(): number;
  95460. /**
  95461. * Gets the performance counter for active bones
  95462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95463. */
  95464. readonly activeBonesPerfCounter: PerfCounter;
  95465. /**
  95466. * Gets the array of active meshes
  95467. * @returns an array of AbstractMesh
  95468. */
  95469. getActiveMeshes(): SmartArray<AbstractMesh>;
  95470. /**
  95471. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95472. * @returns a number
  95473. */
  95474. getAnimationRatio(): number;
  95475. /**
  95476. * Gets an unique Id for the current render phase
  95477. * @returns a number
  95478. */
  95479. getRenderId(): number;
  95480. /**
  95481. * Gets an unique Id for the current frame
  95482. * @returns a number
  95483. */
  95484. getFrameId(): number;
  95485. /** Call this function if you want to manually increment the render Id*/
  95486. incrementRenderId(): void;
  95487. private _createUbo;
  95488. /**
  95489. * Use this method to simulate a pointer move on a mesh
  95490. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95491. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95492. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95493. * @returns the current scene
  95494. */
  95495. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95496. /**
  95497. * Use this method to simulate a pointer down on a mesh
  95498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95501. * @returns the current scene
  95502. */
  95503. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95504. /**
  95505. * Use this method to simulate a pointer up on a mesh
  95506. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95507. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95508. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95509. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95510. * @returns the current scene
  95511. */
  95512. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95513. /**
  95514. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95515. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95516. * @returns true if the pointer was captured
  95517. */
  95518. isPointerCaptured(pointerId?: number): boolean;
  95519. /**
  95520. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95521. * @param attachUp defines if you want to attach events to pointerup
  95522. * @param attachDown defines if you want to attach events to pointerdown
  95523. * @param attachMove defines if you want to attach events to pointermove
  95524. */
  95525. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95526. /** Detaches all event handlers*/
  95527. detachControl(): void;
  95528. /**
  95529. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95530. * Delay loaded resources are not taking in account
  95531. * @return true if all required resources are ready
  95532. */
  95533. isReady(): boolean;
  95534. /** Resets all cached information relative to material (including effect and visibility) */
  95535. resetCachedMaterial(): void;
  95536. /**
  95537. * Registers a function to be called before every frame render
  95538. * @param func defines the function to register
  95539. */
  95540. registerBeforeRender(func: () => void): void;
  95541. /**
  95542. * Unregisters a function called before every frame render
  95543. * @param func defines the function to unregister
  95544. */
  95545. unregisterBeforeRender(func: () => void): void;
  95546. /**
  95547. * Registers a function to be called after every frame render
  95548. * @param func defines the function to register
  95549. */
  95550. registerAfterRender(func: () => void): void;
  95551. /**
  95552. * Unregisters a function called after every frame render
  95553. * @param func defines the function to unregister
  95554. */
  95555. unregisterAfterRender(func: () => void): void;
  95556. private _executeOnceBeforeRender;
  95557. /**
  95558. * The provided function will run before render once and will be disposed afterwards.
  95559. * A timeout delay can be provided so that the function will be executed in N ms.
  95560. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95561. * @param func The function to be executed.
  95562. * @param timeout optional delay in ms
  95563. */
  95564. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95565. /** @hidden */
  95566. _addPendingData(data: any): void;
  95567. /** @hidden */
  95568. _removePendingData(data: any): void;
  95569. /**
  95570. * Returns the number of items waiting to be loaded
  95571. * @returns the number of items waiting to be loaded
  95572. */
  95573. getWaitingItemsCount(): number;
  95574. /**
  95575. * Returns a boolean indicating if the scene is still loading data
  95576. */
  95577. readonly isLoading: boolean;
  95578. /**
  95579. * Registers a function to be executed when the scene is ready
  95580. * @param {Function} func - the function to be executed
  95581. */
  95582. executeWhenReady(func: () => void): void;
  95583. /**
  95584. * Returns a promise that resolves when the scene is ready
  95585. * @returns A promise that resolves when the scene is ready
  95586. */
  95587. whenReadyAsync(): Promise<void>;
  95588. /** @hidden */
  95589. _checkIsReady(): void;
  95590. /**
  95591. * Gets all animatable attached to the scene
  95592. */
  95593. readonly animatables: Animatable[];
  95594. /**
  95595. * Resets the last animation time frame.
  95596. * Useful to override when animations start running when loading a scene for the first time.
  95597. */
  95598. resetLastAnimationTimeFrame(): void;
  95599. /**
  95600. * Gets the current view matrix
  95601. * @returns a Matrix
  95602. */
  95603. getViewMatrix(): Matrix;
  95604. /**
  95605. * Gets the current projection matrix
  95606. * @returns a Matrix
  95607. */
  95608. getProjectionMatrix(): Matrix;
  95609. /**
  95610. * Gets the current transform matrix
  95611. * @returns a Matrix made of View * Projection
  95612. */
  95613. getTransformMatrix(): Matrix;
  95614. /**
  95615. * Sets the current transform matrix
  95616. * @param viewL defines the View matrix to use
  95617. * @param projectionL defines the Projection matrix to use
  95618. * @param viewR defines the right View matrix to use (if provided)
  95619. * @param projectionR defines the right Projection matrix to use (if provided)
  95620. */
  95621. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95622. /**
  95623. * Gets the uniform buffer used to store scene data
  95624. * @returns a UniformBuffer
  95625. */
  95626. getSceneUniformBuffer(): UniformBuffer;
  95627. /**
  95628. * Gets an unique (relatively to the current scene) Id
  95629. * @returns an unique number for the scene
  95630. */
  95631. getUniqueId(): number;
  95632. /**
  95633. * Add a mesh to the list of scene's meshes
  95634. * @param newMesh defines the mesh to add
  95635. * @param recursive if all child meshes should also be added to the scene
  95636. */
  95637. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95638. /**
  95639. * Remove a mesh for the list of scene's meshes
  95640. * @param toRemove defines the mesh to remove
  95641. * @param recursive if all child meshes should also be removed from the scene
  95642. * @returns the index where the mesh was in the mesh list
  95643. */
  95644. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95645. /**
  95646. * Add a transform node to the list of scene's transform nodes
  95647. * @param newTransformNode defines the transform node to add
  95648. */
  95649. addTransformNode(newTransformNode: TransformNode): void;
  95650. /**
  95651. * Remove a transform node for the list of scene's transform nodes
  95652. * @param toRemove defines the transform node to remove
  95653. * @returns the index where the transform node was in the transform node list
  95654. */
  95655. removeTransformNode(toRemove: TransformNode): number;
  95656. /**
  95657. * Remove a skeleton for the list of scene's skeletons
  95658. * @param toRemove defines the skeleton to remove
  95659. * @returns the index where the skeleton was in the skeleton list
  95660. */
  95661. removeSkeleton(toRemove: Skeleton): number;
  95662. /**
  95663. * Remove a morph target for the list of scene's morph targets
  95664. * @param toRemove defines the morph target to remove
  95665. * @returns the index where the morph target was in the morph target list
  95666. */
  95667. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95668. /**
  95669. * Remove a light for the list of scene's lights
  95670. * @param toRemove defines the light to remove
  95671. * @returns the index where the light was in the light list
  95672. */
  95673. removeLight(toRemove: Light): number;
  95674. /**
  95675. * Remove a camera for the list of scene's cameras
  95676. * @param toRemove defines the camera to remove
  95677. * @returns the index where the camera was in the camera list
  95678. */
  95679. removeCamera(toRemove: Camera): number;
  95680. /**
  95681. * Remove a particle system for the list of scene's particle systems
  95682. * @param toRemove defines the particle system to remove
  95683. * @returns the index where the particle system was in the particle system list
  95684. */
  95685. removeParticleSystem(toRemove: IParticleSystem): number;
  95686. /**
  95687. * Remove a animation for the list of scene's animations
  95688. * @param toRemove defines the animation to remove
  95689. * @returns the index where the animation was in the animation list
  95690. */
  95691. removeAnimation(toRemove: Animation): number;
  95692. /**
  95693. * Will stop the animation of the given target
  95694. * @param target - the target
  95695. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95696. * @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)
  95697. */
  95698. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95699. /**
  95700. * Removes the given animation group from this scene.
  95701. * @param toRemove The animation group to remove
  95702. * @returns The index of the removed animation group
  95703. */
  95704. removeAnimationGroup(toRemove: AnimationGroup): number;
  95705. /**
  95706. * Removes the given multi-material from this scene.
  95707. * @param toRemove The multi-material to remove
  95708. * @returns The index of the removed multi-material
  95709. */
  95710. removeMultiMaterial(toRemove: MultiMaterial): number;
  95711. /**
  95712. * Removes the given material from this scene.
  95713. * @param toRemove The material to remove
  95714. * @returns The index of the removed material
  95715. */
  95716. removeMaterial(toRemove: Material): number;
  95717. /**
  95718. * Removes the given action manager from this scene.
  95719. * @param toRemove The action manager to remove
  95720. * @returns The index of the removed action manager
  95721. */
  95722. removeActionManager(toRemove: AbstractActionManager): number;
  95723. /**
  95724. * Removes the given texture from this scene.
  95725. * @param toRemove The texture to remove
  95726. * @returns The index of the removed texture
  95727. */
  95728. removeTexture(toRemove: BaseTexture): number;
  95729. /**
  95730. * Adds the given light to this scene
  95731. * @param newLight The light to add
  95732. */
  95733. addLight(newLight: Light): void;
  95734. /**
  95735. * Sorts the list list based on light priorities
  95736. */
  95737. sortLightsByPriority(): void;
  95738. /**
  95739. * Adds the given camera to this scene
  95740. * @param newCamera The camera to add
  95741. */
  95742. addCamera(newCamera: Camera): void;
  95743. /**
  95744. * Adds the given skeleton to this scene
  95745. * @param newSkeleton The skeleton to add
  95746. */
  95747. addSkeleton(newSkeleton: Skeleton): void;
  95748. /**
  95749. * Adds the given particle system to this scene
  95750. * @param newParticleSystem The particle system to add
  95751. */
  95752. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95753. /**
  95754. * Adds the given animation to this scene
  95755. * @param newAnimation The animation to add
  95756. */
  95757. addAnimation(newAnimation: Animation): void;
  95758. /**
  95759. * Adds the given animation group to this scene.
  95760. * @param newAnimationGroup The animation group to add
  95761. */
  95762. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95763. /**
  95764. * Adds the given multi-material to this scene
  95765. * @param newMultiMaterial The multi-material to add
  95766. */
  95767. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95768. /**
  95769. * Adds the given material to this scene
  95770. * @param newMaterial The material to add
  95771. */
  95772. addMaterial(newMaterial: Material): void;
  95773. /**
  95774. * Adds the given morph target to this scene
  95775. * @param newMorphTargetManager The morph target to add
  95776. */
  95777. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95778. /**
  95779. * Adds the given geometry to this scene
  95780. * @param newGeometry The geometry to add
  95781. */
  95782. addGeometry(newGeometry: Geometry): void;
  95783. /**
  95784. * Adds the given action manager to this scene
  95785. * @param newActionManager The action manager to add
  95786. */
  95787. addActionManager(newActionManager: AbstractActionManager): void;
  95788. /**
  95789. * Adds the given texture to this scene.
  95790. * @param newTexture The texture to add
  95791. */
  95792. addTexture(newTexture: BaseTexture): void;
  95793. /**
  95794. * Switch active camera
  95795. * @param newCamera defines the new active camera
  95796. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  95797. */
  95798. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  95799. /**
  95800. * sets the active camera of the scene using its ID
  95801. * @param id defines the camera's ID
  95802. * @return the new active camera or null if none found.
  95803. */
  95804. setActiveCameraByID(id: string): Nullable<Camera>;
  95805. /**
  95806. * sets the active camera of the scene using its name
  95807. * @param name defines the camera's name
  95808. * @returns the new active camera or null if none found.
  95809. */
  95810. setActiveCameraByName(name: string): Nullable<Camera>;
  95811. /**
  95812. * get an animation group using its name
  95813. * @param name defines the material's name
  95814. * @return the animation group or null if none found.
  95815. */
  95816. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  95817. /**
  95818. * Get a material using its unique id
  95819. * @param uniqueId defines the material's unique id
  95820. * @return the material or null if none found.
  95821. */
  95822. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  95823. /**
  95824. * get a material using its id
  95825. * @param id defines the material's ID
  95826. * @return the material or null if none found.
  95827. */
  95828. getMaterialByID(id: string): Nullable<Material>;
  95829. /**
  95830. * Gets a material using its name
  95831. * @param name defines the material's name
  95832. * @return the material or null if none found.
  95833. */
  95834. getMaterialByName(name: string): Nullable<Material>;
  95835. /**
  95836. * Gets a camera using its id
  95837. * @param id defines the id to look for
  95838. * @returns the camera or null if not found
  95839. */
  95840. getCameraByID(id: string): Nullable<Camera>;
  95841. /**
  95842. * Gets a camera using its unique id
  95843. * @param uniqueId defines the unique id to look for
  95844. * @returns the camera or null if not found
  95845. */
  95846. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  95847. /**
  95848. * Gets a camera using its name
  95849. * @param name defines the camera's name
  95850. * @return the camera or null if none found.
  95851. */
  95852. getCameraByName(name: string): Nullable<Camera>;
  95853. /**
  95854. * Gets a bone using its id
  95855. * @param id defines the bone's id
  95856. * @return the bone or null if not found
  95857. */
  95858. getBoneByID(id: string): Nullable<Bone>;
  95859. /**
  95860. * Gets a bone using its id
  95861. * @param name defines the bone's name
  95862. * @return the bone or null if not found
  95863. */
  95864. getBoneByName(name: string): Nullable<Bone>;
  95865. /**
  95866. * Gets a light node using its name
  95867. * @param name defines the the light's name
  95868. * @return the light or null if none found.
  95869. */
  95870. getLightByName(name: string): Nullable<Light>;
  95871. /**
  95872. * Gets a light node using its id
  95873. * @param id defines the light's id
  95874. * @return the light or null if none found.
  95875. */
  95876. getLightByID(id: string): Nullable<Light>;
  95877. /**
  95878. * Gets a light node using its scene-generated unique ID
  95879. * @param uniqueId defines the light's unique id
  95880. * @return the light or null if none found.
  95881. */
  95882. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  95883. /**
  95884. * Gets a particle system by id
  95885. * @param id defines the particle system id
  95886. * @return the corresponding system or null if none found
  95887. */
  95888. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  95889. /**
  95890. * Gets a geometry using its ID
  95891. * @param id defines the geometry's id
  95892. * @return the geometry or null if none found.
  95893. */
  95894. getGeometryByID(id: string): Nullable<Geometry>;
  95895. private _getGeometryByUniqueID;
  95896. /**
  95897. * Add a new geometry to this scene
  95898. * @param geometry defines the geometry to be added to the scene.
  95899. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  95900. * @return a boolean defining if the geometry was added or not
  95901. */
  95902. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  95903. /**
  95904. * Removes an existing geometry
  95905. * @param geometry defines the geometry to be removed from the scene
  95906. * @return a boolean defining if the geometry was removed or not
  95907. */
  95908. removeGeometry(geometry: Geometry): boolean;
  95909. /**
  95910. * Gets the list of geometries attached to the scene
  95911. * @returns an array of Geometry
  95912. */
  95913. getGeometries(): Geometry[];
  95914. /**
  95915. * Gets the first added mesh found of a given ID
  95916. * @param id defines the id to search for
  95917. * @return the mesh found or null if not found at all
  95918. */
  95919. getMeshByID(id: string): Nullable<AbstractMesh>;
  95920. /**
  95921. * Gets a list of meshes using their id
  95922. * @param id defines the id to search for
  95923. * @returns a list of meshes
  95924. */
  95925. getMeshesByID(id: string): Array<AbstractMesh>;
  95926. /**
  95927. * Gets the first added transform node found of a given ID
  95928. * @param id defines the id to search for
  95929. * @return the found transform node or null if not found at all.
  95930. */
  95931. getTransformNodeByID(id: string): Nullable<TransformNode>;
  95932. /**
  95933. * Gets a transform node with its auto-generated unique id
  95934. * @param uniqueId efines the unique id to search for
  95935. * @return the found transform node or null if not found at all.
  95936. */
  95937. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  95938. /**
  95939. * Gets a list of transform nodes using their id
  95940. * @param id defines the id to search for
  95941. * @returns a list of transform nodes
  95942. */
  95943. getTransformNodesByID(id: string): Array<TransformNode>;
  95944. /**
  95945. * Gets a mesh with its auto-generated unique id
  95946. * @param uniqueId defines the unique id to search for
  95947. * @return the found mesh or null if not found at all.
  95948. */
  95949. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  95950. /**
  95951. * Gets a the last added mesh using a given id
  95952. * @param id defines the id to search for
  95953. * @return the found mesh or null if not found at all.
  95954. */
  95955. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  95956. /**
  95957. * Gets a the last added node (Mesh, Camera, Light) using a given id
  95958. * @param id defines the id to search for
  95959. * @return the found node or null if not found at all
  95960. */
  95961. getLastEntryByID(id: string): Nullable<Node>;
  95962. /**
  95963. * Gets a node (Mesh, Camera, Light) using a given id
  95964. * @param id defines the id to search for
  95965. * @return the found node or null if not found at all
  95966. */
  95967. getNodeByID(id: string): Nullable<Node>;
  95968. /**
  95969. * Gets a node (Mesh, Camera, Light) using a given name
  95970. * @param name defines the name to search for
  95971. * @return the found node or null if not found at all.
  95972. */
  95973. getNodeByName(name: string): Nullable<Node>;
  95974. /**
  95975. * Gets a mesh using a given name
  95976. * @param name defines the name to search for
  95977. * @return the found mesh or null if not found at all.
  95978. */
  95979. getMeshByName(name: string): Nullable<AbstractMesh>;
  95980. /**
  95981. * Gets a transform node using a given name
  95982. * @param name defines the name to search for
  95983. * @return the found transform node or null if not found at all.
  95984. */
  95985. getTransformNodeByName(name: string): Nullable<TransformNode>;
  95986. /**
  95987. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  95988. * @param id defines the id to search for
  95989. * @return the found skeleton or null if not found at all.
  95990. */
  95991. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  95992. /**
  95993. * Gets a skeleton using a given auto generated unique id
  95994. * @param uniqueId defines the unique id to search for
  95995. * @return the found skeleton or null if not found at all.
  95996. */
  95997. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  95998. /**
  95999. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96000. * @param id defines the id to search for
  96001. * @return the found skeleton or null if not found at all.
  96002. */
  96003. getSkeletonById(id: string): Nullable<Skeleton>;
  96004. /**
  96005. * Gets a skeleton using a given name
  96006. * @param name defines the name to search for
  96007. * @return the found skeleton or null if not found at all.
  96008. */
  96009. getSkeletonByName(name: string): Nullable<Skeleton>;
  96010. /**
  96011. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96012. * @param id defines the id to search for
  96013. * @return the found morph target manager or null if not found at all.
  96014. */
  96015. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96016. /**
  96017. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96018. * @param id defines the id to search for
  96019. * @return the found morph target or null if not found at all.
  96020. */
  96021. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96022. /**
  96023. * Gets a boolean indicating if the given mesh is active
  96024. * @param mesh defines the mesh to look for
  96025. * @returns true if the mesh is in the active list
  96026. */
  96027. isActiveMesh(mesh: AbstractMesh): boolean;
  96028. /**
  96029. * Return a unique id as a string which can serve as an identifier for the scene
  96030. */
  96031. readonly uid: string;
  96032. /**
  96033. * Add an externaly attached data from its key.
  96034. * This method call will fail and return false, if such key already exists.
  96035. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96036. * @param key the unique key that identifies the data
  96037. * @param data the data object to associate to the key for this Engine instance
  96038. * @return true if no such key were already present and the data was added successfully, false otherwise
  96039. */
  96040. addExternalData<T>(key: string, data: T): boolean;
  96041. /**
  96042. * Get an externaly attached data from its key
  96043. * @param key the unique key that identifies the data
  96044. * @return the associated data, if present (can be null), or undefined if not present
  96045. */
  96046. getExternalData<T>(key: string): Nullable<T>;
  96047. /**
  96048. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96049. * @param key the unique key that identifies the data
  96050. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96051. * @return the associated data, can be null if the factory returned null.
  96052. */
  96053. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96054. /**
  96055. * Remove an externaly attached data from the Engine instance
  96056. * @param key the unique key that identifies the data
  96057. * @return true if the data was successfully removed, false if it doesn't exist
  96058. */
  96059. removeExternalData(key: string): boolean;
  96060. private _evaluateSubMesh;
  96061. /**
  96062. * Clear the processed materials smart array preventing retention point in material dispose.
  96063. */
  96064. freeProcessedMaterials(): void;
  96065. private _preventFreeActiveMeshesAndRenderingGroups;
  96066. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96067. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96068. * when disposing several meshes in a row or a hierarchy of meshes.
  96069. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96070. */
  96071. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96072. /**
  96073. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96074. */
  96075. freeActiveMeshes(): void;
  96076. /**
  96077. * Clear the info related to rendering groups preventing retention points during dispose.
  96078. */
  96079. freeRenderingGroups(): void;
  96080. /** @hidden */
  96081. _isInIntermediateRendering(): boolean;
  96082. /**
  96083. * Lambda returning the list of potentially active meshes.
  96084. */
  96085. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96086. /**
  96087. * Lambda returning the list of potentially active sub meshes.
  96088. */
  96089. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96090. /**
  96091. * Lambda returning the list of potentially intersecting sub meshes.
  96092. */
  96093. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96094. /**
  96095. * Lambda returning the list of potentially colliding sub meshes.
  96096. */
  96097. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96098. private _activeMeshesFrozen;
  96099. /**
  96100. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96101. * @returns the current scene
  96102. */
  96103. freezeActiveMeshes(): Scene;
  96104. /**
  96105. * Use this function to restart evaluating active meshes on every frame
  96106. * @returns the current scene
  96107. */
  96108. unfreezeActiveMeshes(): Scene;
  96109. private _evaluateActiveMeshes;
  96110. private _activeMesh;
  96111. /**
  96112. * Update the transform matrix to update from the current active camera
  96113. * @param force defines a boolean used to force the update even if cache is up to date
  96114. */
  96115. updateTransformMatrix(force?: boolean): void;
  96116. private _bindFrameBuffer;
  96117. /** @hidden */
  96118. _allowPostProcessClearColor: boolean;
  96119. /** @hidden */
  96120. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96121. private _processSubCameras;
  96122. private _checkIntersections;
  96123. /** @hidden */
  96124. _advancePhysicsEngineStep(step: number): void;
  96125. /**
  96126. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96127. */
  96128. getDeterministicFrameTime: () => number;
  96129. /** @hidden */
  96130. _animate(): void;
  96131. /** Execute all animations (for a frame) */
  96132. animate(): void;
  96133. /**
  96134. * Render the scene
  96135. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96136. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96137. */
  96138. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96139. /**
  96140. * Freeze all materials
  96141. * A frozen material will not be updatable but should be faster to render
  96142. */
  96143. freezeMaterials(): void;
  96144. /**
  96145. * Unfreeze all materials
  96146. * A frozen material will not be updatable but should be faster to render
  96147. */
  96148. unfreezeMaterials(): void;
  96149. /**
  96150. * Releases all held ressources
  96151. */
  96152. dispose(): void;
  96153. /**
  96154. * Gets if the scene is already disposed
  96155. */
  96156. readonly isDisposed: boolean;
  96157. /**
  96158. * Call this function to reduce memory footprint of the scene.
  96159. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96160. */
  96161. clearCachedVertexData(): void;
  96162. /**
  96163. * This function will remove the local cached buffer data from texture.
  96164. * It will save memory but will prevent the texture from being rebuilt
  96165. */
  96166. cleanCachedTextureBuffer(): void;
  96167. /**
  96168. * Get the world extend vectors with an optional filter
  96169. *
  96170. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96171. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96172. */
  96173. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96174. min: Vector3;
  96175. max: Vector3;
  96176. };
  96177. /**
  96178. * Creates a ray that can be used to pick in the scene
  96179. * @param x defines the x coordinate of the origin (on-screen)
  96180. * @param y defines the y coordinate of the origin (on-screen)
  96181. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96182. * @param camera defines the camera to use for the picking
  96183. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96184. * @returns a Ray
  96185. */
  96186. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96187. /**
  96188. * Creates a ray that can be used to pick in the scene
  96189. * @param x defines the x coordinate of the origin (on-screen)
  96190. * @param y defines the y coordinate of the origin (on-screen)
  96191. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96192. * @param result defines the ray where to store the picking ray
  96193. * @param camera defines the camera to use for the picking
  96194. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96195. * @returns the current scene
  96196. */
  96197. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96198. /**
  96199. * Creates a ray that can be used to pick in the scene
  96200. * @param x defines the x coordinate of the origin (on-screen)
  96201. * @param y defines the y coordinate of the origin (on-screen)
  96202. * @param camera defines the camera to use for the picking
  96203. * @returns a Ray
  96204. */
  96205. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96206. /**
  96207. * Creates a ray that can be used to pick in the scene
  96208. * @param x defines the x coordinate of the origin (on-screen)
  96209. * @param y defines the y coordinate of the origin (on-screen)
  96210. * @param result defines the ray where to store the picking ray
  96211. * @param camera defines the camera to use for the picking
  96212. * @returns the current scene
  96213. */
  96214. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96215. /** Launch a ray to try to pick a mesh in the scene
  96216. * @param x position on screen
  96217. * @param y position on screen
  96218. * @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
  96219. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96220. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96221. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96222. * @returns a PickingInfo
  96223. */
  96224. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  96225. /** Use the given ray to pick a mesh in the scene
  96226. * @param ray The ray to use to pick meshes
  96227. * @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
  96228. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96229. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96230. * @returns a PickingInfo
  96231. */
  96232. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96233. /**
  96234. * Launch a ray to try to pick a mesh in the scene
  96235. * @param x X position on screen
  96236. * @param y Y position on screen
  96237. * @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
  96238. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96240. * @returns an array of PickingInfo
  96241. */
  96242. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96243. /**
  96244. * Launch a ray to try to pick a mesh in the scene
  96245. * @param ray Ray to use
  96246. * @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
  96247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96248. * @returns an array of PickingInfo
  96249. */
  96250. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96251. /**
  96252. * Force the value of meshUnderPointer
  96253. * @param mesh defines the mesh to use
  96254. */
  96255. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96256. /**
  96257. * Gets the mesh under the pointer
  96258. * @returns a Mesh or null if no mesh is under the pointer
  96259. */
  96260. getPointerOverMesh(): Nullable<AbstractMesh>;
  96261. /** @hidden */
  96262. _rebuildGeometries(): void;
  96263. /** @hidden */
  96264. _rebuildTextures(): void;
  96265. private _getByTags;
  96266. /**
  96267. * Get a list of meshes by tags
  96268. * @param tagsQuery defines the tags query to use
  96269. * @param forEach defines a predicate used to filter results
  96270. * @returns an array of Mesh
  96271. */
  96272. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96273. /**
  96274. * Get a list of cameras by tags
  96275. * @param tagsQuery defines the tags query to use
  96276. * @param forEach defines a predicate used to filter results
  96277. * @returns an array of Camera
  96278. */
  96279. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96280. /**
  96281. * Get a list of lights by tags
  96282. * @param tagsQuery defines the tags query to use
  96283. * @param forEach defines a predicate used to filter results
  96284. * @returns an array of Light
  96285. */
  96286. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96287. /**
  96288. * Get a list of materials by tags
  96289. * @param tagsQuery defines the tags query to use
  96290. * @param forEach defines a predicate used to filter results
  96291. * @returns an array of Material
  96292. */
  96293. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96294. /**
  96295. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96296. * This allowed control for front to back rendering or reversly depending of the special needs.
  96297. *
  96298. * @param renderingGroupId The rendering group id corresponding to its index
  96299. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96300. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96301. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96302. */
  96303. 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;
  96304. /**
  96305. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96306. *
  96307. * @param renderingGroupId The rendering group id corresponding to its index
  96308. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96309. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96310. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96311. */
  96312. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96313. /**
  96314. * Gets the current auto clear configuration for one rendering group of the rendering
  96315. * manager.
  96316. * @param index the rendering group index to get the information for
  96317. * @returns The auto clear setup for the requested rendering group
  96318. */
  96319. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96320. private _blockMaterialDirtyMechanism;
  96321. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96322. blockMaterialDirtyMechanism: boolean;
  96323. /**
  96324. * Will flag all materials as dirty to trigger new shader compilation
  96325. * @param flag defines the flag used to specify which material part must be marked as dirty
  96326. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96327. */
  96328. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96329. /** @hidden */
  96330. _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;
  96331. /** @hidden */
  96332. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96333. }
  96334. }
  96335. declare module BABYLON {
  96336. /**
  96337. * Set of assets to keep when moving a scene into an asset container.
  96338. */
  96339. export class KeepAssets extends AbstractScene {
  96340. }
  96341. /**
  96342. * Container with a set of assets that can be added or removed from a scene.
  96343. */
  96344. export class AssetContainer extends AbstractScene {
  96345. /**
  96346. * The scene the AssetContainer belongs to.
  96347. */
  96348. scene: Scene;
  96349. /**
  96350. * Instantiates an AssetContainer.
  96351. * @param scene The scene the AssetContainer belongs to.
  96352. */
  96353. constructor(scene: Scene);
  96354. /**
  96355. * Adds all the assets from the container to the scene.
  96356. */
  96357. addAllToScene(): void;
  96358. /**
  96359. * Removes all the assets in the container from the scene
  96360. */
  96361. removeAllFromScene(): void;
  96362. /**
  96363. * Disposes all the assets in the container
  96364. */
  96365. dispose(): void;
  96366. private _moveAssets;
  96367. /**
  96368. * Removes all the assets contained in the scene and adds them to the container.
  96369. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96370. */
  96371. moveAllFromScene(keepAssets?: KeepAssets): void;
  96372. /**
  96373. * 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.
  96374. * @returns the root mesh
  96375. */
  96376. createRootMesh(): Mesh;
  96377. }
  96378. }
  96379. declare module BABYLON {
  96380. /**
  96381. * Defines how the parser contract is defined.
  96382. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96383. */
  96384. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96385. /**
  96386. * Defines how the individual parser contract is defined.
  96387. * These parser can parse an individual asset
  96388. */
  96389. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96390. /**
  96391. * Base class of the scene acting as a container for the different elements composing a scene.
  96392. * This class is dynamically extended by the different components of the scene increasing
  96393. * flexibility and reducing coupling
  96394. */
  96395. export abstract class AbstractScene {
  96396. /**
  96397. * Stores the list of available parsers in the application.
  96398. */
  96399. private static _BabylonFileParsers;
  96400. /**
  96401. * Stores the list of available individual parsers in the application.
  96402. */
  96403. private static _IndividualBabylonFileParsers;
  96404. /**
  96405. * Adds a parser in the list of available ones
  96406. * @param name Defines the name of the parser
  96407. * @param parser Defines the parser to add
  96408. */
  96409. static AddParser(name: string, parser: BabylonFileParser): void;
  96410. /**
  96411. * Gets a general parser from the list of avaialble ones
  96412. * @param name Defines the name of the parser
  96413. * @returns the requested parser or null
  96414. */
  96415. static GetParser(name: string): Nullable<BabylonFileParser>;
  96416. /**
  96417. * Adds n individual parser in the list of available ones
  96418. * @param name Defines the name of the parser
  96419. * @param parser Defines the parser to add
  96420. */
  96421. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96422. /**
  96423. * Gets an individual parser from the list of avaialble ones
  96424. * @param name Defines the name of the parser
  96425. * @returns the requested parser or null
  96426. */
  96427. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96428. /**
  96429. * Parser json data and populate both a scene and its associated container object
  96430. * @param jsonData Defines the data to parse
  96431. * @param scene Defines the scene to parse the data for
  96432. * @param container Defines the container attached to the parsing sequence
  96433. * @param rootUrl Defines the root url of the data
  96434. */
  96435. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96436. /**
  96437. * Gets the list of root nodes (ie. nodes with no parent)
  96438. */
  96439. rootNodes: Node[];
  96440. /** All of the cameras added to this scene
  96441. * @see http://doc.babylonjs.com/babylon101/cameras
  96442. */
  96443. cameras: Camera[];
  96444. /**
  96445. * All of the lights added to this scene
  96446. * @see http://doc.babylonjs.com/babylon101/lights
  96447. */
  96448. lights: Light[];
  96449. /**
  96450. * All of the (abstract) meshes added to this scene
  96451. */
  96452. meshes: AbstractMesh[];
  96453. /**
  96454. * The list of skeletons added to the scene
  96455. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96456. */
  96457. skeletons: Skeleton[];
  96458. /**
  96459. * All of the particle systems added to this scene
  96460. * @see http://doc.babylonjs.com/babylon101/particles
  96461. */
  96462. particleSystems: IParticleSystem[];
  96463. /**
  96464. * Gets a list of Animations associated with the scene
  96465. */
  96466. animations: Animation[];
  96467. /**
  96468. * All of the animation groups added to this scene
  96469. * @see http://doc.babylonjs.com/how_to/group
  96470. */
  96471. animationGroups: AnimationGroup[];
  96472. /**
  96473. * All of the multi-materials added to this scene
  96474. * @see http://doc.babylonjs.com/how_to/multi_materials
  96475. */
  96476. multiMaterials: MultiMaterial[];
  96477. /**
  96478. * All of the materials added to this scene
  96479. * In the context of a Scene, it is not supposed to be modified manually.
  96480. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96481. * Note also that the order of the Material wihin the array is not significant and might change.
  96482. * @see http://doc.babylonjs.com/babylon101/materials
  96483. */
  96484. materials: Material[];
  96485. /**
  96486. * The list of morph target managers added to the scene
  96487. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96488. */
  96489. morphTargetManagers: MorphTargetManager[];
  96490. /**
  96491. * The list of geometries used in the scene.
  96492. */
  96493. geometries: Geometry[];
  96494. /**
  96495. * All of the tranform nodes added to this scene
  96496. * In the context of a Scene, it is not supposed to be modified manually.
  96497. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96498. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96499. * @see http://doc.babylonjs.com/how_to/transformnode
  96500. */
  96501. transformNodes: TransformNode[];
  96502. /**
  96503. * ActionManagers available on the scene.
  96504. */
  96505. actionManagers: AbstractActionManager[];
  96506. /**
  96507. * Textures to keep.
  96508. */
  96509. textures: BaseTexture[];
  96510. /**
  96511. * Environment texture for the scene
  96512. */
  96513. environmentTexture: Nullable<BaseTexture>;
  96514. }
  96515. }
  96516. declare module BABYLON {
  96517. /**
  96518. * Defines a sound that can be played in the application.
  96519. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96521. */
  96522. export class Sound {
  96523. /**
  96524. * The name of the sound in the scene.
  96525. */
  96526. name: string;
  96527. /**
  96528. * Does the sound autoplay once loaded.
  96529. */
  96530. autoplay: boolean;
  96531. /**
  96532. * Does the sound loop after it finishes playing once.
  96533. */
  96534. loop: boolean;
  96535. /**
  96536. * Does the sound use a custom attenuation curve to simulate the falloff
  96537. * happening when the source gets further away from the camera.
  96538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96539. */
  96540. useCustomAttenuation: boolean;
  96541. /**
  96542. * The sound track id this sound belongs to.
  96543. */
  96544. soundTrackId: number;
  96545. /**
  96546. * Is this sound currently played.
  96547. */
  96548. isPlaying: boolean;
  96549. /**
  96550. * Is this sound currently paused.
  96551. */
  96552. isPaused: boolean;
  96553. /**
  96554. * Does this sound enables spatial sound.
  96555. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96556. */
  96557. spatialSound: boolean;
  96558. /**
  96559. * Define the reference distance the sound should be heard perfectly.
  96560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96561. */
  96562. refDistance: number;
  96563. /**
  96564. * Define the roll off factor of spatial sounds.
  96565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96566. */
  96567. rolloffFactor: number;
  96568. /**
  96569. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96571. */
  96572. maxDistance: number;
  96573. /**
  96574. * Define the distance attenuation model the sound will follow.
  96575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96576. */
  96577. distanceModel: string;
  96578. /**
  96579. * @hidden
  96580. * Back Compat
  96581. **/
  96582. onended: () => any;
  96583. /**
  96584. * Observable event when the current playing sound finishes.
  96585. */
  96586. onEndedObservable: Observable<Sound>;
  96587. private _panningModel;
  96588. private _playbackRate;
  96589. private _streaming;
  96590. private _startTime;
  96591. private _startOffset;
  96592. private _position;
  96593. /** @hidden */
  96594. _positionInEmitterSpace: boolean;
  96595. private _localDirection;
  96596. private _volume;
  96597. private _isReadyToPlay;
  96598. private _isDirectional;
  96599. private _readyToPlayCallback;
  96600. private _audioBuffer;
  96601. private _soundSource;
  96602. private _streamingSource;
  96603. private _soundPanner;
  96604. private _soundGain;
  96605. private _inputAudioNode;
  96606. private _outputAudioNode;
  96607. private _coneInnerAngle;
  96608. private _coneOuterAngle;
  96609. private _coneOuterGain;
  96610. private _scene;
  96611. private _connectedTransformNode;
  96612. private _customAttenuationFunction;
  96613. private _registerFunc;
  96614. private _isOutputConnected;
  96615. private _htmlAudioElement;
  96616. private _urlType;
  96617. /** @hidden */
  96618. static _SceneComponentInitialization: (scene: Scene) => void;
  96619. /**
  96620. * Create a sound and attach it to a scene
  96621. * @param name Name of your sound
  96622. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96623. * @param scene defines the scene the sound belongs to
  96624. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96625. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96626. */
  96627. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96628. /**
  96629. * Release the sound and its associated resources
  96630. */
  96631. dispose(): void;
  96632. /**
  96633. * Gets if the sounds is ready to be played or not.
  96634. * @returns true if ready, otherwise false
  96635. */
  96636. isReady(): boolean;
  96637. private _soundLoaded;
  96638. /**
  96639. * Sets the data of the sound from an audiobuffer
  96640. * @param audioBuffer The audioBuffer containing the data
  96641. */
  96642. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96643. /**
  96644. * Updates the current sounds options such as maxdistance, loop...
  96645. * @param options A JSON object containing values named as the object properties
  96646. */
  96647. updateOptions(options: any): void;
  96648. private _createSpatialParameters;
  96649. private _updateSpatialParameters;
  96650. /**
  96651. * Switch the panning model to HRTF:
  96652. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96653. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96654. */
  96655. switchPanningModelToHRTF(): void;
  96656. /**
  96657. * Switch the panning model to Equal Power:
  96658. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96660. */
  96661. switchPanningModelToEqualPower(): void;
  96662. private _switchPanningModel;
  96663. /**
  96664. * Connect this sound to a sound track audio node like gain...
  96665. * @param soundTrackAudioNode the sound track audio node to connect to
  96666. */
  96667. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96668. /**
  96669. * Transform this sound into a directional source
  96670. * @param coneInnerAngle Size of the inner cone in degree
  96671. * @param coneOuterAngle Size of the outer cone in degree
  96672. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96673. */
  96674. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96675. /**
  96676. * Gets or sets the inner angle for the directional cone.
  96677. */
  96678. /**
  96679. * Gets or sets the inner angle for the directional cone.
  96680. */
  96681. directionalConeInnerAngle: number;
  96682. /**
  96683. * Gets or sets the outer angle for the directional cone.
  96684. */
  96685. /**
  96686. * Gets or sets the outer angle for the directional cone.
  96687. */
  96688. directionalConeOuterAngle: number;
  96689. /**
  96690. * Sets the position of the emitter if spatial sound is enabled
  96691. * @param newPosition Defines the new posisiton
  96692. */
  96693. setPosition(newPosition: Vector3): void;
  96694. /**
  96695. * Sets the local direction of the emitter if spatial sound is enabled
  96696. * @param newLocalDirection Defines the new local direction
  96697. */
  96698. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96699. private _updateDirection;
  96700. /** @hidden */
  96701. updateDistanceFromListener(): void;
  96702. /**
  96703. * Sets a new custom attenuation function for the sound.
  96704. * @param callback Defines the function used for the attenuation
  96705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96706. */
  96707. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96708. /**
  96709. * Play the sound
  96710. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96711. * @param offset (optional) Start the sound setting it at a specific time
  96712. */
  96713. play(time?: number, offset?: number): void;
  96714. private _onended;
  96715. /**
  96716. * Stop the sound
  96717. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96718. */
  96719. stop(time?: number): void;
  96720. /**
  96721. * Put the sound in pause
  96722. */
  96723. pause(): void;
  96724. /**
  96725. * Sets a dedicated volume for this sounds
  96726. * @param newVolume Define the new volume of the sound
  96727. * @param time Define in how long the sound should be at this value
  96728. */
  96729. setVolume(newVolume: number, time?: number): void;
  96730. /**
  96731. * Set the sound play back rate
  96732. * @param newPlaybackRate Define the playback rate the sound should be played at
  96733. */
  96734. setPlaybackRate(newPlaybackRate: number): void;
  96735. /**
  96736. * Gets the volume of the sound.
  96737. * @returns the volume of the sound
  96738. */
  96739. getVolume(): number;
  96740. /**
  96741. * Attach the sound to a dedicated mesh
  96742. * @param transformNode The transform node to connect the sound with
  96743. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96744. */
  96745. attachToMesh(transformNode: TransformNode): void;
  96746. /**
  96747. * Detach the sound from the previously attached mesh
  96748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96749. */
  96750. detachFromMesh(): void;
  96751. private _onRegisterAfterWorldMatrixUpdate;
  96752. /**
  96753. * Clone the current sound in the scene.
  96754. * @returns the new sound clone
  96755. */
  96756. clone(): Nullable<Sound>;
  96757. /**
  96758. * Gets the current underlying audio buffer containing the data
  96759. * @returns the audio buffer
  96760. */
  96761. getAudioBuffer(): Nullable<AudioBuffer>;
  96762. /**
  96763. * Serializes the Sound in a JSON representation
  96764. * @returns the JSON representation of the sound
  96765. */
  96766. serialize(): any;
  96767. /**
  96768. * Parse a JSON representation of a sound to innstantiate in a given scene
  96769. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96770. * @param scene Define the scene the new parsed sound should be created in
  96771. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96772. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96773. * @returns the newly parsed sound
  96774. */
  96775. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96776. }
  96777. }
  96778. declare module BABYLON {
  96779. /**
  96780. * This defines an action helpful to play a defined sound on a triggered action.
  96781. */
  96782. export class PlaySoundAction extends Action {
  96783. private _sound;
  96784. /**
  96785. * Instantiate the action
  96786. * @param triggerOptions defines the trigger options
  96787. * @param sound defines the sound to play
  96788. * @param condition defines the trigger related conditions
  96789. */
  96790. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96791. /** @hidden */
  96792. _prepare(): void;
  96793. /**
  96794. * Execute the action and play the sound.
  96795. */
  96796. execute(): void;
  96797. /**
  96798. * Serializes the actions and its related information.
  96799. * @param parent defines the object to serialize in
  96800. * @returns the serialized object
  96801. */
  96802. serialize(parent: any): any;
  96803. }
  96804. /**
  96805. * This defines an action helpful to stop a defined sound on a triggered action.
  96806. */
  96807. export class StopSoundAction extends Action {
  96808. private _sound;
  96809. /**
  96810. * Instantiate the action
  96811. * @param triggerOptions defines the trigger options
  96812. * @param sound defines the sound to stop
  96813. * @param condition defines the trigger related conditions
  96814. */
  96815. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96816. /** @hidden */
  96817. _prepare(): void;
  96818. /**
  96819. * Execute the action and stop the sound.
  96820. */
  96821. execute(): void;
  96822. /**
  96823. * Serializes the actions and its related information.
  96824. * @param parent defines the object to serialize in
  96825. * @returns the serialized object
  96826. */
  96827. serialize(parent: any): any;
  96828. }
  96829. }
  96830. declare module BABYLON {
  96831. /**
  96832. * This defines an action responsible to change the value of a property
  96833. * by interpolating between its current value and the newly set one once triggered.
  96834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96835. */
  96836. export class InterpolateValueAction extends Action {
  96837. /**
  96838. * Defines the path of the property where the value should be interpolated
  96839. */
  96840. propertyPath: string;
  96841. /**
  96842. * Defines the target value at the end of the interpolation.
  96843. */
  96844. value: any;
  96845. /**
  96846. * Defines the time it will take for the property to interpolate to the value.
  96847. */
  96848. duration: number;
  96849. /**
  96850. * Defines if the other scene animations should be stopped when the action has been triggered
  96851. */
  96852. stopOtherAnimations?: boolean;
  96853. /**
  96854. * Defines a callback raised once the interpolation animation has been done.
  96855. */
  96856. onInterpolationDone?: () => void;
  96857. /**
  96858. * Observable triggered once the interpolation animation has been done.
  96859. */
  96860. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  96861. private _target;
  96862. private _effectiveTarget;
  96863. private _property;
  96864. /**
  96865. * Instantiate the action
  96866. * @param triggerOptions defines the trigger options
  96867. * @param target defines the object containing the value to interpolate
  96868. * @param propertyPath defines the path to the property in the target object
  96869. * @param value defines the target value at the end of the interpolation
  96870. * @param duration deines the time it will take for the property to interpolate to the value.
  96871. * @param condition defines the trigger related conditions
  96872. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  96873. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  96874. */
  96875. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  96876. /** @hidden */
  96877. _prepare(): void;
  96878. /**
  96879. * Execute the action starts the value interpolation.
  96880. */
  96881. execute(): void;
  96882. /**
  96883. * Serializes the actions and its related information.
  96884. * @param parent defines the object to serialize in
  96885. * @returns the serialized object
  96886. */
  96887. serialize(parent: any): any;
  96888. }
  96889. }
  96890. declare module BABYLON {
  96891. /**
  96892. * Options allowed during the creation of a sound track.
  96893. */
  96894. export interface ISoundTrackOptions {
  96895. /**
  96896. * The volume the sound track should take during creation
  96897. */
  96898. volume?: number;
  96899. /**
  96900. * Define if the sound track is the main sound track of the scene
  96901. */
  96902. mainTrack?: boolean;
  96903. }
  96904. /**
  96905. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  96906. * It will be also used in a future release to apply effects on a specific track.
  96907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96908. */
  96909. export class SoundTrack {
  96910. /**
  96911. * The unique identifier of the sound track in the scene.
  96912. */
  96913. id: number;
  96914. /**
  96915. * The list of sounds included in the sound track.
  96916. */
  96917. soundCollection: Array<Sound>;
  96918. private _outputAudioNode;
  96919. private _scene;
  96920. private _isMainTrack;
  96921. private _connectedAnalyser;
  96922. private _options;
  96923. private _isInitialized;
  96924. /**
  96925. * Creates a new sound track.
  96926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96927. * @param scene Define the scene the sound track belongs to
  96928. * @param options
  96929. */
  96930. constructor(scene: Scene, options?: ISoundTrackOptions);
  96931. private _initializeSoundTrackAudioGraph;
  96932. /**
  96933. * Release the sound track and its associated resources
  96934. */
  96935. dispose(): void;
  96936. /**
  96937. * Adds a sound to this sound track
  96938. * @param sound define the cound to add
  96939. * @ignoreNaming
  96940. */
  96941. AddSound(sound: Sound): void;
  96942. /**
  96943. * Removes a sound to this sound track
  96944. * @param sound define the cound to remove
  96945. * @ignoreNaming
  96946. */
  96947. RemoveSound(sound: Sound): void;
  96948. /**
  96949. * Set a global volume for the full sound track.
  96950. * @param newVolume Define the new volume of the sound track
  96951. */
  96952. setVolume(newVolume: number): void;
  96953. /**
  96954. * Switch the panning model to HRTF:
  96955. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96957. */
  96958. switchPanningModelToHRTF(): void;
  96959. /**
  96960. * Switch the panning model to Equal Power:
  96961. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96963. */
  96964. switchPanningModelToEqualPower(): void;
  96965. /**
  96966. * Connect the sound track to an audio analyser allowing some amazing
  96967. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  96968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  96969. * @param analyser The analyser to connect to the engine
  96970. */
  96971. connectToAnalyser(analyser: Analyser): void;
  96972. }
  96973. }
  96974. declare module BABYLON {
  96975. interface AbstractScene {
  96976. /**
  96977. * The list of sounds used in the scene.
  96978. */
  96979. sounds: Nullable<Array<Sound>>;
  96980. }
  96981. interface Scene {
  96982. /**
  96983. * @hidden
  96984. * Backing field
  96985. */
  96986. _mainSoundTrack: SoundTrack;
  96987. /**
  96988. * The main sound track played by the scene.
  96989. * It cotains your primary collection of sounds.
  96990. */
  96991. mainSoundTrack: SoundTrack;
  96992. /**
  96993. * The list of sound tracks added to the scene
  96994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96995. */
  96996. soundTracks: Nullable<Array<SoundTrack>>;
  96997. /**
  96998. * Gets a sound using a given name
  96999. * @param name defines the name to search for
  97000. * @return the found sound or null if not found at all.
  97001. */
  97002. getSoundByName(name: string): Nullable<Sound>;
  97003. /**
  97004. * Gets or sets if audio support is enabled
  97005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97006. */
  97007. audioEnabled: boolean;
  97008. /**
  97009. * Gets or sets if audio will be output to headphones
  97010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97011. */
  97012. headphone: boolean;
  97013. }
  97014. /**
  97015. * Defines the sound scene component responsible to manage any sounds
  97016. * in a given scene.
  97017. */
  97018. export class AudioSceneComponent implements ISceneSerializableComponent {
  97019. /**
  97020. * The component name helpfull to identify the component in the list of scene components.
  97021. */
  97022. readonly name: string;
  97023. /**
  97024. * The scene the component belongs to.
  97025. */
  97026. scene: Scene;
  97027. private _audioEnabled;
  97028. /**
  97029. * Gets whether audio is enabled or not.
  97030. * Please use related enable/disable method to switch state.
  97031. */
  97032. readonly audioEnabled: boolean;
  97033. private _headphone;
  97034. /**
  97035. * Gets whether audio is outputing to headphone or not.
  97036. * Please use the according Switch methods to change output.
  97037. */
  97038. readonly headphone: boolean;
  97039. /**
  97040. * Creates a new instance of the component for the given scene
  97041. * @param scene Defines the scene to register the component in
  97042. */
  97043. constructor(scene: Scene);
  97044. /**
  97045. * Registers the component in a given scene
  97046. */
  97047. register(): void;
  97048. /**
  97049. * Rebuilds the elements related to this component in case of
  97050. * context lost for instance.
  97051. */
  97052. rebuild(): void;
  97053. /**
  97054. * Serializes the component data to the specified json object
  97055. * @param serializationObject The object to serialize to
  97056. */
  97057. serialize(serializationObject: any): void;
  97058. /**
  97059. * Adds all the elements from the container to the scene
  97060. * @param container the container holding the elements
  97061. */
  97062. addFromContainer(container: AbstractScene): void;
  97063. /**
  97064. * Removes all the elements in the container from the scene
  97065. * @param container contains the elements to remove
  97066. * @param dispose if the removed element should be disposed (default: false)
  97067. */
  97068. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97069. /**
  97070. * Disposes the component and the associated ressources.
  97071. */
  97072. dispose(): void;
  97073. /**
  97074. * Disables audio in the associated scene.
  97075. */
  97076. disableAudio(): void;
  97077. /**
  97078. * Enables audio in the associated scene.
  97079. */
  97080. enableAudio(): void;
  97081. /**
  97082. * Switch audio to headphone output.
  97083. */
  97084. switchAudioModeForHeadphones(): void;
  97085. /**
  97086. * Switch audio to normal speakers.
  97087. */
  97088. switchAudioModeForNormalSpeakers(): void;
  97089. private _afterRender;
  97090. }
  97091. }
  97092. declare module BABYLON {
  97093. /**
  97094. * Wraps one or more Sound objects and selects one with random weight for playback.
  97095. */
  97096. export class WeightedSound {
  97097. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97098. loop: boolean;
  97099. private _coneInnerAngle;
  97100. private _coneOuterAngle;
  97101. private _volume;
  97102. /** A Sound is currently playing. */
  97103. isPlaying: boolean;
  97104. /** A Sound is currently paused. */
  97105. isPaused: boolean;
  97106. private _sounds;
  97107. private _weights;
  97108. private _currentIndex?;
  97109. /**
  97110. * Creates a new WeightedSound from the list of sounds given.
  97111. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97112. * @param sounds Array of Sounds that will be selected from.
  97113. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97114. */
  97115. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97116. /**
  97117. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97118. */
  97119. /**
  97120. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97121. */
  97122. directionalConeInnerAngle: number;
  97123. /**
  97124. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97125. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97126. */
  97127. /**
  97128. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97129. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97130. */
  97131. directionalConeOuterAngle: number;
  97132. /**
  97133. * Playback volume.
  97134. */
  97135. /**
  97136. * Playback volume.
  97137. */
  97138. volume: number;
  97139. private _onended;
  97140. /**
  97141. * Suspend playback
  97142. */
  97143. pause(): void;
  97144. /**
  97145. * Stop playback
  97146. */
  97147. stop(): void;
  97148. /**
  97149. * Start playback.
  97150. * @param startOffset Position the clip head at a specific time in seconds.
  97151. */
  97152. play(startOffset?: number): void;
  97153. }
  97154. }
  97155. declare module BABYLON {
  97156. /**
  97157. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97159. */
  97160. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97161. /**
  97162. * Gets the name of the behavior.
  97163. */
  97164. readonly name: string;
  97165. /**
  97166. * The easing function used by animations
  97167. */
  97168. static EasingFunction: BackEase;
  97169. /**
  97170. * The easing mode used by animations
  97171. */
  97172. static EasingMode: number;
  97173. /**
  97174. * The duration of the animation, in milliseconds
  97175. */
  97176. transitionDuration: number;
  97177. /**
  97178. * Length of the distance animated by the transition when lower radius is reached
  97179. */
  97180. lowerRadiusTransitionRange: number;
  97181. /**
  97182. * Length of the distance animated by the transition when upper radius is reached
  97183. */
  97184. upperRadiusTransitionRange: number;
  97185. private _autoTransitionRange;
  97186. /**
  97187. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97188. */
  97189. /**
  97190. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97191. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97192. */
  97193. autoTransitionRange: boolean;
  97194. private _attachedCamera;
  97195. private _onAfterCheckInputsObserver;
  97196. private _onMeshTargetChangedObserver;
  97197. /**
  97198. * Initializes the behavior.
  97199. */
  97200. init(): void;
  97201. /**
  97202. * Attaches the behavior to its arc rotate camera.
  97203. * @param camera Defines the camera to attach the behavior to
  97204. */
  97205. attach(camera: ArcRotateCamera): void;
  97206. /**
  97207. * Detaches the behavior from its current arc rotate camera.
  97208. */
  97209. detach(): void;
  97210. private _radiusIsAnimating;
  97211. private _radiusBounceTransition;
  97212. private _animatables;
  97213. private _cachedWheelPrecision;
  97214. /**
  97215. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97216. * @param radiusLimit The limit to check against.
  97217. * @return Bool to indicate if at limit.
  97218. */
  97219. private _isRadiusAtLimit;
  97220. /**
  97221. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97222. * @param radiusDelta The delta by which to animate to. Can be negative.
  97223. */
  97224. private _applyBoundRadiusAnimation;
  97225. /**
  97226. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97227. */
  97228. protected _clearAnimationLocks(): void;
  97229. /**
  97230. * Stops and removes all animations that have been applied to the camera
  97231. */
  97232. stopAllAnimations(): void;
  97233. }
  97234. }
  97235. declare module BABYLON {
  97236. /**
  97237. * 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.
  97238. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97239. */
  97240. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97241. /**
  97242. * Gets the name of the behavior.
  97243. */
  97244. readonly name: string;
  97245. private _mode;
  97246. private _radiusScale;
  97247. private _positionScale;
  97248. private _defaultElevation;
  97249. private _elevationReturnTime;
  97250. private _elevationReturnWaitTime;
  97251. private _zoomStopsAnimation;
  97252. private _framingTime;
  97253. /**
  97254. * The easing function used by animations
  97255. */
  97256. static EasingFunction: ExponentialEase;
  97257. /**
  97258. * The easing mode used by animations
  97259. */
  97260. static EasingMode: number;
  97261. /**
  97262. * Sets the current mode used by the behavior
  97263. */
  97264. /**
  97265. * Gets current mode used by the behavior.
  97266. */
  97267. mode: number;
  97268. /**
  97269. * Sets the scale applied to the radius (1 by default)
  97270. */
  97271. /**
  97272. * Gets the scale applied to the radius
  97273. */
  97274. radiusScale: number;
  97275. /**
  97276. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97277. */
  97278. /**
  97279. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97280. */
  97281. positionScale: number;
  97282. /**
  97283. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97284. * behaviour is triggered, in radians.
  97285. */
  97286. /**
  97287. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97288. * behaviour is triggered, in radians.
  97289. */
  97290. defaultElevation: number;
  97291. /**
  97292. * Sets the time (in milliseconds) taken to return to the default beta position.
  97293. * Negative value indicates camera should not return to default.
  97294. */
  97295. /**
  97296. * Gets the time (in milliseconds) taken to return to the default beta position.
  97297. * Negative value indicates camera should not return to default.
  97298. */
  97299. elevationReturnTime: number;
  97300. /**
  97301. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97302. */
  97303. /**
  97304. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97305. */
  97306. elevationReturnWaitTime: number;
  97307. /**
  97308. * Sets the flag that indicates if user zooming should stop animation.
  97309. */
  97310. /**
  97311. * Gets the flag that indicates if user zooming should stop animation.
  97312. */
  97313. zoomStopsAnimation: boolean;
  97314. /**
  97315. * Sets the transition time when framing the mesh, in milliseconds
  97316. */
  97317. /**
  97318. * Gets the transition time when framing the mesh, in milliseconds
  97319. */
  97320. framingTime: number;
  97321. /**
  97322. * Define if the behavior should automatically change the configured
  97323. * camera limits and sensibilities.
  97324. */
  97325. autoCorrectCameraLimitsAndSensibility: boolean;
  97326. private _onPrePointerObservableObserver;
  97327. private _onAfterCheckInputsObserver;
  97328. private _onMeshTargetChangedObserver;
  97329. private _attachedCamera;
  97330. private _isPointerDown;
  97331. private _lastInteractionTime;
  97332. /**
  97333. * Initializes the behavior.
  97334. */
  97335. init(): void;
  97336. /**
  97337. * Attaches the behavior to its arc rotate camera.
  97338. * @param camera Defines the camera to attach the behavior to
  97339. */
  97340. attach(camera: ArcRotateCamera): void;
  97341. /**
  97342. * Detaches the behavior from its current arc rotate camera.
  97343. */
  97344. detach(): void;
  97345. private _animatables;
  97346. private _betaIsAnimating;
  97347. private _betaTransition;
  97348. private _radiusTransition;
  97349. private _vectorTransition;
  97350. /**
  97351. * Targets the given mesh and updates zoom level accordingly.
  97352. * @param mesh The mesh to target.
  97353. * @param radius Optional. If a cached radius position already exists, overrides default.
  97354. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97355. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97356. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97357. */
  97358. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97359. /**
  97360. * Targets the given mesh with its children and updates zoom level accordingly.
  97361. * @param mesh The mesh to target.
  97362. * @param radius Optional. If a cached radius position already exists, overrides default.
  97363. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97364. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97365. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97366. */
  97367. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97368. /**
  97369. * Targets the given meshes with their children and updates zoom level accordingly.
  97370. * @param meshes The mesh to target.
  97371. * @param radius Optional. If a cached radius position already exists, overrides default.
  97372. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97373. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97374. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97375. */
  97376. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97377. /**
  97378. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97379. * @param minimumWorld Determines the smaller position of the bounding box extend
  97380. * @param maximumWorld Determines the bigger position of the bounding box extend
  97381. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97382. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97383. */
  97384. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97385. /**
  97386. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97387. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97388. * frustum width.
  97389. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97390. * to fully enclose the mesh in the viewing frustum.
  97391. */
  97392. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97393. /**
  97394. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97395. * is automatically returned to its default position (expected to be above ground plane).
  97396. */
  97397. private _maintainCameraAboveGround;
  97398. /**
  97399. * Returns the frustum slope based on the canvas ratio and camera FOV
  97400. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97401. */
  97402. private _getFrustumSlope;
  97403. /**
  97404. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97405. */
  97406. private _clearAnimationLocks;
  97407. /**
  97408. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97409. */
  97410. private _applyUserInteraction;
  97411. /**
  97412. * Stops and removes all animations that have been applied to the camera
  97413. */
  97414. stopAllAnimations(): void;
  97415. /**
  97416. * Gets a value indicating if the user is moving the camera
  97417. */
  97418. readonly isUserIsMoving: boolean;
  97419. /**
  97420. * The camera can move all the way towards the mesh.
  97421. */
  97422. static IgnoreBoundsSizeMode: number;
  97423. /**
  97424. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97425. */
  97426. static FitFrustumSidesMode: number;
  97427. }
  97428. }
  97429. declare module BABYLON {
  97430. /**
  97431. * Base class for Camera Pointer Inputs.
  97432. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97433. * for example usage.
  97434. */
  97435. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97436. /**
  97437. * Defines the camera the input is attached to.
  97438. */
  97439. abstract camera: Camera;
  97440. /**
  97441. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97442. */
  97443. protected _altKey: boolean;
  97444. protected _ctrlKey: boolean;
  97445. protected _metaKey: boolean;
  97446. protected _shiftKey: boolean;
  97447. /**
  97448. * Which mouse buttons were pressed at time of last mouse event.
  97449. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97450. */
  97451. protected _buttonsPressed: number;
  97452. /**
  97453. * Defines the buttons associated with the input to handle camera move.
  97454. */
  97455. buttons: number[];
  97456. /**
  97457. * Attach the input controls to a specific dom element to get the input from.
  97458. * @param element Defines the element the controls should be listened from
  97459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97460. */
  97461. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97462. /**
  97463. * Detach the current controls from the specified dom element.
  97464. * @param element Defines the element to stop listening the inputs from
  97465. */
  97466. detachControl(element: Nullable<HTMLElement>): void;
  97467. /**
  97468. * Gets the class name of the current input.
  97469. * @returns the class name
  97470. */
  97471. getClassName(): string;
  97472. /**
  97473. * Get the friendly name associated with the input class.
  97474. * @returns the input friendly name
  97475. */
  97476. getSimpleName(): string;
  97477. /**
  97478. * Called on pointer POINTERDOUBLETAP event.
  97479. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97480. */
  97481. protected onDoubleTap(type: string): void;
  97482. /**
  97483. * Called on pointer POINTERMOVE event if only a single touch is active.
  97484. * Override this method to provide functionality.
  97485. */
  97486. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97487. /**
  97488. * Called on pointer POINTERMOVE event if multiple touches are active.
  97489. * Override this method to provide functionality.
  97490. */
  97491. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97492. /**
  97493. * Called on JS contextmenu event.
  97494. * Override this method to provide functionality.
  97495. */
  97496. protected onContextMenu(evt: PointerEvent): void;
  97497. /**
  97498. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97499. * press.
  97500. * Override this method to provide functionality.
  97501. */
  97502. protected onButtonDown(evt: PointerEvent): void;
  97503. /**
  97504. * Called each time a new POINTERUP event occurs. Ie, for each button
  97505. * release.
  97506. * Override this method to provide functionality.
  97507. */
  97508. protected onButtonUp(evt: PointerEvent): void;
  97509. /**
  97510. * Called when window becomes inactive.
  97511. * Override this method to provide functionality.
  97512. */
  97513. protected onLostFocus(): void;
  97514. private _pointerInput;
  97515. private _observer;
  97516. private _onLostFocus;
  97517. private pointA;
  97518. private pointB;
  97519. }
  97520. }
  97521. declare module BABYLON {
  97522. /**
  97523. * Manage the pointers inputs to control an arc rotate camera.
  97524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97525. */
  97526. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97527. /**
  97528. * Defines the camera the input is attached to.
  97529. */
  97530. camera: ArcRotateCamera;
  97531. /**
  97532. * Gets the class name of the current input.
  97533. * @returns the class name
  97534. */
  97535. getClassName(): string;
  97536. /**
  97537. * Defines the buttons associated with the input to handle camera move.
  97538. */
  97539. buttons: number[];
  97540. /**
  97541. * Defines the pointer angular sensibility along the X axis or how fast is
  97542. * the camera rotating.
  97543. */
  97544. angularSensibilityX: number;
  97545. /**
  97546. * Defines the pointer angular sensibility along the Y axis or how fast is
  97547. * the camera rotating.
  97548. */
  97549. angularSensibilityY: number;
  97550. /**
  97551. * Defines the pointer pinch precision or how fast is the camera zooming.
  97552. */
  97553. pinchPrecision: number;
  97554. /**
  97555. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97556. * from 0.
  97557. * It defines the percentage of current camera.radius to use as delta when
  97558. * pinch zoom is used.
  97559. */
  97560. pinchDeltaPercentage: number;
  97561. /**
  97562. * Defines the pointer panning sensibility or how fast is the camera moving.
  97563. */
  97564. panningSensibility: number;
  97565. /**
  97566. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97567. */
  97568. multiTouchPanning: boolean;
  97569. /**
  97570. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97571. * zoom (pinch) through multitouch.
  97572. */
  97573. multiTouchPanAndZoom: boolean;
  97574. /**
  97575. * Revers pinch action direction.
  97576. */
  97577. pinchInwards: boolean;
  97578. private _isPanClick;
  97579. private _twoFingerActivityCount;
  97580. private _isPinching;
  97581. /**
  97582. * Called on pointer POINTERMOVE event if only a single touch is active.
  97583. */
  97584. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97585. /**
  97586. * Called on pointer POINTERDOUBLETAP event.
  97587. */
  97588. protected onDoubleTap(type: string): void;
  97589. /**
  97590. * Called on pointer POINTERMOVE event if multiple touches are active.
  97591. */
  97592. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97593. /**
  97594. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97595. * press.
  97596. */
  97597. protected onButtonDown(evt: PointerEvent): void;
  97598. /**
  97599. * Called each time a new POINTERUP event occurs. Ie, for each button
  97600. * release.
  97601. */
  97602. protected onButtonUp(evt: PointerEvent): void;
  97603. /**
  97604. * Called when window becomes inactive.
  97605. */
  97606. protected onLostFocus(): void;
  97607. }
  97608. }
  97609. declare module BABYLON {
  97610. /**
  97611. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97613. */
  97614. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97615. /**
  97616. * Defines the camera the input is attached to.
  97617. */
  97618. camera: ArcRotateCamera;
  97619. /**
  97620. * Defines the list of key codes associated with the up action (increase alpha)
  97621. */
  97622. keysUp: number[];
  97623. /**
  97624. * Defines the list of key codes associated with the down action (decrease alpha)
  97625. */
  97626. keysDown: number[];
  97627. /**
  97628. * Defines the list of key codes associated with the left action (increase beta)
  97629. */
  97630. keysLeft: number[];
  97631. /**
  97632. * Defines the list of key codes associated with the right action (decrease beta)
  97633. */
  97634. keysRight: number[];
  97635. /**
  97636. * Defines the list of key codes associated with the reset action.
  97637. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97638. */
  97639. keysReset: number[];
  97640. /**
  97641. * Defines the panning sensibility of the inputs.
  97642. * (How fast is the camera paning)
  97643. */
  97644. panningSensibility: number;
  97645. /**
  97646. * Defines the zooming sensibility of the inputs.
  97647. * (How fast is the camera zooming)
  97648. */
  97649. zoomingSensibility: number;
  97650. /**
  97651. * Defines wether maintaining the alt key down switch the movement mode from
  97652. * orientation to zoom.
  97653. */
  97654. useAltToZoom: boolean;
  97655. /**
  97656. * Rotation speed of the camera
  97657. */
  97658. angularSpeed: number;
  97659. private _keys;
  97660. private _ctrlPressed;
  97661. private _altPressed;
  97662. private _onCanvasBlurObserver;
  97663. private _onKeyboardObserver;
  97664. private _engine;
  97665. private _scene;
  97666. /**
  97667. * Attach the input controls to a specific dom element to get the input from.
  97668. * @param element Defines the element the controls should be listened from
  97669. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97670. */
  97671. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97672. /**
  97673. * Detach the current controls from the specified dom element.
  97674. * @param element Defines the element to stop listening the inputs from
  97675. */
  97676. detachControl(element: Nullable<HTMLElement>): void;
  97677. /**
  97678. * Update the current camera state depending on the inputs that have been used this frame.
  97679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97680. */
  97681. checkInputs(): void;
  97682. /**
  97683. * Gets the class name of the current intput.
  97684. * @returns the class name
  97685. */
  97686. getClassName(): string;
  97687. /**
  97688. * Get the friendly name associated with the input class.
  97689. * @returns the input friendly name
  97690. */
  97691. getSimpleName(): string;
  97692. }
  97693. }
  97694. declare module BABYLON {
  97695. /**
  97696. * Manage the mouse wheel inputs to control an arc rotate camera.
  97697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97698. */
  97699. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97700. /**
  97701. * Defines the camera the input is attached to.
  97702. */
  97703. camera: ArcRotateCamera;
  97704. /**
  97705. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97706. */
  97707. wheelPrecision: number;
  97708. /**
  97709. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97710. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97711. */
  97712. wheelDeltaPercentage: number;
  97713. private _wheel;
  97714. private _observer;
  97715. private computeDeltaFromMouseWheelLegacyEvent;
  97716. /**
  97717. * Attach the input controls to a specific dom element to get the input from.
  97718. * @param element Defines the element the controls should be listened from
  97719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97720. */
  97721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97722. /**
  97723. * Detach the current controls from the specified dom element.
  97724. * @param element Defines the element to stop listening the inputs from
  97725. */
  97726. detachControl(element: Nullable<HTMLElement>): void;
  97727. /**
  97728. * Gets the class name of the current intput.
  97729. * @returns the class name
  97730. */
  97731. getClassName(): string;
  97732. /**
  97733. * Get the friendly name associated with the input class.
  97734. * @returns the input friendly name
  97735. */
  97736. getSimpleName(): string;
  97737. }
  97738. }
  97739. declare module BABYLON {
  97740. /**
  97741. * Default Inputs manager for the ArcRotateCamera.
  97742. * It groups all the default supported inputs for ease of use.
  97743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97744. */
  97745. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97746. /**
  97747. * Instantiates a new ArcRotateCameraInputsManager.
  97748. * @param camera Defines the camera the inputs belong to
  97749. */
  97750. constructor(camera: ArcRotateCamera);
  97751. /**
  97752. * Add mouse wheel input support to the input manager.
  97753. * @returns the current input manager
  97754. */
  97755. addMouseWheel(): ArcRotateCameraInputsManager;
  97756. /**
  97757. * Add pointers input support to the input manager.
  97758. * @returns the current input manager
  97759. */
  97760. addPointers(): ArcRotateCameraInputsManager;
  97761. /**
  97762. * Add keyboard input support to the input manager.
  97763. * @returns the current input manager
  97764. */
  97765. addKeyboard(): ArcRotateCameraInputsManager;
  97766. }
  97767. }
  97768. declare module BABYLON {
  97769. /**
  97770. * This represents an orbital type of camera.
  97771. *
  97772. * 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.
  97773. * 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.
  97774. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97775. */
  97776. export class ArcRotateCamera extends TargetCamera {
  97777. /**
  97778. * Defines the rotation angle of the camera along the longitudinal axis.
  97779. */
  97780. alpha: number;
  97781. /**
  97782. * Defines the rotation angle of the camera along the latitudinal axis.
  97783. */
  97784. beta: number;
  97785. /**
  97786. * Defines the radius of the camera from it s target point.
  97787. */
  97788. radius: number;
  97789. protected _target: Vector3;
  97790. protected _targetHost: Nullable<AbstractMesh>;
  97791. /**
  97792. * Defines the target point of the camera.
  97793. * The camera looks towards it form the radius distance.
  97794. */
  97795. target: Vector3;
  97796. /**
  97797. * Define the current local position of the camera in the scene
  97798. */
  97799. position: Vector3;
  97800. protected _upVector: Vector3;
  97801. protected _upToYMatrix: Matrix;
  97802. protected _YToUpMatrix: Matrix;
  97803. /**
  97804. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  97805. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  97806. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  97807. */
  97808. upVector: Vector3;
  97809. /**
  97810. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  97811. */
  97812. setMatUp(): void;
  97813. /**
  97814. * Current inertia value on the longitudinal axis.
  97815. * The bigger this number the longer it will take for the camera to stop.
  97816. */
  97817. inertialAlphaOffset: number;
  97818. /**
  97819. * Current inertia value on the latitudinal axis.
  97820. * The bigger this number the longer it will take for the camera to stop.
  97821. */
  97822. inertialBetaOffset: number;
  97823. /**
  97824. * Current inertia value on the radius axis.
  97825. * The bigger this number the longer it will take for the camera to stop.
  97826. */
  97827. inertialRadiusOffset: number;
  97828. /**
  97829. * Minimum allowed angle on the longitudinal axis.
  97830. * This can help limiting how the Camera is able to move in the scene.
  97831. */
  97832. lowerAlphaLimit: Nullable<number>;
  97833. /**
  97834. * Maximum allowed angle on the longitudinal axis.
  97835. * This can help limiting how the Camera is able to move in the scene.
  97836. */
  97837. upperAlphaLimit: Nullable<number>;
  97838. /**
  97839. * Minimum allowed angle on the latitudinal axis.
  97840. * This can help limiting how the Camera is able to move in the scene.
  97841. */
  97842. lowerBetaLimit: number;
  97843. /**
  97844. * Maximum allowed angle on the latitudinal axis.
  97845. * This can help limiting how the Camera is able to move in the scene.
  97846. */
  97847. upperBetaLimit: number;
  97848. /**
  97849. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  97850. * This can help limiting how the Camera is able to move in the scene.
  97851. */
  97852. lowerRadiusLimit: Nullable<number>;
  97853. /**
  97854. * Maximum allowed distance of the camera to the target (The camera can not get further).
  97855. * This can help limiting how the Camera is able to move in the scene.
  97856. */
  97857. upperRadiusLimit: Nullable<number>;
  97858. /**
  97859. * Defines the current inertia value used during panning of the camera along the X axis.
  97860. */
  97861. inertialPanningX: number;
  97862. /**
  97863. * Defines the current inertia value used during panning of the camera along the Y axis.
  97864. */
  97865. inertialPanningY: number;
  97866. /**
  97867. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  97868. * Basically if your fingers moves away from more than this distance you will be considered
  97869. * in pinch mode.
  97870. */
  97871. pinchToPanMaxDistance: number;
  97872. /**
  97873. * Defines the maximum distance the camera can pan.
  97874. * This could help keeping the cammera always in your scene.
  97875. */
  97876. panningDistanceLimit: Nullable<number>;
  97877. /**
  97878. * Defines the target of the camera before paning.
  97879. */
  97880. panningOriginTarget: Vector3;
  97881. /**
  97882. * Defines the value of the inertia used during panning.
  97883. * 0 would mean stop inertia and one would mean no decelleration at all.
  97884. */
  97885. panningInertia: number;
  97886. /**
  97887. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  97888. */
  97889. angularSensibilityX: number;
  97890. /**
  97891. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  97892. */
  97893. angularSensibilityY: number;
  97894. /**
  97895. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  97896. */
  97897. pinchPrecision: number;
  97898. /**
  97899. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  97900. * It will be used instead of pinchDeltaPrecision if different from 0.
  97901. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97902. */
  97903. pinchDeltaPercentage: number;
  97904. /**
  97905. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  97906. */
  97907. panningSensibility: number;
  97908. /**
  97909. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  97910. */
  97911. keysUp: number[];
  97912. /**
  97913. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  97914. */
  97915. keysDown: number[];
  97916. /**
  97917. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  97918. */
  97919. keysLeft: number[];
  97920. /**
  97921. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  97922. */
  97923. keysRight: number[];
  97924. /**
  97925. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97926. */
  97927. wheelPrecision: number;
  97928. /**
  97929. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  97930. * It will be used instead of pinchDeltaPrecision if different from 0.
  97931. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97932. */
  97933. wheelDeltaPercentage: number;
  97934. /**
  97935. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  97936. */
  97937. zoomOnFactor: number;
  97938. /**
  97939. * Defines a screen offset for the camera position.
  97940. */
  97941. targetScreenOffset: Vector2;
  97942. /**
  97943. * Allows the camera to be completely reversed.
  97944. * If false the camera can not arrive upside down.
  97945. */
  97946. allowUpsideDown: boolean;
  97947. /**
  97948. * Define if double tap/click is used to restore the previously saved state of the camera.
  97949. */
  97950. useInputToRestoreState: boolean;
  97951. /** @hidden */
  97952. _viewMatrix: Matrix;
  97953. /** @hidden */
  97954. _useCtrlForPanning: boolean;
  97955. /** @hidden */
  97956. _panningMouseButton: number;
  97957. /**
  97958. * Defines the input associated to the camera.
  97959. */
  97960. inputs: ArcRotateCameraInputsManager;
  97961. /** @hidden */
  97962. _reset: () => void;
  97963. /**
  97964. * Defines the allowed panning axis.
  97965. */
  97966. panningAxis: Vector3;
  97967. protected _localDirection: Vector3;
  97968. protected _transformedDirection: Vector3;
  97969. private _bouncingBehavior;
  97970. /**
  97971. * Gets the bouncing behavior of the camera if it has been enabled.
  97972. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97973. */
  97974. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  97975. /**
  97976. * Defines if the bouncing behavior of the camera is enabled on the camera.
  97977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97978. */
  97979. useBouncingBehavior: boolean;
  97980. private _framingBehavior;
  97981. /**
  97982. * Gets the framing behavior of the camera if it has been enabled.
  97983. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97984. */
  97985. readonly framingBehavior: Nullable<FramingBehavior>;
  97986. /**
  97987. * Defines if the framing behavior of the camera is enabled on the camera.
  97988. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97989. */
  97990. useFramingBehavior: boolean;
  97991. private _autoRotationBehavior;
  97992. /**
  97993. * Gets the auto rotation behavior of the camera if it has been enabled.
  97994. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97995. */
  97996. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  97997. /**
  97998. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  97999. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98000. */
  98001. useAutoRotationBehavior: boolean;
  98002. /**
  98003. * Observable triggered when the mesh target has been changed on the camera.
  98004. */
  98005. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98006. /**
  98007. * Event raised when the camera is colliding with a mesh.
  98008. */
  98009. onCollide: (collidedMesh: AbstractMesh) => void;
  98010. /**
  98011. * Defines whether the camera should check collision with the objects oh the scene.
  98012. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98013. */
  98014. checkCollisions: boolean;
  98015. /**
  98016. * Defines the collision radius of the camera.
  98017. * This simulates a sphere around the camera.
  98018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98019. */
  98020. collisionRadius: Vector3;
  98021. protected _collider: Collider;
  98022. protected _previousPosition: Vector3;
  98023. protected _collisionVelocity: Vector3;
  98024. protected _newPosition: Vector3;
  98025. protected _previousAlpha: number;
  98026. protected _previousBeta: number;
  98027. protected _previousRadius: number;
  98028. protected _collisionTriggered: boolean;
  98029. protected _targetBoundingCenter: Nullable<Vector3>;
  98030. private _computationVector;
  98031. /**
  98032. * Instantiates a new ArcRotateCamera in a given scene
  98033. * @param name Defines the name of the camera
  98034. * @param alpha Defines the camera rotation along the logitudinal axis
  98035. * @param beta Defines the camera rotation along the latitudinal axis
  98036. * @param radius Defines the camera distance from its target
  98037. * @param target Defines the camera target
  98038. * @param scene Defines the scene the camera belongs to
  98039. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98040. */
  98041. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98042. /** @hidden */
  98043. _initCache(): void;
  98044. /** @hidden */
  98045. _updateCache(ignoreParentClass?: boolean): void;
  98046. protected _getTargetPosition(): Vector3;
  98047. private _storedAlpha;
  98048. private _storedBeta;
  98049. private _storedRadius;
  98050. private _storedTarget;
  98051. /**
  98052. * Stores the current state of the camera (alpha, beta, radius and target)
  98053. * @returns the camera itself
  98054. */
  98055. storeState(): Camera;
  98056. /**
  98057. * @hidden
  98058. * Restored camera state. You must call storeState() first
  98059. */
  98060. _restoreStateValues(): boolean;
  98061. /** @hidden */
  98062. _isSynchronizedViewMatrix(): boolean;
  98063. /**
  98064. * Attached controls to the current camera.
  98065. * @param element Defines the element the controls should be listened from
  98066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98067. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98068. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98069. */
  98070. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98071. /**
  98072. * Detach the current controls from the camera.
  98073. * The camera will stop reacting to inputs.
  98074. * @param element Defines the element to stop listening the inputs from
  98075. */
  98076. detachControl(element: HTMLElement): void;
  98077. /** @hidden */
  98078. _checkInputs(): void;
  98079. protected _checkLimits(): void;
  98080. /**
  98081. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98082. */
  98083. rebuildAnglesAndRadius(): void;
  98084. /**
  98085. * Use a position to define the current camera related information like aplha, beta and radius
  98086. * @param position Defines the position to set the camera at
  98087. */
  98088. setPosition(position: Vector3): void;
  98089. /**
  98090. * Defines the target the camera should look at.
  98091. * This will automatically adapt alpha beta and radius to fit within the new target.
  98092. * @param target Defines the new target as a Vector or a mesh
  98093. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98094. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98095. */
  98096. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98097. /** @hidden */
  98098. _getViewMatrix(): Matrix;
  98099. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98100. /**
  98101. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98102. * @param meshes Defines the mesh to zoom on
  98103. * @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)
  98104. */
  98105. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98106. /**
  98107. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98108. * The target will be changed but the radius
  98109. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98110. * @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)
  98111. */
  98112. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98113. min: Vector3;
  98114. max: Vector3;
  98115. distance: number;
  98116. }, doNotUpdateMaxZ?: boolean): void;
  98117. /**
  98118. * @override
  98119. * Override Camera.createRigCamera
  98120. */
  98121. createRigCamera(name: string, cameraIndex: number): Camera;
  98122. /**
  98123. * @hidden
  98124. * @override
  98125. * Override Camera._updateRigCameras
  98126. */
  98127. _updateRigCameras(): void;
  98128. /**
  98129. * Destroy the camera and release the current resources hold by it.
  98130. */
  98131. dispose(): void;
  98132. /**
  98133. * Gets the current object class name.
  98134. * @return the class name
  98135. */
  98136. getClassName(): string;
  98137. }
  98138. }
  98139. declare module BABYLON {
  98140. /**
  98141. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98143. */
  98144. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98145. /**
  98146. * Gets the name of the behavior.
  98147. */
  98148. readonly name: string;
  98149. private _zoomStopsAnimation;
  98150. private _idleRotationSpeed;
  98151. private _idleRotationWaitTime;
  98152. private _idleRotationSpinupTime;
  98153. /**
  98154. * Sets the flag that indicates if user zooming should stop animation.
  98155. */
  98156. /**
  98157. * Gets the flag that indicates if user zooming should stop animation.
  98158. */
  98159. zoomStopsAnimation: boolean;
  98160. /**
  98161. * Sets the default speed at which the camera rotates around the model.
  98162. */
  98163. /**
  98164. * Gets the default speed at which the camera rotates around the model.
  98165. */
  98166. idleRotationSpeed: number;
  98167. /**
  98168. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98169. */
  98170. /**
  98171. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98172. */
  98173. idleRotationWaitTime: number;
  98174. /**
  98175. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98176. */
  98177. /**
  98178. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98179. */
  98180. idleRotationSpinupTime: number;
  98181. /**
  98182. * Gets a value indicating if the camera is currently rotating because of this behavior
  98183. */
  98184. readonly rotationInProgress: boolean;
  98185. private _onPrePointerObservableObserver;
  98186. private _onAfterCheckInputsObserver;
  98187. private _attachedCamera;
  98188. private _isPointerDown;
  98189. private _lastFrameTime;
  98190. private _lastInteractionTime;
  98191. private _cameraRotationSpeed;
  98192. /**
  98193. * Initializes the behavior.
  98194. */
  98195. init(): void;
  98196. /**
  98197. * Attaches the behavior to its arc rotate camera.
  98198. * @param camera Defines the camera to attach the behavior to
  98199. */
  98200. attach(camera: ArcRotateCamera): void;
  98201. /**
  98202. * Detaches the behavior from its current arc rotate camera.
  98203. */
  98204. detach(): void;
  98205. /**
  98206. * Returns true if user is scrolling.
  98207. * @return true if user is scrolling.
  98208. */
  98209. private _userIsZooming;
  98210. private _lastFrameRadius;
  98211. private _shouldAnimationStopForInteraction;
  98212. /**
  98213. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98214. */
  98215. private _applyUserInteraction;
  98216. private _userIsMoving;
  98217. }
  98218. }
  98219. declare module BABYLON {
  98220. /**
  98221. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98222. */
  98223. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98224. private ui;
  98225. /**
  98226. * The name of the behavior
  98227. */
  98228. name: string;
  98229. /**
  98230. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98231. */
  98232. distanceAwayFromFace: number;
  98233. /**
  98234. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98235. */
  98236. distanceAwayFromBottomOfFace: number;
  98237. private _faceVectors;
  98238. private _target;
  98239. private _scene;
  98240. private _onRenderObserver;
  98241. private _tmpMatrix;
  98242. private _tmpVector;
  98243. /**
  98244. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98245. * @param ui The transform node that should be attched to the mesh
  98246. */
  98247. constructor(ui: TransformNode);
  98248. /**
  98249. * Initializes the behavior
  98250. */
  98251. init(): void;
  98252. private _closestFace;
  98253. private _zeroVector;
  98254. private _lookAtTmpMatrix;
  98255. private _lookAtToRef;
  98256. /**
  98257. * Attaches the AttachToBoxBehavior to the passed in mesh
  98258. * @param target The mesh that the specified node will be attached to
  98259. */
  98260. attach(target: Mesh): void;
  98261. /**
  98262. * Detaches the behavior from the mesh
  98263. */
  98264. detach(): void;
  98265. }
  98266. }
  98267. declare module BABYLON {
  98268. /**
  98269. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98270. */
  98271. export class FadeInOutBehavior implements Behavior<Mesh> {
  98272. /**
  98273. * Time in milliseconds to delay before fading in (Default: 0)
  98274. */
  98275. delay: number;
  98276. /**
  98277. * Time in milliseconds for the mesh to fade in (Default: 300)
  98278. */
  98279. fadeInTime: number;
  98280. private _millisecondsPerFrame;
  98281. private _hovered;
  98282. private _hoverValue;
  98283. private _ownerNode;
  98284. /**
  98285. * Instatiates the FadeInOutBehavior
  98286. */
  98287. constructor();
  98288. /**
  98289. * The name of the behavior
  98290. */
  98291. readonly name: string;
  98292. /**
  98293. * Initializes the behavior
  98294. */
  98295. init(): void;
  98296. /**
  98297. * Attaches the fade behavior on the passed in mesh
  98298. * @param ownerNode The mesh that will be faded in/out once attached
  98299. */
  98300. attach(ownerNode: Mesh): void;
  98301. /**
  98302. * Detaches the behavior from the mesh
  98303. */
  98304. detach(): void;
  98305. /**
  98306. * Triggers the mesh to begin fading in or out
  98307. * @param value if the object should fade in or out (true to fade in)
  98308. */
  98309. fadeIn(value: boolean): void;
  98310. private _update;
  98311. private _setAllVisibility;
  98312. }
  98313. }
  98314. declare module BABYLON {
  98315. /**
  98316. * Class containing a set of static utilities functions for managing Pivots
  98317. * @hidden
  98318. */
  98319. export class PivotTools {
  98320. private static _PivotCached;
  98321. private static _OldPivotPoint;
  98322. private static _PivotTranslation;
  98323. private static _PivotTmpVector;
  98324. /** @hidden */
  98325. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98326. /** @hidden */
  98327. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98328. }
  98329. }
  98330. declare module BABYLON {
  98331. /**
  98332. * Class containing static functions to help procedurally build meshes
  98333. */
  98334. export class PlaneBuilder {
  98335. /**
  98336. * Creates a plane mesh
  98337. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98338. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98339. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98340. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98341. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98343. * @param name defines the name of the mesh
  98344. * @param options defines the options used to create the mesh
  98345. * @param scene defines the hosting scene
  98346. * @returns the plane mesh
  98347. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98348. */
  98349. static CreatePlane(name: string, options: {
  98350. size?: number;
  98351. width?: number;
  98352. height?: number;
  98353. sideOrientation?: number;
  98354. frontUVs?: Vector4;
  98355. backUVs?: Vector4;
  98356. updatable?: boolean;
  98357. sourcePlane?: Plane;
  98358. }, scene?: Nullable<Scene>): Mesh;
  98359. }
  98360. }
  98361. declare module BABYLON {
  98362. /**
  98363. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98364. */
  98365. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98366. private static _AnyMouseID;
  98367. /**
  98368. * Abstract mesh the behavior is set on
  98369. */
  98370. attachedNode: AbstractMesh;
  98371. private _dragPlane;
  98372. private _scene;
  98373. private _pointerObserver;
  98374. private _beforeRenderObserver;
  98375. private static _planeScene;
  98376. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98377. /**
  98378. * 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)
  98379. */
  98380. maxDragAngle: number;
  98381. /**
  98382. * @hidden
  98383. */
  98384. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98385. /**
  98386. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98387. */
  98388. currentDraggingPointerID: number;
  98389. /**
  98390. * The last position where the pointer hit the drag plane in world space
  98391. */
  98392. lastDragPosition: Vector3;
  98393. /**
  98394. * If the behavior is currently in a dragging state
  98395. */
  98396. dragging: boolean;
  98397. /**
  98398. * 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)
  98399. */
  98400. dragDeltaRatio: number;
  98401. /**
  98402. * If the drag plane orientation should be updated during the dragging (Default: true)
  98403. */
  98404. updateDragPlane: boolean;
  98405. private _debugMode;
  98406. private _moving;
  98407. /**
  98408. * Fires each time the attached mesh is dragged with the pointer
  98409. * * delta between last drag position and current drag position in world space
  98410. * * dragDistance along the drag axis
  98411. * * dragPlaneNormal normal of the current drag plane used during the drag
  98412. * * dragPlanePoint in world space where the drag intersects the drag plane
  98413. */
  98414. onDragObservable: Observable<{
  98415. delta: Vector3;
  98416. dragPlanePoint: Vector3;
  98417. dragPlaneNormal: Vector3;
  98418. dragDistance: number;
  98419. pointerId: number;
  98420. }>;
  98421. /**
  98422. * Fires each time a drag begins (eg. mouse down on mesh)
  98423. */
  98424. onDragStartObservable: Observable<{
  98425. dragPlanePoint: Vector3;
  98426. pointerId: number;
  98427. }>;
  98428. /**
  98429. * Fires each time a drag ends (eg. mouse release after drag)
  98430. */
  98431. onDragEndObservable: Observable<{
  98432. dragPlanePoint: Vector3;
  98433. pointerId: number;
  98434. }>;
  98435. /**
  98436. * If the attached mesh should be moved when dragged
  98437. */
  98438. moveAttached: boolean;
  98439. /**
  98440. * If the drag behavior will react to drag events (Default: true)
  98441. */
  98442. enabled: boolean;
  98443. /**
  98444. * If camera controls should be detached during the drag
  98445. */
  98446. detachCameraControls: boolean;
  98447. /**
  98448. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98449. */
  98450. useObjectOrienationForDragging: boolean;
  98451. private _options;
  98452. /**
  98453. * Creates a pointer drag behavior that can be attached to a mesh
  98454. * @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)
  98455. */
  98456. constructor(options?: {
  98457. dragAxis?: Vector3;
  98458. dragPlaneNormal?: Vector3;
  98459. });
  98460. /**
  98461. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98462. */
  98463. validateDrag: (targetPosition: Vector3) => boolean;
  98464. /**
  98465. * The name of the behavior
  98466. */
  98467. readonly name: string;
  98468. /**
  98469. * Initializes the behavior
  98470. */
  98471. init(): void;
  98472. private _tmpVector;
  98473. private _alternatePickedPoint;
  98474. private _worldDragAxis;
  98475. private _targetPosition;
  98476. private _attachedElement;
  98477. /**
  98478. * Attaches the drag behavior the passed in mesh
  98479. * @param ownerNode The mesh that will be dragged around once attached
  98480. */
  98481. attach(ownerNode: AbstractMesh): void;
  98482. /**
  98483. * Force relase the drag action by code.
  98484. */
  98485. releaseDrag(): void;
  98486. private _startDragRay;
  98487. private _lastPointerRay;
  98488. /**
  98489. * Simulates the start of a pointer drag event on the behavior
  98490. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98491. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98492. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98493. */
  98494. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98495. private _startDrag;
  98496. private _dragDelta;
  98497. private _moveDrag;
  98498. private _pickWithRayOnDragPlane;
  98499. private _pointA;
  98500. private _pointB;
  98501. private _pointC;
  98502. private _lineA;
  98503. private _lineB;
  98504. private _localAxis;
  98505. private _lookAt;
  98506. private _updateDragPlanePosition;
  98507. /**
  98508. * Detaches the behavior from the mesh
  98509. */
  98510. detach(): void;
  98511. }
  98512. }
  98513. declare module BABYLON {
  98514. /**
  98515. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98516. */
  98517. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98518. private _dragBehaviorA;
  98519. private _dragBehaviorB;
  98520. private _startDistance;
  98521. private _initialScale;
  98522. private _targetScale;
  98523. private _ownerNode;
  98524. private _sceneRenderObserver;
  98525. /**
  98526. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98527. */
  98528. constructor();
  98529. /**
  98530. * The name of the behavior
  98531. */
  98532. readonly name: string;
  98533. /**
  98534. * Initializes the behavior
  98535. */
  98536. init(): void;
  98537. private _getCurrentDistance;
  98538. /**
  98539. * Attaches the scale behavior the passed in mesh
  98540. * @param ownerNode The mesh that will be scaled around once attached
  98541. */
  98542. attach(ownerNode: Mesh): void;
  98543. /**
  98544. * Detaches the behavior from the mesh
  98545. */
  98546. detach(): void;
  98547. }
  98548. }
  98549. declare module BABYLON {
  98550. /**
  98551. * 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
  98552. */
  98553. export class SixDofDragBehavior implements Behavior<Mesh> {
  98554. private static _virtualScene;
  98555. private _ownerNode;
  98556. private _sceneRenderObserver;
  98557. private _scene;
  98558. private _targetPosition;
  98559. private _virtualOriginMesh;
  98560. private _virtualDragMesh;
  98561. private _pointerObserver;
  98562. private _moving;
  98563. private _startingOrientation;
  98564. /**
  98565. * 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)
  98566. */
  98567. private zDragFactor;
  98568. /**
  98569. * If the object should rotate to face the drag origin
  98570. */
  98571. rotateDraggedObject: boolean;
  98572. /**
  98573. * If the behavior is currently in a dragging state
  98574. */
  98575. dragging: boolean;
  98576. /**
  98577. * 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)
  98578. */
  98579. dragDeltaRatio: number;
  98580. /**
  98581. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98582. */
  98583. currentDraggingPointerID: number;
  98584. /**
  98585. * If camera controls should be detached during the drag
  98586. */
  98587. detachCameraControls: boolean;
  98588. /**
  98589. * Fires each time a drag starts
  98590. */
  98591. onDragStartObservable: Observable<{}>;
  98592. /**
  98593. * Fires each time a drag ends (eg. mouse release after drag)
  98594. */
  98595. onDragEndObservable: Observable<{}>;
  98596. /**
  98597. * 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
  98598. */
  98599. constructor();
  98600. /**
  98601. * The name of the behavior
  98602. */
  98603. readonly name: string;
  98604. /**
  98605. * Initializes the behavior
  98606. */
  98607. init(): void;
  98608. /**
  98609. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  98610. */
  98611. private readonly _pointerCamera;
  98612. /**
  98613. * Attaches the scale behavior the passed in mesh
  98614. * @param ownerNode The mesh that will be scaled around once attached
  98615. */
  98616. attach(ownerNode: Mesh): void;
  98617. /**
  98618. * Detaches the behavior from the mesh
  98619. */
  98620. detach(): void;
  98621. }
  98622. }
  98623. declare module BABYLON {
  98624. /**
  98625. * Class used to apply inverse kinematics to bones
  98626. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98627. */
  98628. export class BoneIKController {
  98629. private static _tmpVecs;
  98630. private static _tmpQuat;
  98631. private static _tmpMats;
  98632. /**
  98633. * Gets or sets the target mesh
  98634. */
  98635. targetMesh: AbstractMesh;
  98636. /** Gets or sets the mesh used as pole */
  98637. poleTargetMesh: AbstractMesh;
  98638. /**
  98639. * Gets or sets the bone used as pole
  98640. */
  98641. poleTargetBone: Nullable<Bone>;
  98642. /**
  98643. * Gets or sets the target position
  98644. */
  98645. targetPosition: Vector3;
  98646. /**
  98647. * Gets or sets the pole target position
  98648. */
  98649. poleTargetPosition: Vector3;
  98650. /**
  98651. * Gets or sets the pole target local offset
  98652. */
  98653. poleTargetLocalOffset: Vector3;
  98654. /**
  98655. * Gets or sets the pole angle
  98656. */
  98657. poleAngle: number;
  98658. /**
  98659. * Gets or sets the mesh associated with the controller
  98660. */
  98661. mesh: AbstractMesh;
  98662. /**
  98663. * 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)
  98664. */
  98665. slerpAmount: number;
  98666. private _bone1Quat;
  98667. private _bone1Mat;
  98668. private _bone2Ang;
  98669. private _bone1;
  98670. private _bone2;
  98671. private _bone1Length;
  98672. private _bone2Length;
  98673. private _maxAngle;
  98674. private _maxReach;
  98675. private _rightHandedSystem;
  98676. private _bendAxis;
  98677. private _slerping;
  98678. private _adjustRoll;
  98679. /**
  98680. * Gets or sets maximum allowed angle
  98681. */
  98682. maxAngle: number;
  98683. /**
  98684. * Creates a new BoneIKController
  98685. * @param mesh defines the mesh to control
  98686. * @param bone defines the bone to control
  98687. * @param options defines options to set up the controller
  98688. */
  98689. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98690. targetMesh?: AbstractMesh;
  98691. poleTargetMesh?: AbstractMesh;
  98692. poleTargetBone?: Bone;
  98693. poleTargetLocalOffset?: Vector3;
  98694. poleAngle?: number;
  98695. bendAxis?: Vector3;
  98696. maxAngle?: number;
  98697. slerpAmount?: number;
  98698. });
  98699. private _setMaxAngle;
  98700. /**
  98701. * Force the controller to update the bones
  98702. */
  98703. update(): void;
  98704. }
  98705. }
  98706. declare module BABYLON {
  98707. /**
  98708. * Class used to make a bone look toward a point in space
  98709. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98710. */
  98711. export class BoneLookController {
  98712. private static _tmpVecs;
  98713. private static _tmpQuat;
  98714. private static _tmpMats;
  98715. /**
  98716. * The target Vector3 that the bone will look at
  98717. */
  98718. target: Vector3;
  98719. /**
  98720. * The mesh that the bone is attached to
  98721. */
  98722. mesh: AbstractMesh;
  98723. /**
  98724. * The bone that will be looking to the target
  98725. */
  98726. bone: Bone;
  98727. /**
  98728. * The up axis of the coordinate system that is used when the bone is rotated
  98729. */
  98730. upAxis: Vector3;
  98731. /**
  98732. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98733. */
  98734. upAxisSpace: Space;
  98735. /**
  98736. * Used to make an adjustment to the yaw of the bone
  98737. */
  98738. adjustYaw: number;
  98739. /**
  98740. * Used to make an adjustment to the pitch of the bone
  98741. */
  98742. adjustPitch: number;
  98743. /**
  98744. * Used to make an adjustment to the roll of the bone
  98745. */
  98746. adjustRoll: number;
  98747. /**
  98748. * 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)
  98749. */
  98750. slerpAmount: number;
  98751. private _minYaw;
  98752. private _maxYaw;
  98753. private _minPitch;
  98754. private _maxPitch;
  98755. private _minYawSin;
  98756. private _minYawCos;
  98757. private _maxYawSin;
  98758. private _maxYawCos;
  98759. private _midYawConstraint;
  98760. private _minPitchTan;
  98761. private _maxPitchTan;
  98762. private _boneQuat;
  98763. private _slerping;
  98764. private _transformYawPitch;
  98765. private _transformYawPitchInv;
  98766. private _firstFrameSkipped;
  98767. private _yawRange;
  98768. private _fowardAxis;
  98769. /**
  98770. * Gets or sets the minimum yaw angle that the bone can look to
  98771. */
  98772. minYaw: number;
  98773. /**
  98774. * Gets or sets the maximum yaw angle that the bone can look to
  98775. */
  98776. maxYaw: number;
  98777. /**
  98778. * Gets or sets the minimum pitch angle that the bone can look to
  98779. */
  98780. minPitch: number;
  98781. /**
  98782. * Gets or sets the maximum pitch angle that the bone can look to
  98783. */
  98784. maxPitch: number;
  98785. /**
  98786. * Create a BoneLookController
  98787. * @param mesh the mesh that the bone belongs to
  98788. * @param bone the bone that will be looking to the target
  98789. * @param target the target Vector3 to look at
  98790. * @param options optional settings:
  98791. * * maxYaw: the maximum angle the bone will yaw to
  98792. * * minYaw: the minimum angle the bone will yaw to
  98793. * * maxPitch: the maximum angle the bone will pitch to
  98794. * * minPitch: the minimum angle the bone will yaw to
  98795. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98796. * * upAxis: the up axis of the coordinate system
  98797. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  98798. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  98799. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  98800. * * adjustYaw: used to make an adjustment to the yaw of the bone
  98801. * * adjustPitch: used to make an adjustment to the pitch of the bone
  98802. * * adjustRoll: used to make an adjustment to the roll of the bone
  98803. **/
  98804. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  98805. maxYaw?: number;
  98806. minYaw?: number;
  98807. maxPitch?: number;
  98808. minPitch?: number;
  98809. slerpAmount?: number;
  98810. upAxis?: Vector3;
  98811. upAxisSpace?: Space;
  98812. yawAxis?: Vector3;
  98813. pitchAxis?: Vector3;
  98814. adjustYaw?: number;
  98815. adjustPitch?: number;
  98816. adjustRoll?: number;
  98817. });
  98818. /**
  98819. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  98820. */
  98821. update(): void;
  98822. private _getAngleDiff;
  98823. private _getAngleBetween;
  98824. private _isAngleBetween;
  98825. }
  98826. }
  98827. declare module BABYLON {
  98828. /**
  98829. * Manage the gamepad inputs to control an arc rotate camera.
  98830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98831. */
  98832. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  98833. /**
  98834. * Defines the camera the input is attached to.
  98835. */
  98836. camera: ArcRotateCamera;
  98837. /**
  98838. * Defines the gamepad the input is gathering event from.
  98839. */
  98840. gamepad: Nullable<Gamepad>;
  98841. /**
  98842. * Defines the gamepad rotation sensiblity.
  98843. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  98844. */
  98845. gamepadRotationSensibility: number;
  98846. /**
  98847. * Defines the gamepad move sensiblity.
  98848. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  98849. */
  98850. gamepadMoveSensibility: number;
  98851. private _onGamepadConnectedObserver;
  98852. private _onGamepadDisconnectedObserver;
  98853. /**
  98854. * Attach the input controls to a specific dom element to get the input from.
  98855. * @param element Defines the element the controls should be listened from
  98856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98857. */
  98858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98859. /**
  98860. * Detach the current controls from the specified dom element.
  98861. * @param element Defines the element to stop listening the inputs from
  98862. */
  98863. detachControl(element: Nullable<HTMLElement>): void;
  98864. /**
  98865. * Update the current camera state depending on the inputs that have been used this frame.
  98866. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98867. */
  98868. checkInputs(): void;
  98869. /**
  98870. * Gets the class name of the current intput.
  98871. * @returns the class name
  98872. */
  98873. getClassName(): string;
  98874. /**
  98875. * Get the friendly name associated with the input class.
  98876. * @returns the input friendly name
  98877. */
  98878. getSimpleName(): string;
  98879. }
  98880. }
  98881. declare module BABYLON {
  98882. interface ArcRotateCameraInputsManager {
  98883. /**
  98884. * Add orientation input support to the input manager.
  98885. * @returns the current input manager
  98886. */
  98887. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  98888. }
  98889. /**
  98890. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  98891. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98892. */
  98893. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  98894. /**
  98895. * Defines the camera the input is attached to.
  98896. */
  98897. camera: ArcRotateCamera;
  98898. /**
  98899. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  98900. */
  98901. alphaCorrection: number;
  98902. /**
  98903. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  98904. */
  98905. gammaCorrection: number;
  98906. private _alpha;
  98907. private _gamma;
  98908. private _dirty;
  98909. private _deviceOrientationHandler;
  98910. /**
  98911. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  98912. */
  98913. constructor();
  98914. /**
  98915. * Attach the input controls to a specific dom element to get the input from.
  98916. * @param element Defines the element the controls should be listened from
  98917. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98918. */
  98919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98920. /** @hidden */
  98921. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  98922. /**
  98923. * Update the current camera state depending on the inputs that have been used this frame.
  98924. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98925. */
  98926. checkInputs(): void;
  98927. /**
  98928. * Detach the current controls from the specified dom element.
  98929. * @param element Defines the element to stop listening the inputs from
  98930. */
  98931. detachControl(element: Nullable<HTMLElement>): void;
  98932. /**
  98933. * Gets the class name of the current intput.
  98934. * @returns the class name
  98935. */
  98936. getClassName(): string;
  98937. /**
  98938. * Get the friendly name associated with the input class.
  98939. * @returns the input friendly name
  98940. */
  98941. getSimpleName(): string;
  98942. }
  98943. }
  98944. declare module BABYLON {
  98945. /**
  98946. * Listen to mouse events to control the camera.
  98947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98948. */
  98949. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  98950. /**
  98951. * Defines the camera the input is attached to.
  98952. */
  98953. camera: FlyCamera;
  98954. /**
  98955. * Defines if touch is enabled. (Default is true.)
  98956. */
  98957. touchEnabled: boolean;
  98958. /**
  98959. * Defines the buttons associated with the input to handle camera rotation.
  98960. */
  98961. buttons: number[];
  98962. /**
  98963. * Assign buttons for Yaw control.
  98964. */
  98965. buttonsYaw: number[];
  98966. /**
  98967. * Assign buttons for Pitch control.
  98968. */
  98969. buttonsPitch: number[];
  98970. /**
  98971. * Assign buttons for Roll control.
  98972. */
  98973. buttonsRoll: number[];
  98974. /**
  98975. * Detect if any button is being pressed while mouse is moved.
  98976. * -1 = Mouse locked.
  98977. * 0 = Left button.
  98978. * 1 = Middle Button.
  98979. * 2 = Right Button.
  98980. */
  98981. activeButton: number;
  98982. /**
  98983. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  98984. * Higher values reduce its sensitivity.
  98985. */
  98986. angularSensibility: number;
  98987. private _mousemoveCallback;
  98988. private _observer;
  98989. private _rollObserver;
  98990. private previousPosition;
  98991. private noPreventDefault;
  98992. private element;
  98993. /**
  98994. * Listen to mouse events to control the camera.
  98995. * @param touchEnabled Define if touch is enabled. (Default is true.)
  98996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98997. */
  98998. constructor(touchEnabled?: boolean);
  98999. /**
  99000. * Attach the mouse control to the HTML DOM element.
  99001. * @param element Defines the element that listens to the input events.
  99002. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99003. */
  99004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99005. /**
  99006. * Detach the current controls from the specified dom element.
  99007. * @param element Defines the element to stop listening the inputs from
  99008. */
  99009. detachControl(element: Nullable<HTMLElement>): void;
  99010. /**
  99011. * Gets the class name of the current input.
  99012. * @returns the class name.
  99013. */
  99014. getClassName(): string;
  99015. /**
  99016. * Get the friendly name associated with the input class.
  99017. * @returns the input's friendly name.
  99018. */
  99019. getSimpleName(): string;
  99020. private _pointerInput;
  99021. private _onMouseMove;
  99022. /**
  99023. * Rotate camera by mouse offset.
  99024. */
  99025. private rotateCamera;
  99026. }
  99027. }
  99028. declare module BABYLON {
  99029. /**
  99030. * Default Inputs manager for the FlyCamera.
  99031. * It groups all the default supported inputs for ease of use.
  99032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99033. */
  99034. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99035. /**
  99036. * Instantiates a new FlyCameraInputsManager.
  99037. * @param camera Defines the camera the inputs belong to.
  99038. */
  99039. constructor(camera: FlyCamera);
  99040. /**
  99041. * Add keyboard input support to the input manager.
  99042. * @returns the new FlyCameraKeyboardMoveInput().
  99043. */
  99044. addKeyboard(): FlyCameraInputsManager;
  99045. /**
  99046. * Add mouse input support to the input manager.
  99047. * @param touchEnabled Enable touch screen support.
  99048. * @returns the new FlyCameraMouseInput().
  99049. */
  99050. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99051. }
  99052. }
  99053. declare module BABYLON {
  99054. /**
  99055. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99056. * such as in a 3D Space Shooter or a Flight Simulator.
  99057. */
  99058. export class FlyCamera extends TargetCamera {
  99059. /**
  99060. * Define the collision ellipsoid of the camera.
  99061. * This is helpful for simulating a camera body, like a player's body.
  99062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99063. */
  99064. ellipsoid: Vector3;
  99065. /**
  99066. * Define an offset for the position of the ellipsoid around the camera.
  99067. * This can be helpful if the camera is attached away from the player's body center,
  99068. * such as at its head.
  99069. */
  99070. ellipsoidOffset: Vector3;
  99071. /**
  99072. * Enable or disable collisions of the camera with the rest of the scene objects.
  99073. */
  99074. checkCollisions: boolean;
  99075. /**
  99076. * Enable or disable gravity on the camera.
  99077. */
  99078. applyGravity: boolean;
  99079. /**
  99080. * Define the current direction the camera is moving to.
  99081. */
  99082. cameraDirection: Vector3;
  99083. /**
  99084. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99085. * This overrides and empties cameraRotation.
  99086. */
  99087. rotationQuaternion: Quaternion;
  99088. /**
  99089. * Track Roll to maintain the wanted Rolling when looking around.
  99090. */
  99091. _trackRoll: number;
  99092. /**
  99093. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99094. */
  99095. rollCorrect: number;
  99096. /**
  99097. * Mimic a banked turn, Rolling the camera when Yawing.
  99098. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99099. */
  99100. bankedTurn: boolean;
  99101. /**
  99102. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99103. */
  99104. bankedTurnLimit: number;
  99105. /**
  99106. * Value of 0 disables the banked Roll.
  99107. * Value of 1 is equal to the Yaw angle in radians.
  99108. */
  99109. bankedTurnMultiplier: number;
  99110. /**
  99111. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99112. */
  99113. inputs: FlyCameraInputsManager;
  99114. /**
  99115. * Gets the input sensibility for mouse input.
  99116. * Higher values reduce sensitivity.
  99117. */
  99118. /**
  99119. * Sets the input sensibility for a mouse input.
  99120. * Higher values reduce sensitivity.
  99121. */
  99122. angularSensibility: number;
  99123. /**
  99124. * Get the keys for camera movement forward.
  99125. */
  99126. /**
  99127. * Set the keys for camera movement forward.
  99128. */
  99129. keysForward: number[];
  99130. /**
  99131. * Get the keys for camera movement backward.
  99132. */
  99133. keysBackward: number[];
  99134. /**
  99135. * Get the keys for camera movement up.
  99136. */
  99137. /**
  99138. * Set the keys for camera movement up.
  99139. */
  99140. keysUp: number[];
  99141. /**
  99142. * Get the keys for camera movement down.
  99143. */
  99144. /**
  99145. * Set the keys for camera movement down.
  99146. */
  99147. keysDown: number[];
  99148. /**
  99149. * Get the keys for camera movement left.
  99150. */
  99151. /**
  99152. * Set the keys for camera movement left.
  99153. */
  99154. keysLeft: number[];
  99155. /**
  99156. * Set the keys for camera movement right.
  99157. */
  99158. /**
  99159. * Set the keys for camera movement right.
  99160. */
  99161. keysRight: number[];
  99162. /**
  99163. * Event raised when the camera collides with a mesh in the scene.
  99164. */
  99165. onCollide: (collidedMesh: AbstractMesh) => void;
  99166. private _collider;
  99167. private _needMoveForGravity;
  99168. private _oldPosition;
  99169. private _diffPosition;
  99170. private _newPosition;
  99171. /** @hidden */
  99172. _localDirection: Vector3;
  99173. /** @hidden */
  99174. _transformedDirection: Vector3;
  99175. /**
  99176. * Instantiates a FlyCamera.
  99177. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99178. * such as in a 3D Space Shooter or a Flight Simulator.
  99179. * @param name Define the name of the camera in the scene.
  99180. * @param position Define the starting position of the camera in the scene.
  99181. * @param scene Define the scene the camera belongs to.
  99182. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99183. */
  99184. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99185. /**
  99186. * Attach a control to the HTML DOM element.
  99187. * @param element Defines the element that listens to the input events.
  99188. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99189. */
  99190. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99191. /**
  99192. * Detach a control from the HTML DOM element.
  99193. * The camera will stop reacting to that input.
  99194. * @param element Defines the element that listens to the input events.
  99195. */
  99196. detachControl(element: HTMLElement): void;
  99197. private _collisionMask;
  99198. /**
  99199. * Get the mask that the camera ignores in collision events.
  99200. */
  99201. /**
  99202. * Set the mask that the camera ignores in collision events.
  99203. */
  99204. collisionMask: number;
  99205. /** @hidden */
  99206. _collideWithWorld(displacement: Vector3): void;
  99207. /** @hidden */
  99208. private _onCollisionPositionChange;
  99209. /** @hidden */
  99210. _checkInputs(): void;
  99211. /** @hidden */
  99212. _decideIfNeedsToMove(): boolean;
  99213. /** @hidden */
  99214. _updatePosition(): void;
  99215. /**
  99216. * Restore the Roll to its target value at the rate specified.
  99217. * @param rate - Higher means slower restoring.
  99218. * @hidden
  99219. */
  99220. restoreRoll(rate: number): void;
  99221. /**
  99222. * Destroy the camera and release the current resources held by it.
  99223. */
  99224. dispose(): void;
  99225. /**
  99226. * Get the current object class name.
  99227. * @returns the class name.
  99228. */
  99229. getClassName(): string;
  99230. }
  99231. }
  99232. declare module BABYLON {
  99233. /**
  99234. * Listen to keyboard events to control the camera.
  99235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99236. */
  99237. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99238. /**
  99239. * Defines the camera the input is attached to.
  99240. */
  99241. camera: FlyCamera;
  99242. /**
  99243. * The list of keyboard keys used to control the forward move of the camera.
  99244. */
  99245. keysForward: number[];
  99246. /**
  99247. * The list of keyboard keys used to control the backward move of the camera.
  99248. */
  99249. keysBackward: number[];
  99250. /**
  99251. * The list of keyboard keys used to control the forward move of the camera.
  99252. */
  99253. keysUp: number[];
  99254. /**
  99255. * The list of keyboard keys used to control the backward move of the camera.
  99256. */
  99257. keysDown: number[];
  99258. /**
  99259. * The list of keyboard keys used to control the right strafe move of the camera.
  99260. */
  99261. keysRight: number[];
  99262. /**
  99263. * The list of keyboard keys used to control the left strafe move of the camera.
  99264. */
  99265. keysLeft: number[];
  99266. private _keys;
  99267. private _onCanvasBlurObserver;
  99268. private _onKeyboardObserver;
  99269. private _engine;
  99270. private _scene;
  99271. /**
  99272. * Attach the input controls to a specific dom element to get the input from.
  99273. * @param element Defines the element the controls should be listened from
  99274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99275. */
  99276. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99277. /**
  99278. * Detach the current controls from the specified dom element.
  99279. * @param element Defines the element to stop listening the inputs from
  99280. */
  99281. detachControl(element: Nullable<HTMLElement>): void;
  99282. /**
  99283. * Gets the class name of the current intput.
  99284. * @returns the class name
  99285. */
  99286. getClassName(): string;
  99287. /** @hidden */
  99288. _onLostFocus(e: FocusEvent): void;
  99289. /**
  99290. * Get the friendly name associated with the input class.
  99291. * @returns the input friendly name
  99292. */
  99293. getSimpleName(): string;
  99294. /**
  99295. * Update the current camera state depending on the inputs that have been used this frame.
  99296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99297. */
  99298. checkInputs(): void;
  99299. }
  99300. }
  99301. declare module BABYLON {
  99302. /**
  99303. * Manage the mouse wheel inputs to control a follow camera.
  99304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99305. */
  99306. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99307. /**
  99308. * Defines the camera the input is attached to.
  99309. */
  99310. camera: FollowCamera;
  99311. /**
  99312. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99313. */
  99314. axisControlRadius: boolean;
  99315. /**
  99316. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99317. */
  99318. axisControlHeight: boolean;
  99319. /**
  99320. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99321. */
  99322. axisControlRotation: boolean;
  99323. /**
  99324. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99325. * relation to mouseWheel events.
  99326. */
  99327. wheelPrecision: number;
  99328. /**
  99329. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99330. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99331. */
  99332. wheelDeltaPercentage: number;
  99333. private _wheel;
  99334. private _observer;
  99335. /**
  99336. * Attach the input controls to a specific dom element to get the input from.
  99337. * @param element Defines the element the controls should be listened from
  99338. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99339. */
  99340. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99341. /**
  99342. * Detach the current controls from the specified dom element.
  99343. * @param element Defines the element to stop listening the inputs from
  99344. */
  99345. detachControl(element: Nullable<HTMLElement>): void;
  99346. /**
  99347. * Gets the class name of the current intput.
  99348. * @returns the class name
  99349. */
  99350. getClassName(): string;
  99351. /**
  99352. * Get the friendly name associated with the input class.
  99353. * @returns the input friendly name
  99354. */
  99355. getSimpleName(): string;
  99356. }
  99357. }
  99358. declare module BABYLON {
  99359. /**
  99360. * Manage the pointers inputs to control an follow camera.
  99361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99362. */
  99363. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99364. /**
  99365. * Defines the camera the input is attached to.
  99366. */
  99367. camera: FollowCamera;
  99368. /**
  99369. * Gets the class name of the current input.
  99370. * @returns the class name
  99371. */
  99372. getClassName(): string;
  99373. /**
  99374. * Defines the pointer angular sensibility along the X axis or how fast is
  99375. * the camera rotating.
  99376. * A negative number will reverse the axis direction.
  99377. */
  99378. angularSensibilityX: number;
  99379. /**
  99380. * Defines the pointer angular sensibility along the Y axis or how fast is
  99381. * the camera rotating.
  99382. * A negative number will reverse the axis direction.
  99383. */
  99384. angularSensibilityY: number;
  99385. /**
  99386. * Defines the pointer pinch precision or how fast is the camera zooming.
  99387. * A negative number will reverse the axis direction.
  99388. */
  99389. pinchPrecision: number;
  99390. /**
  99391. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99392. * from 0.
  99393. * It defines the percentage of current camera.radius to use as delta when
  99394. * pinch zoom is used.
  99395. */
  99396. pinchDeltaPercentage: number;
  99397. /**
  99398. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99399. */
  99400. axisXControlRadius: boolean;
  99401. /**
  99402. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99403. */
  99404. axisXControlHeight: boolean;
  99405. /**
  99406. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99407. */
  99408. axisXControlRotation: boolean;
  99409. /**
  99410. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99411. */
  99412. axisYControlRadius: boolean;
  99413. /**
  99414. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99415. */
  99416. axisYControlHeight: boolean;
  99417. /**
  99418. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99419. */
  99420. axisYControlRotation: boolean;
  99421. /**
  99422. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99423. */
  99424. axisPinchControlRadius: boolean;
  99425. /**
  99426. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99427. */
  99428. axisPinchControlHeight: boolean;
  99429. /**
  99430. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99431. */
  99432. axisPinchControlRotation: boolean;
  99433. /**
  99434. * Log error messages if basic misconfiguration has occurred.
  99435. */
  99436. warningEnable: boolean;
  99437. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99438. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99439. private _warningCounter;
  99440. private _warning;
  99441. }
  99442. }
  99443. declare module BABYLON {
  99444. /**
  99445. * Default Inputs manager for the FollowCamera.
  99446. * It groups all the default supported inputs for ease of use.
  99447. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99448. */
  99449. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99450. /**
  99451. * Instantiates a new FollowCameraInputsManager.
  99452. * @param camera Defines the camera the inputs belong to
  99453. */
  99454. constructor(camera: FollowCamera);
  99455. /**
  99456. * Add keyboard input support to the input manager.
  99457. * @returns the current input manager
  99458. */
  99459. addKeyboard(): FollowCameraInputsManager;
  99460. /**
  99461. * Add mouse wheel input support to the input manager.
  99462. * @returns the current input manager
  99463. */
  99464. addMouseWheel(): FollowCameraInputsManager;
  99465. /**
  99466. * Add pointers input support to the input manager.
  99467. * @returns the current input manager
  99468. */
  99469. addPointers(): FollowCameraInputsManager;
  99470. /**
  99471. * Add orientation input support to the input manager.
  99472. * @returns the current input manager
  99473. */
  99474. addVRDeviceOrientation(): FollowCameraInputsManager;
  99475. }
  99476. }
  99477. declare module BABYLON {
  99478. /**
  99479. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99480. * an arc rotate version arcFollowCamera are available.
  99481. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99482. */
  99483. export class FollowCamera extends TargetCamera {
  99484. /**
  99485. * Distance the follow camera should follow an object at
  99486. */
  99487. radius: number;
  99488. /**
  99489. * Minimum allowed distance of the camera to the axis of rotation
  99490. * (The camera can not get closer).
  99491. * This can help limiting how the Camera is able to move in the scene.
  99492. */
  99493. lowerRadiusLimit: Nullable<number>;
  99494. /**
  99495. * Maximum allowed distance of the camera to the axis of rotation
  99496. * (The camera can not get further).
  99497. * This can help limiting how the Camera is able to move in the scene.
  99498. */
  99499. upperRadiusLimit: Nullable<number>;
  99500. /**
  99501. * Define a rotation offset between the camera and the object it follows
  99502. */
  99503. rotationOffset: number;
  99504. /**
  99505. * Minimum allowed angle to camera position relative to target object.
  99506. * This can help limiting how the Camera is able to move in the scene.
  99507. */
  99508. lowerRotationOffsetLimit: Nullable<number>;
  99509. /**
  99510. * Maximum allowed angle to camera position relative to target object.
  99511. * This can help limiting how the Camera is able to move in the scene.
  99512. */
  99513. upperRotationOffsetLimit: Nullable<number>;
  99514. /**
  99515. * Define a height offset between the camera and the object it follows.
  99516. * It can help following an object from the top (like a car chaing a plane)
  99517. */
  99518. heightOffset: number;
  99519. /**
  99520. * Minimum allowed height of camera position relative to target object.
  99521. * This can help limiting how the Camera is able to move in the scene.
  99522. */
  99523. lowerHeightOffsetLimit: Nullable<number>;
  99524. /**
  99525. * Maximum allowed height of camera position relative to target object.
  99526. * This can help limiting how the Camera is able to move in the scene.
  99527. */
  99528. upperHeightOffsetLimit: Nullable<number>;
  99529. /**
  99530. * Define how fast the camera can accelerate to follow it s target.
  99531. */
  99532. cameraAcceleration: number;
  99533. /**
  99534. * Define the speed limit of the camera following an object.
  99535. */
  99536. maxCameraSpeed: number;
  99537. /**
  99538. * Define the target of the camera.
  99539. */
  99540. lockedTarget: Nullable<AbstractMesh>;
  99541. /**
  99542. * Defines the input associated with the camera.
  99543. */
  99544. inputs: FollowCameraInputsManager;
  99545. /**
  99546. * Instantiates the follow camera.
  99547. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99548. * @param name Define the name of the camera in the scene
  99549. * @param position Define the position of the camera
  99550. * @param scene Define the scene the camera belong to
  99551. * @param lockedTarget Define the target of the camera
  99552. */
  99553. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99554. private _follow;
  99555. /**
  99556. * Attached controls to the current camera.
  99557. * @param element Defines the element the controls should be listened from
  99558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99559. */
  99560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99561. /**
  99562. * Detach the current controls from the camera.
  99563. * The camera will stop reacting to inputs.
  99564. * @param element Defines the element to stop listening the inputs from
  99565. */
  99566. detachControl(element: HTMLElement): void;
  99567. /** @hidden */
  99568. _checkInputs(): void;
  99569. private _checkLimits;
  99570. /**
  99571. * Gets the camera class name.
  99572. * @returns the class name
  99573. */
  99574. getClassName(): string;
  99575. }
  99576. /**
  99577. * Arc Rotate version of the follow camera.
  99578. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99579. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99580. */
  99581. export class ArcFollowCamera extends TargetCamera {
  99582. /** The longitudinal angle of the camera */
  99583. alpha: number;
  99584. /** The latitudinal angle of the camera */
  99585. beta: number;
  99586. /** The radius of the camera from its target */
  99587. radius: number;
  99588. /** Define the camera target (the messh it should follow) */
  99589. target: Nullable<AbstractMesh>;
  99590. private _cartesianCoordinates;
  99591. /**
  99592. * Instantiates a new ArcFollowCamera
  99593. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99594. * @param name Define the name of the camera
  99595. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99596. * @param beta Define the rotation angle of the camera around the elevation axis
  99597. * @param radius Define the radius of the camera from its target point
  99598. * @param target Define the target of the camera
  99599. * @param scene Define the scene the camera belongs to
  99600. */
  99601. constructor(name: string,
  99602. /** The longitudinal angle of the camera */
  99603. alpha: number,
  99604. /** The latitudinal angle of the camera */
  99605. beta: number,
  99606. /** The radius of the camera from its target */
  99607. radius: number,
  99608. /** Define the camera target (the messh it should follow) */
  99609. target: Nullable<AbstractMesh>, scene: Scene);
  99610. private _follow;
  99611. /** @hidden */
  99612. _checkInputs(): void;
  99613. /**
  99614. * Returns the class name of the object.
  99615. * It is mostly used internally for serialization purposes.
  99616. */
  99617. getClassName(): string;
  99618. }
  99619. }
  99620. declare module BABYLON {
  99621. /**
  99622. * Manage the keyboard inputs to control the movement of a follow camera.
  99623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99624. */
  99625. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99626. /**
  99627. * Defines the camera the input is attached to.
  99628. */
  99629. camera: FollowCamera;
  99630. /**
  99631. * Defines the list of key codes associated with the up action (increase heightOffset)
  99632. */
  99633. keysHeightOffsetIncr: number[];
  99634. /**
  99635. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99636. */
  99637. keysHeightOffsetDecr: number[];
  99638. /**
  99639. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99640. */
  99641. keysHeightOffsetModifierAlt: boolean;
  99642. /**
  99643. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99644. */
  99645. keysHeightOffsetModifierCtrl: boolean;
  99646. /**
  99647. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99648. */
  99649. keysHeightOffsetModifierShift: boolean;
  99650. /**
  99651. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99652. */
  99653. keysRotationOffsetIncr: number[];
  99654. /**
  99655. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99656. */
  99657. keysRotationOffsetDecr: number[];
  99658. /**
  99659. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99660. */
  99661. keysRotationOffsetModifierAlt: boolean;
  99662. /**
  99663. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99664. */
  99665. keysRotationOffsetModifierCtrl: boolean;
  99666. /**
  99667. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99668. */
  99669. keysRotationOffsetModifierShift: boolean;
  99670. /**
  99671. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99672. */
  99673. keysRadiusIncr: number[];
  99674. /**
  99675. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99676. */
  99677. keysRadiusDecr: number[];
  99678. /**
  99679. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99680. */
  99681. keysRadiusModifierAlt: boolean;
  99682. /**
  99683. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99684. */
  99685. keysRadiusModifierCtrl: boolean;
  99686. /**
  99687. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99688. */
  99689. keysRadiusModifierShift: boolean;
  99690. /**
  99691. * Defines the rate of change of heightOffset.
  99692. */
  99693. heightSensibility: number;
  99694. /**
  99695. * Defines the rate of change of rotationOffset.
  99696. */
  99697. rotationSensibility: number;
  99698. /**
  99699. * Defines the rate of change of radius.
  99700. */
  99701. radiusSensibility: number;
  99702. private _keys;
  99703. private _ctrlPressed;
  99704. private _altPressed;
  99705. private _shiftPressed;
  99706. private _onCanvasBlurObserver;
  99707. private _onKeyboardObserver;
  99708. private _engine;
  99709. private _scene;
  99710. /**
  99711. * Attach the input controls to a specific dom element to get the input from.
  99712. * @param element Defines the element the controls should be listened from
  99713. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99714. */
  99715. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99716. /**
  99717. * Detach the current controls from the specified dom element.
  99718. * @param element Defines the element to stop listening the inputs from
  99719. */
  99720. detachControl(element: Nullable<HTMLElement>): void;
  99721. /**
  99722. * Update the current camera state depending on the inputs that have been used this frame.
  99723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99724. */
  99725. checkInputs(): void;
  99726. /**
  99727. * Gets the class name of the current input.
  99728. * @returns the class name
  99729. */
  99730. getClassName(): string;
  99731. /**
  99732. * Get the friendly name associated with the input class.
  99733. * @returns the input friendly name
  99734. */
  99735. getSimpleName(): string;
  99736. /**
  99737. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99738. * allow modification of the heightOffset value.
  99739. */
  99740. private _modifierHeightOffset;
  99741. /**
  99742. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99743. * allow modification of the rotationOffset value.
  99744. */
  99745. private _modifierRotationOffset;
  99746. /**
  99747. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99748. * allow modification of the radius value.
  99749. */
  99750. private _modifierRadius;
  99751. }
  99752. }
  99753. declare module BABYLON {
  99754. interface FreeCameraInputsManager {
  99755. /**
  99756. * @hidden
  99757. */
  99758. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99759. /**
  99760. * Add orientation input support to the input manager.
  99761. * @returns the current input manager
  99762. */
  99763. addDeviceOrientation(): FreeCameraInputsManager;
  99764. }
  99765. /**
  99766. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99767. * Screen rotation is taken into account.
  99768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99769. */
  99770. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99771. private _camera;
  99772. private _screenOrientationAngle;
  99773. private _constantTranform;
  99774. private _screenQuaternion;
  99775. private _alpha;
  99776. private _beta;
  99777. private _gamma;
  99778. /**
  99779. * @hidden
  99780. */
  99781. _onDeviceOrientationChangedObservable: Observable<void>;
  99782. /**
  99783. * Instantiates a new input
  99784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99785. */
  99786. constructor();
  99787. /**
  99788. * Define the camera controlled by the input.
  99789. */
  99790. camera: FreeCamera;
  99791. /**
  99792. * Attach the input controls to a specific dom element to get the input from.
  99793. * @param element Defines the element the controls should be listened from
  99794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99795. */
  99796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99797. private _orientationChanged;
  99798. private _deviceOrientation;
  99799. /**
  99800. * Detach the current controls from the specified dom element.
  99801. * @param element Defines the element to stop listening the inputs from
  99802. */
  99803. detachControl(element: Nullable<HTMLElement>): void;
  99804. /**
  99805. * Update the current camera state depending on the inputs that have been used this frame.
  99806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99807. */
  99808. checkInputs(): void;
  99809. /**
  99810. * Gets the class name of the current intput.
  99811. * @returns the class name
  99812. */
  99813. getClassName(): string;
  99814. /**
  99815. * Get the friendly name associated with the input class.
  99816. * @returns the input friendly name
  99817. */
  99818. getSimpleName(): string;
  99819. }
  99820. }
  99821. declare module BABYLON {
  99822. /**
  99823. * Manage the gamepad inputs to control a free camera.
  99824. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99825. */
  99826. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  99827. /**
  99828. * Define the camera the input is attached to.
  99829. */
  99830. camera: FreeCamera;
  99831. /**
  99832. * Define the Gamepad controlling the input
  99833. */
  99834. gamepad: Nullable<Gamepad>;
  99835. /**
  99836. * Defines the gamepad rotation sensiblity.
  99837. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99838. */
  99839. gamepadAngularSensibility: number;
  99840. /**
  99841. * Defines the gamepad move sensiblity.
  99842. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99843. */
  99844. gamepadMoveSensibility: number;
  99845. private _onGamepadConnectedObserver;
  99846. private _onGamepadDisconnectedObserver;
  99847. private _cameraTransform;
  99848. private _deltaTransform;
  99849. private _vector3;
  99850. private _vector2;
  99851. /**
  99852. * Attach the input controls to a specific dom element to get the input from.
  99853. * @param element Defines the element the controls should be listened from
  99854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99855. */
  99856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99857. /**
  99858. * Detach the current controls from the specified dom element.
  99859. * @param element Defines the element to stop listening the inputs from
  99860. */
  99861. detachControl(element: Nullable<HTMLElement>): void;
  99862. /**
  99863. * Update the current camera state depending on the inputs that have been used this frame.
  99864. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99865. */
  99866. checkInputs(): void;
  99867. /**
  99868. * Gets the class name of the current intput.
  99869. * @returns the class name
  99870. */
  99871. getClassName(): string;
  99872. /**
  99873. * Get the friendly name associated with the input class.
  99874. * @returns the input friendly name
  99875. */
  99876. getSimpleName(): string;
  99877. }
  99878. }
  99879. declare module BABYLON {
  99880. /**
  99881. * Defines the potential axis of a Joystick
  99882. */
  99883. export enum JoystickAxis {
  99884. /** X axis */
  99885. X = 0,
  99886. /** Y axis */
  99887. Y = 1,
  99888. /** Z axis */
  99889. Z = 2
  99890. }
  99891. /**
  99892. * Class used to define virtual joystick (used in touch mode)
  99893. */
  99894. export class VirtualJoystick {
  99895. /**
  99896. * Gets or sets a boolean indicating that left and right values must be inverted
  99897. */
  99898. reverseLeftRight: boolean;
  99899. /**
  99900. * Gets or sets a boolean indicating that up and down values must be inverted
  99901. */
  99902. reverseUpDown: boolean;
  99903. /**
  99904. * Gets the offset value for the position (ie. the change of the position value)
  99905. */
  99906. deltaPosition: Vector3;
  99907. /**
  99908. * Gets a boolean indicating if the virtual joystick was pressed
  99909. */
  99910. pressed: boolean;
  99911. /**
  99912. * Canvas the virtual joystick will render onto, default z-index of this is 5
  99913. */
  99914. static Canvas: Nullable<HTMLCanvasElement>;
  99915. private static _globalJoystickIndex;
  99916. private static vjCanvasContext;
  99917. private static vjCanvasWidth;
  99918. private static vjCanvasHeight;
  99919. private static halfWidth;
  99920. private _action;
  99921. private _axisTargetedByLeftAndRight;
  99922. private _axisTargetedByUpAndDown;
  99923. private _joystickSensibility;
  99924. private _inversedSensibility;
  99925. private _joystickPointerID;
  99926. private _joystickColor;
  99927. private _joystickPointerPos;
  99928. private _joystickPreviousPointerPos;
  99929. private _joystickPointerStartPos;
  99930. private _deltaJoystickVector;
  99931. private _leftJoystick;
  99932. private _touches;
  99933. private _onPointerDownHandlerRef;
  99934. private _onPointerMoveHandlerRef;
  99935. private _onPointerUpHandlerRef;
  99936. private _onResize;
  99937. /**
  99938. * Creates a new virtual joystick
  99939. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99940. */
  99941. constructor(leftJoystick?: boolean);
  99942. /**
  99943. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99944. * @param newJoystickSensibility defines the new sensibility
  99945. */
  99946. setJoystickSensibility(newJoystickSensibility: number): void;
  99947. private _onPointerDown;
  99948. private _onPointerMove;
  99949. private _onPointerUp;
  99950. /**
  99951. * Change the color of the virtual joystick
  99952. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99953. */
  99954. setJoystickColor(newColor: string): void;
  99955. /**
  99956. * Defines a callback to call when the joystick is touched
  99957. * @param action defines the callback
  99958. */
  99959. setActionOnTouch(action: () => any): void;
  99960. /**
  99961. * Defines which axis you'd like to control for left & right
  99962. * @param axis defines the axis to use
  99963. */
  99964. setAxisForLeftRight(axis: JoystickAxis): void;
  99965. /**
  99966. * Defines which axis you'd like to control for up & down
  99967. * @param axis defines the axis to use
  99968. */
  99969. setAxisForUpDown(axis: JoystickAxis): void;
  99970. private _drawVirtualJoystick;
  99971. /**
  99972. * Release internal HTML canvas
  99973. */
  99974. releaseCanvas(): void;
  99975. }
  99976. }
  99977. declare module BABYLON {
  99978. interface FreeCameraInputsManager {
  99979. /**
  99980. * Add virtual joystick input support to the input manager.
  99981. * @returns the current input manager
  99982. */
  99983. addVirtualJoystick(): FreeCameraInputsManager;
  99984. }
  99985. /**
  99986. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  99987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99988. */
  99989. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  99990. /**
  99991. * Defines the camera the input is attached to.
  99992. */
  99993. camera: FreeCamera;
  99994. private _leftjoystick;
  99995. private _rightjoystick;
  99996. /**
  99997. * Gets the left stick of the virtual joystick.
  99998. * @returns The virtual Joystick
  99999. */
  100000. getLeftJoystick(): VirtualJoystick;
  100001. /**
  100002. * Gets the right stick of the virtual joystick.
  100003. * @returns The virtual Joystick
  100004. */
  100005. getRightJoystick(): VirtualJoystick;
  100006. /**
  100007. * Update the current camera state depending on the inputs that have been used this frame.
  100008. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100009. */
  100010. checkInputs(): void;
  100011. /**
  100012. * Attach the input controls to a specific dom element to get the input from.
  100013. * @param element Defines the element the controls should be listened from
  100014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100015. */
  100016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100017. /**
  100018. * Detach the current controls from the specified dom element.
  100019. * @param element Defines the element to stop listening the inputs from
  100020. */
  100021. detachControl(element: Nullable<HTMLElement>): void;
  100022. /**
  100023. * Gets the class name of the current intput.
  100024. * @returns the class name
  100025. */
  100026. getClassName(): string;
  100027. /**
  100028. * Get the friendly name associated with the input class.
  100029. * @returns the input friendly name
  100030. */
  100031. getSimpleName(): string;
  100032. }
  100033. }
  100034. declare module BABYLON {
  100035. /**
  100036. * This represents a FPS type of camera controlled by touch.
  100037. * This is like a universal camera minus the Gamepad controls.
  100038. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100039. */
  100040. export class TouchCamera extends FreeCamera {
  100041. /**
  100042. * Defines the touch sensibility for rotation.
  100043. * The higher the faster.
  100044. */
  100045. touchAngularSensibility: number;
  100046. /**
  100047. * Defines the touch sensibility for move.
  100048. * The higher the faster.
  100049. */
  100050. touchMoveSensibility: number;
  100051. /**
  100052. * Instantiates a new touch camera.
  100053. * This represents a FPS type of camera controlled by touch.
  100054. * This is like a universal camera minus the Gamepad controls.
  100055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100056. * @param name Define the name of the camera in the scene
  100057. * @param position Define the start position of the camera in the scene
  100058. * @param scene Define the scene the camera belongs to
  100059. */
  100060. constructor(name: string, position: Vector3, scene: Scene);
  100061. /**
  100062. * Gets the current object class name.
  100063. * @return the class name
  100064. */
  100065. getClassName(): string;
  100066. /** @hidden */
  100067. _setupInputs(): void;
  100068. }
  100069. }
  100070. declare module BABYLON {
  100071. /**
  100072. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100073. * being tilted forward or back and left or right.
  100074. */
  100075. export class DeviceOrientationCamera extends FreeCamera {
  100076. private _initialQuaternion;
  100077. private _quaternionCache;
  100078. private _tmpDragQuaternion;
  100079. /**
  100080. * Creates a new device orientation camera
  100081. * @param name The name of the camera
  100082. * @param position The start position camera
  100083. * @param scene The scene the camera belongs to
  100084. */
  100085. constructor(name: string, position: Vector3, scene: Scene);
  100086. /**
  100087. * @hidden
  100088. * Disabled pointer input on first orientation sensor update (Default: true)
  100089. */
  100090. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100091. private _dragFactor;
  100092. /**
  100093. * Enabled turning on the y axis when the orientation sensor is active
  100094. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100095. */
  100096. enableHorizontalDragging(dragFactor?: number): void;
  100097. /**
  100098. * Gets the current instance class name ("DeviceOrientationCamera").
  100099. * This helps avoiding instanceof at run time.
  100100. * @returns the class name
  100101. */
  100102. getClassName(): string;
  100103. /**
  100104. * @hidden
  100105. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100106. */
  100107. _checkInputs(): void;
  100108. /**
  100109. * Reset the camera to its default orientation on the specified axis only.
  100110. * @param axis The axis to reset
  100111. */
  100112. resetToCurrentRotation(axis?: Axis): void;
  100113. }
  100114. }
  100115. declare module BABYLON {
  100116. /**
  100117. * Defines supported buttons for XBox360 compatible gamepads
  100118. */
  100119. export enum Xbox360Button {
  100120. /** A */
  100121. A = 0,
  100122. /** B */
  100123. B = 1,
  100124. /** X */
  100125. X = 2,
  100126. /** Y */
  100127. Y = 3,
  100128. /** Start */
  100129. Start = 4,
  100130. /** Back */
  100131. Back = 5,
  100132. /** Left button */
  100133. LB = 6,
  100134. /** Right button */
  100135. RB = 7,
  100136. /** Left stick */
  100137. LeftStick = 8,
  100138. /** Right stick */
  100139. RightStick = 9
  100140. }
  100141. /** Defines values for XBox360 DPad */
  100142. export enum Xbox360Dpad {
  100143. /** Up */
  100144. Up = 0,
  100145. /** Down */
  100146. Down = 1,
  100147. /** Left */
  100148. Left = 2,
  100149. /** Right */
  100150. Right = 3
  100151. }
  100152. /**
  100153. * Defines a XBox360 gamepad
  100154. */
  100155. export class Xbox360Pad extends Gamepad {
  100156. private _leftTrigger;
  100157. private _rightTrigger;
  100158. private _onlefttriggerchanged;
  100159. private _onrighttriggerchanged;
  100160. private _onbuttondown;
  100161. private _onbuttonup;
  100162. private _ondpaddown;
  100163. private _ondpadup;
  100164. /** Observable raised when a button is pressed */
  100165. onButtonDownObservable: Observable<Xbox360Button>;
  100166. /** Observable raised when a button is released */
  100167. onButtonUpObservable: Observable<Xbox360Button>;
  100168. /** Observable raised when a pad is pressed */
  100169. onPadDownObservable: Observable<Xbox360Dpad>;
  100170. /** Observable raised when a pad is released */
  100171. onPadUpObservable: Observable<Xbox360Dpad>;
  100172. private _buttonA;
  100173. private _buttonB;
  100174. private _buttonX;
  100175. private _buttonY;
  100176. private _buttonBack;
  100177. private _buttonStart;
  100178. private _buttonLB;
  100179. private _buttonRB;
  100180. private _buttonLeftStick;
  100181. private _buttonRightStick;
  100182. private _dPadUp;
  100183. private _dPadDown;
  100184. private _dPadLeft;
  100185. private _dPadRight;
  100186. private _isXboxOnePad;
  100187. /**
  100188. * Creates a new XBox360 gamepad object
  100189. * @param id defines the id of this gamepad
  100190. * @param index defines its index
  100191. * @param gamepad defines the internal HTML gamepad object
  100192. * @param xboxOne defines if it is a XBox One gamepad
  100193. */
  100194. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100195. /**
  100196. * Defines the callback to call when left trigger is pressed
  100197. * @param callback defines the callback to use
  100198. */
  100199. onlefttriggerchanged(callback: (value: number) => void): void;
  100200. /**
  100201. * Defines the callback to call when right trigger is pressed
  100202. * @param callback defines the callback to use
  100203. */
  100204. onrighttriggerchanged(callback: (value: number) => void): void;
  100205. /**
  100206. * Gets the left trigger value
  100207. */
  100208. /**
  100209. * Sets the left trigger value
  100210. */
  100211. leftTrigger: number;
  100212. /**
  100213. * Gets the right trigger value
  100214. */
  100215. /**
  100216. * Sets the right trigger value
  100217. */
  100218. rightTrigger: number;
  100219. /**
  100220. * Defines the callback to call when a button is pressed
  100221. * @param callback defines the callback to use
  100222. */
  100223. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100224. /**
  100225. * Defines the callback to call when a button is released
  100226. * @param callback defines the callback to use
  100227. */
  100228. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100229. /**
  100230. * Defines the callback to call when a pad is pressed
  100231. * @param callback defines the callback to use
  100232. */
  100233. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100234. /**
  100235. * Defines the callback to call when a pad is released
  100236. * @param callback defines the callback to use
  100237. */
  100238. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100239. private _setButtonValue;
  100240. private _setDPadValue;
  100241. /**
  100242. * Gets the value of the `A` button
  100243. */
  100244. /**
  100245. * Sets the value of the `A` button
  100246. */
  100247. buttonA: number;
  100248. /**
  100249. * Gets the value of the `B` button
  100250. */
  100251. /**
  100252. * Sets the value of the `B` button
  100253. */
  100254. buttonB: number;
  100255. /**
  100256. * Gets the value of the `X` button
  100257. */
  100258. /**
  100259. * Sets the value of the `X` button
  100260. */
  100261. buttonX: number;
  100262. /**
  100263. * Gets the value of the `Y` button
  100264. */
  100265. /**
  100266. * Sets the value of the `Y` button
  100267. */
  100268. buttonY: number;
  100269. /**
  100270. * Gets the value of the `Start` button
  100271. */
  100272. /**
  100273. * Sets the value of the `Start` button
  100274. */
  100275. buttonStart: number;
  100276. /**
  100277. * Gets the value of the `Back` button
  100278. */
  100279. /**
  100280. * Sets the value of the `Back` button
  100281. */
  100282. buttonBack: number;
  100283. /**
  100284. * Gets the value of the `Left` button
  100285. */
  100286. /**
  100287. * Sets the value of the `Left` button
  100288. */
  100289. buttonLB: number;
  100290. /**
  100291. * Gets the value of the `Right` button
  100292. */
  100293. /**
  100294. * Sets the value of the `Right` button
  100295. */
  100296. buttonRB: number;
  100297. /**
  100298. * Gets the value of the Left joystick
  100299. */
  100300. /**
  100301. * Sets the value of the Left joystick
  100302. */
  100303. buttonLeftStick: number;
  100304. /**
  100305. * Gets the value of the Right joystick
  100306. */
  100307. /**
  100308. * Sets the value of the Right joystick
  100309. */
  100310. buttonRightStick: number;
  100311. /**
  100312. * Gets the value of D-pad up
  100313. */
  100314. /**
  100315. * Sets the value of D-pad up
  100316. */
  100317. dPadUp: number;
  100318. /**
  100319. * Gets the value of D-pad down
  100320. */
  100321. /**
  100322. * Sets the value of D-pad down
  100323. */
  100324. dPadDown: number;
  100325. /**
  100326. * Gets the value of D-pad left
  100327. */
  100328. /**
  100329. * Sets the value of D-pad left
  100330. */
  100331. dPadLeft: number;
  100332. /**
  100333. * Gets the value of D-pad right
  100334. */
  100335. /**
  100336. * Sets the value of D-pad right
  100337. */
  100338. dPadRight: number;
  100339. /**
  100340. * Force the gamepad to synchronize with device values
  100341. */
  100342. update(): void;
  100343. /**
  100344. * Disposes the gamepad
  100345. */
  100346. dispose(): void;
  100347. }
  100348. }
  100349. declare module BABYLON {
  100350. /**
  100351. * Manager for handling gamepads
  100352. */
  100353. export class GamepadManager {
  100354. private _scene?;
  100355. private _babylonGamepads;
  100356. private _oneGamepadConnected;
  100357. /** @hidden */
  100358. _isMonitoring: boolean;
  100359. private _gamepadEventSupported;
  100360. private _gamepadSupport;
  100361. /**
  100362. * observable to be triggered when the gamepad controller has been connected
  100363. */
  100364. onGamepadConnectedObservable: Observable<Gamepad>;
  100365. /**
  100366. * observable to be triggered when the gamepad controller has been disconnected
  100367. */
  100368. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100369. private _onGamepadConnectedEvent;
  100370. private _onGamepadDisconnectedEvent;
  100371. /**
  100372. * Initializes the gamepad manager
  100373. * @param _scene BabylonJS scene
  100374. */
  100375. constructor(_scene?: Scene | undefined);
  100376. /**
  100377. * The gamepads in the game pad manager
  100378. */
  100379. readonly gamepads: Gamepad[];
  100380. /**
  100381. * Get the gamepad controllers based on type
  100382. * @param type The type of gamepad controller
  100383. * @returns Nullable gamepad
  100384. */
  100385. getGamepadByType(type?: number): Nullable<Gamepad>;
  100386. /**
  100387. * Disposes the gamepad manager
  100388. */
  100389. dispose(): void;
  100390. private _addNewGamepad;
  100391. private _startMonitoringGamepads;
  100392. private _stopMonitoringGamepads;
  100393. /** @hidden */
  100394. _checkGamepadsStatus(): void;
  100395. private _updateGamepadObjects;
  100396. }
  100397. }
  100398. declare module BABYLON {
  100399. interface Scene {
  100400. /** @hidden */
  100401. _gamepadManager: Nullable<GamepadManager>;
  100402. /**
  100403. * Gets the gamepad manager associated with the scene
  100404. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100405. */
  100406. gamepadManager: GamepadManager;
  100407. }
  100408. /**
  100409. * Interface representing a free camera inputs manager
  100410. */
  100411. interface FreeCameraInputsManager {
  100412. /**
  100413. * Adds gamepad input support to the FreeCameraInputsManager.
  100414. * @returns the FreeCameraInputsManager
  100415. */
  100416. addGamepad(): FreeCameraInputsManager;
  100417. }
  100418. /**
  100419. * Interface representing an arc rotate camera inputs manager
  100420. */
  100421. interface ArcRotateCameraInputsManager {
  100422. /**
  100423. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100424. * @returns the camera inputs manager
  100425. */
  100426. addGamepad(): ArcRotateCameraInputsManager;
  100427. }
  100428. /**
  100429. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100430. */
  100431. export class GamepadSystemSceneComponent implements ISceneComponent {
  100432. /**
  100433. * The component name helpfull to identify the component in the list of scene components.
  100434. */
  100435. readonly name: string;
  100436. /**
  100437. * The scene the component belongs to.
  100438. */
  100439. scene: Scene;
  100440. /**
  100441. * Creates a new instance of the component for the given scene
  100442. * @param scene Defines the scene to register the component in
  100443. */
  100444. constructor(scene: Scene);
  100445. /**
  100446. * Registers the component in a given scene
  100447. */
  100448. register(): void;
  100449. /**
  100450. * Rebuilds the elements related to this component in case of
  100451. * context lost for instance.
  100452. */
  100453. rebuild(): void;
  100454. /**
  100455. * Disposes the component and the associated ressources
  100456. */
  100457. dispose(): void;
  100458. private _beforeCameraUpdate;
  100459. }
  100460. }
  100461. declare module BABYLON {
  100462. /**
  100463. * 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,
  100464. * which still works and will still be found in many Playgrounds.
  100465. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100466. */
  100467. export class UniversalCamera extends TouchCamera {
  100468. /**
  100469. * Defines the gamepad rotation sensiblity.
  100470. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100471. */
  100472. gamepadAngularSensibility: number;
  100473. /**
  100474. * Defines the gamepad move sensiblity.
  100475. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100476. */
  100477. gamepadMoveSensibility: number;
  100478. /**
  100479. * 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,
  100480. * which still works and will still be found in many Playgrounds.
  100481. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100482. * @param name Define the name of the camera in the scene
  100483. * @param position Define the start position of the camera in the scene
  100484. * @param scene Define the scene the camera belongs to
  100485. */
  100486. constructor(name: string, position: Vector3, scene: Scene);
  100487. /**
  100488. * Gets the current object class name.
  100489. * @return the class name
  100490. */
  100491. getClassName(): string;
  100492. }
  100493. }
  100494. declare module BABYLON {
  100495. /**
  100496. * This represents a FPS type of camera. This is only here for back compat purpose.
  100497. * Please use the UniversalCamera instead as both are identical.
  100498. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100499. */
  100500. export class GamepadCamera extends UniversalCamera {
  100501. /**
  100502. * Instantiates a new Gamepad Camera
  100503. * This represents a FPS type of camera. This is only here for back compat purpose.
  100504. * Please use the UniversalCamera instead as both are identical.
  100505. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100506. * @param name Define the name of the camera in the scene
  100507. * @param position Define the start position of the camera in the scene
  100508. * @param scene Define the scene the camera belongs to
  100509. */
  100510. constructor(name: string, position: Vector3, scene: Scene);
  100511. /**
  100512. * Gets the current object class name.
  100513. * @return the class name
  100514. */
  100515. getClassName(): string;
  100516. }
  100517. }
  100518. declare module BABYLON {
  100519. /** @hidden */
  100520. export var passPixelShader: {
  100521. name: string;
  100522. shader: string;
  100523. };
  100524. }
  100525. declare module BABYLON {
  100526. /** @hidden */
  100527. export var passCubePixelShader: {
  100528. name: string;
  100529. shader: string;
  100530. };
  100531. }
  100532. declare module BABYLON {
  100533. /**
  100534. * PassPostProcess which produces an output the same as it's input
  100535. */
  100536. export class PassPostProcess extends PostProcess {
  100537. /**
  100538. * Creates the PassPostProcess
  100539. * @param name The name of the effect.
  100540. * @param options The required width/height ratio to downsize to before computing the render pass.
  100541. * @param camera The camera to apply the render pass to.
  100542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100543. * @param engine The engine which the post process will be applied. (default: current engine)
  100544. * @param reusable If the post process can be reused on the same frame. (default: false)
  100545. * @param textureType The type of texture to be used when performing the post processing.
  100546. * @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)
  100547. */
  100548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100549. }
  100550. /**
  100551. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100552. */
  100553. export class PassCubePostProcess extends PostProcess {
  100554. private _face;
  100555. /**
  100556. * Gets or sets the cube face to display.
  100557. * * 0 is +X
  100558. * * 1 is -X
  100559. * * 2 is +Y
  100560. * * 3 is -Y
  100561. * * 4 is +Z
  100562. * * 5 is -Z
  100563. */
  100564. face: number;
  100565. /**
  100566. * Creates the PassCubePostProcess
  100567. * @param name The name of the effect.
  100568. * @param options The required width/height ratio to downsize to before computing the render pass.
  100569. * @param camera The camera to apply the render pass to.
  100570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100571. * @param engine The engine which the post process will be applied. (default: current engine)
  100572. * @param reusable If the post process can be reused on the same frame. (default: false)
  100573. * @param textureType The type of texture to be used when performing the post processing.
  100574. * @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)
  100575. */
  100576. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100577. }
  100578. }
  100579. declare module BABYLON {
  100580. /** @hidden */
  100581. export var anaglyphPixelShader: {
  100582. name: string;
  100583. shader: string;
  100584. };
  100585. }
  100586. declare module BABYLON {
  100587. /**
  100588. * Postprocess used to generate anaglyphic rendering
  100589. */
  100590. export class AnaglyphPostProcess extends PostProcess {
  100591. private _passedProcess;
  100592. /**
  100593. * Creates a new AnaglyphPostProcess
  100594. * @param name defines postprocess name
  100595. * @param options defines creation options or target ratio scale
  100596. * @param rigCameras defines cameras using this postprocess
  100597. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100598. * @param engine defines hosting engine
  100599. * @param reusable defines if the postprocess will be reused multiple times per frame
  100600. */
  100601. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100602. }
  100603. }
  100604. declare module BABYLON {
  100605. /**
  100606. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100607. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100608. */
  100609. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100610. /**
  100611. * Creates a new AnaglyphArcRotateCamera
  100612. * @param name defines camera name
  100613. * @param alpha defines alpha angle (in radians)
  100614. * @param beta defines beta angle (in radians)
  100615. * @param radius defines radius
  100616. * @param target defines camera target
  100617. * @param interaxialDistance defines distance between each color axis
  100618. * @param scene defines the hosting scene
  100619. */
  100620. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100621. /**
  100622. * Gets camera class name
  100623. * @returns AnaglyphArcRotateCamera
  100624. */
  100625. getClassName(): string;
  100626. }
  100627. }
  100628. declare module BABYLON {
  100629. /**
  100630. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100631. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100632. */
  100633. export class AnaglyphFreeCamera extends FreeCamera {
  100634. /**
  100635. * Creates a new AnaglyphFreeCamera
  100636. * @param name defines camera name
  100637. * @param position defines initial position
  100638. * @param interaxialDistance defines distance between each color axis
  100639. * @param scene defines the hosting scene
  100640. */
  100641. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100642. /**
  100643. * Gets camera class name
  100644. * @returns AnaglyphFreeCamera
  100645. */
  100646. getClassName(): string;
  100647. }
  100648. }
  100649. declare module BABYLON {
  100650. /**
  100651. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100652. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100653. */
  100654. export class AnaglyphGamepadCamera extends GamepadCamera {
  100655. /**
  100656. * Creates a new AnaglyphGamepadCamera
  100657. * @param name defines camera name
  100658. * @param position defines initial position
  100659. * @param interaxialDistance defines distance between each color axis
  100660. * @param scene defines the hosting scene
  100661. */
  100662. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100663. /**
  100664. * Gets camera class name
  100665. * @returns AnaglyphGamepadCamera
  100666. */
  100667. getClassName(): string;
  100668. }
  100669. }
  100670. declare module BABYLON {
  100671. /**
  100672. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100673. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100674. */
  100675. export class AnaglyphUniversalCamera extends UniversalCamera {
  100676. /**
  100677. * Creates a new AnaglyphUniversalCamera
  100678. * @param name defines camera name
  100679. * @param position defines initial position
  100680. * @param interaxialDistance defines distance between each color axis
  100681. * @param scene defines the hosting scene
  100682. */
  100683. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100684. /**
  100685. * Gets camera class name
  100686. * @returns AnaglyphUniversalCamera
  100687. */
  100688. getClassName(): string;
  100689. }
  100690. }
  100691. declare module BABYLON {
  100692. /** @hidden */
  100693. export var stereoscopicInterlacePixelShader: {
  100694. name: string;
  100695. shader: string;
  100696. };
  100697. }
  100698. declare module BABYLON {
  100699. /**
  100700. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100701. */
  100702. export class StereoscopicInterlacePostProcess extends PostProcess {
  100703. private _stepSize;
  100704. private _passedProcess;
  100705. /**
  100706. * Initializes a StereoscopicInterlacePostProcess
  100707. * @param name The name of the effect.
  100708. * @param rigCameras The rig cameras to be appled to the post process
  100709. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100711. * @param engine The engine which the post process will be applied. (default: current engine)
  100712. * @param reusable If the post process can be reused on the same frame. (default: false)
  100713. */
  100714. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100715. }
  100716. }
  100717. declare module BABYLON {
  100718. /**
  100719. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100720. * @see http://doc.babylonjs.com/features/cameras
  100721. */
  100722. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100723. /**
  100724. * Creates a new StereoscopicArcRotateCamera
  100725. * @param name defines camera name
  100726. * @param alpha defines alpha angle (in radians)
  100727. * @param beta defines beta angle (in radians)
  100728. * @param radius defines radius
  100729. * @param target defines camera target
  100730. * @param interaxialDistance defines distance between each color axis
  100731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100732. * @param scene defines the hosting scene
  100733. */
  100734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100735. /**
  100736. * Gets camera class name
  100737. * @returns StereoscopicArcRotateCamera
  100738. */
  100739. getClassName(): string;
  100740. }
  100741. }
  100742. declare module BABYLON {
  100743. /**
  100744. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100745. * @see http://doc.babylonjs.com/features/cameras
  100746. */
  100747. export class StereoscopicFreeCamera extends FreeCamera {
  100748. /**
  100749. * Creates a new StereoscopicFreeCamera
  100750. * @param name defines camera name
  100751. * @param position defines initial position
  100752. * @param interaxialDistance defines distance between each color axis
  100753. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100754. * @param scene defines the hosting scene
  100755. */
  100756. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100757. /**
  100758. * Gets camera class name
  100759. * @returns StereoscopicFreeCamera
  100760. */
  100761. getClassName(): string;
  100762. }
  100763. }
  100764. declare module BABYLON {
  100765. /**
  100766. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100767. * @see http://doc.babylonjs.com/features/cameras
  100768. */
  100769. export class StereoscopicGamepadCamera extends GamepadCamera {
  100770. /**
  100771. * Creates a new StereoscopicGamepadCamera
  100772. * @param name defines camera name
  100773. * @param position defines initial position
  100774. * @param interaxialDistance defines distance between each color axis
  100775. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100776. * @param scene defines the hosting scene
  100777. */
  100778. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100779. /**
  100780. * Gets camera class name
  100781. * @returns StereoscopicGamepadCamera
  100782. */
  100783. getClassName(): string;
  100784. }
  100785. }
  100786. declare module BABYLON {
  100787. /**
  100788. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100789. * @see http://doc.babylonjs.com/features/cameras
  100790. */
  100791. export class StereoscopicUniversalCamera extends UniversalCamera {
  100792. /**
  100793. * Creates a new StereoscopicUniversalCamera
  100794. * @param name defines camera name
  100795. * @param position defines initial position
  100796. * @param interaxialDistance defines distance between each color axis
  100797. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100798. * @param scene defines the hosting scene
  100799. */
  100800. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100801. /**
  100802. * Gets camera class name
  100803. * @returns StereoscopicUniversalCamera
  100804. */
  100805. getClassName(): string;
  100806. }
  100807. }
  100808. declare module BABYLON {
  100809. /**
  100810. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100811. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100812. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100813. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100814. */
  100815. export class VirtualJoysticksCamera extends FreeCamera {
  100816. /**
  100817. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  100818. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100819. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100820. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100821. * @param name Define the name of the camera in the scene
  100822. * @param position Define the start position of the camera in the scene
  100823. * @param scene Define the scene the camera belongs to
  100824. */
  100825. constructor(name: string, position: Vector3, scene: Scene);
  100826. /**
  100827. * Gets the current object class name.
  100828. * @return the class name
  100829. */
  100830. getClassName(): string;
  100831. }
  100832. }
  100833. declare module BABYLON {
  100834. /**
  100835. * This represents all the required metrics to create a VR camera.
  100836. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  100837. */
  100838. export class VRCameraMetrics {
  100839. /**
  100840. * Define the horizontal resolution off the screen.
  100841. */
  100842. hResolution: number;
  100843. /**
  100844. * Define the vertical resolution off the screen.
  100845. */
  100846. vResolution: number;
  100847. /**
  100848. * Define the horizontal screen size.
  100849. */
  100850. hScreenSize: number;
  100851. /**
  100852. * Define the vertical screen size.
  100853. */
  100854. vScreenSize: number;
  100855. /**
  100856. * Define the vertical screen center position.
  100857. */
  100858. vScreenCenter: number;
  100859. /**
  100860. * Define the distance of the eyes to the screen.
  100861. */
  100862. eyeToScreenDistance: number;
  100863. /**
  100864. * Define the distance between both lenses
  100865. */
  100866. lensSeparationDistance: number;
  100867. /**
  100868. * Define the distance between both viewer's eyes.
  100869. */
  100870. interpupillaryDistance: number;
  100871. /**
  100872. * Define the distortion factor of the VR postprocess.
  100873. * Please, touch with care.
  100874. */
  100875. distortionK: number[];
  100876. /**
  100877. * Define the chromatic aberration correction factors for the VR post process.
  100878. */
  100879. chromaAbCorrection: number[];
  100880. /**
  100881. * Define the scale factor of the post process.
  100882. * The smaller the better but the slower.
  100883. */
  100884. postProcessScaleFactor: number;
  100885. /**
  100886. * Define an offset for the lens center.
  100887. */
  100888. lensCenterOffset: number;
  100889. /**
  100890. * Define if the current vr camera should compensate the distortion of the lense or not.
  100891. */
  100892. compensateDistortion: boolean;
  100893. /**
  100894. * Defines if multiview should be enabled when rendering (Default: false)
  100895. */
  100896. multiviewEnabled: boolean;
  100897. /**
  100898. * Gets the rendering aspect ratio based on the provided resolutions.
  100899. */
  100900. readonly aspectRatio: number;
  100901. /**
  100902. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  100903. */
  100904. readonly aspectRatioFov: number;
  100905. /**
  100906. * @hidden
  100907. */
  100908. readonly leftHMatrix: Matrix;
  100909. /**
  100910. * @hidden
  100911. */
  100912. readonly rightHMatrix: Matrix;
  100913. /**
  100914. * @hidden
  100915. */
  100916. readonly leftPreViewMatrix: Matrix;
  100917. /**
  100918. * @hidden
  100919. */
  100920. readonly rightPreViewMatrix: Matrix;
  100921. /**
  100922. * Get the default VRMetrics based on the most generic setup.
  100923. * @returns the default vr metrics
  100924. */
  100925. static GetDefault(): VRCameraMetrics;
  100926. }
  100927. }
  100928. declare module BABYLON {
  100929. /** @hidden */
  100930. export var vrDistortionCorrectionPixelShader: {
  100931. name: string;
  100932. shader: string;
  100933. };
  100934. }
  100935. declare module BABYLON {
  100936. /**
  100937. * VRDistortionCorrectionPostProcess used for mobile VR
  100938. */
  100939. export class VRDistortionCorrectionPostProcess extends PostProcess {
  100940. private _isRightEye;
  100941. private _distortionFactors;
  100942. private _postProcessScaleFactor;
  100943. private _lensCenterOffset;
  100944. private _scaleIn;
  100945. private _scaleFactor;
  100946. private _lensCenter;
  100947. /**
  100948. * Initializes the VRDistortionCorrectionPostProcess
  100949. * @param name The name of the effect.
  100950. * @param camera The camera to apply the render pass to.
  100951. * @param isRightEye If this is for the right eye distortion
  100952. * @param vrMetrics All the required metrics for the VR camera
  100953. */
  100954. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  100955. }
  100956. }
  100957. declare module BABYLON {
  100958. /**
  100959. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  100960. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100961. */
  100962. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  100963. /**
  100964. * Creates a new VRDeviceOrientationArcRotateCamera
  100965. * @param name defines camera name
  100966. * @param alpha defines the camera rotation along the logitudinal axis
  100967. * @param beta defines the camera rotation along the latitudinal axis
  100968. * @param radius defines the camera distance from its target
  100969. * @param target defines the camera target
  100970. * @param scene defines the scene the camera belongs to
  100971. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100972. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100973. */
  100974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100975. /**
  100976. * Gets camera class name
  100977. * @returns VRDeviceOrientationArcRotateCamera
  100978. */
  100979. getClassName(): string;
  100980. }
  100981. }
  100982. declare module BABYLON {
  100983. /**
  100984. * Camera used to simulate VR rendering (based on FreeCamera)
  100985. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100986. */
  100987. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  100988. /**
  100989. * Creates a new VRDeviceOrientationFreeCamera
  100990. * @param name defines camera name
  100991. * @param position defines the start position of the camera
  100992. * @param scene defines the scene the camera belongs to
  100993. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100994. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100995. */
  100996. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100997. /**
  100998. * Gets camera class name
  100999. * @returns VRDeviceOrientationFreeCamera
  101000. */
  101001. getClassName(): string;
  101002. }
  101003. }
  101004. declare module BABYLON {
  101005. /**
  101006. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101007. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101008. */
  101009. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101010. /**
  101011. * Creates a new VRDeviceOrientationGamepadCamera
  101012. * @param name defines camera name
  101013. * @param position defines the start position of the camera
  101014. * @param scene defines the scene the camera belongs to
  101015. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101016. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101017. */
  101018. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101019. /**
  101020. * Gets camera class name
  101021. * @returns VRDeviceOrientationGamepadCamera
  101022. */
  101023. getClassName(): string;
  101024. }
  101025. }
  101026. declare module BABYLON {
  101027. /**
  101028. * Base class of materials working in push mode in babylon JS
  101029. * @hidden
  101030. */
  101031. export class PushMaterial extends Material {
  101032. protected _activeEffect: Effect;
  101033. protected _normalMatrix: Matrix;
  101034. /**
  101035. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101036. * This means that the material can keep using a previous shader while a new one is being compiled.
  101037. * This is mostly used when shader parallel compilation is supported (true by default)
  101038. */
  101039. allowShaderHotSwapping: boolean;
  101040. constructor(name: string, scene: Scene);
  101041. getEffect(): Effect;
  101042. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101043. /**
  101044. * Binds the given world matrix to the active effect
  101045. *
  101046. * @param world the matrix to bind
  101047. */
  101048. bindOnlyWorldMatrix(world: Matrix): void;
  101049. /**
  101050. * Binds the given normal matrix to the active effect
  101051. *
  101052. * @param normalMatrix the matrix to bind
  101053. */
  101054. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101055. bind(world: Matrix, mesh?: Mesh): void;
  101056. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101057. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101058. }
  101059. }
  101060. declare module BABYLON {
  101061. /**
  101062. * This groups all the flags used to control the materials channel.
  101063. */
  101064. export class MaterialFlags {
  101065. private static _DiffuseTextureEnabled;
  101066. /**
  101067. * Are diffuse textures enabled in the application.
  101068. */
  101069. static DiffuseTextureEnabled: boolean;
  101070. private static _AmbientTextureEnabled;
  101071. /**
  101072. * Are ambient textures enabled in the application.
  101073. */
  101074. static AmbientTextureEnabled: boolean;
  101075. private static _OpacityTextureEnabled;
  101076. /**
  101077. * Are opacity textures enabled in the application.
  101078. */
  101079. static OpacityTextureEnabled: boolean;
  101080. private static _ReflectionTextureEnabled;
  101081. /**
  101082. * Are reflection textures enabled in the application.
  101083. */
  101084. static ReflectionTextureEnabled: boolean;
  101085. private static _EmissiveTextureEnabled;
  101086. /**
  101087. * Are emissive textures enabled in the application.
  101088. */
  101089. static EmissiveTextureEnabled: boolean;
  101090. private static _SpecularTextureEnabled;
  101091. /**
  101092. * Are specular textures enabled in the application.
  101093. */
  101094. static SpecularTextureEnabled: boolean;
  101095. private static _BumpTextureEnabled;
  101096. /**
  101097. * Are bump textures enabled in the application.
  101098. */
  101099. static BumpTextureEnabled: boolean;
  101100. private static _LightmapTextureEnabled;
  101101. /**
  101102. * Are lightmap textures enabled in the application.
  101103. */
  101104. static LightmapTextureEnabled: boolean;
  101105. private static _RefractionTextureEnabled;
  101106. /**
  101107. * Are refraction textures enabled in the application.
  101108. */
  101109. static RefractionTextureEnabled: boolean;
  101110. private static _ColorGradingTextureEnabled;
  101111. /**
  101112. * Are color grading textures enabled in the application.
  101113. */
  101114. static ColorGradingTextureEnabled: boolean;
  101115. private static _FresnelEnabled;
  101116. /**
  101117. * Are fresnels enabled in the application.
  101118. */
  101119. static FresnelEnabled: boolean;
  101120. private static _ClearCoatTextureEnabled;
  101121. /**
  101122. * Are clear coat textures enabled in the application.
  101123. */
  101124. static ClearCoatTextureEnabled: boolean;
  101125. private static _ClearCoatBumpTextureEnabled;
  101126. /**
  101127. * Are clear coat bump textures enabled in the application.
  101128. */
  101129. static ClearCoatBumpTextureEnabled: boolean;
  101130. private static _ClearCoatTintTextureEnabled;
  101131. /**
  101132. * Are clear coat tint textures enabled in the application.
  101133. */
  101134. static ClearCoatTintTextureEnabled: boolean;
  101135. private static _SheenTextureEnabled;
  101136. /**
  101137. * Are sheen textures enabled in the application.
  101138. */
  101139. static SheenTextureEnabled: boolean;
  101140. private static _AnisotropicTextureEnabled;
  101141. /**
  101142. * Are anisotropic textures enabled in the application.
  101143. */
  101144. static AnisotropicTextureEnabled: boolean;
  101145. private static _ThicknessTextureEnabled;
  101146. /**
  101147. * Are thickness textures enabled in the application.
  101148. */
  101149. static ThicknessTextureEnabled: boolean;
  101150. }
  101151. }
  101152. declare module BABYLON {
  101153. /** @hidden */
  101154. export var defaultFragmentDeclaration: {
  101155. name: string;
  101156. shader: string;
  101157. };
  101158. }
  101159. declare module BABYLON {
  101160. /** @hidden */
  101161. export var defaultUboDeclaration: {
  101162. name: string;
  101163. shader: string;
  101164. };
  101165. }
  101166. declare module BABYLON {
  101167. /** @hidden */
  101168. export var lightFragmentDeclaration: {
  101169. name: string;
  101170. shader: string;
  101171. };
  101172. }
  101173. declare module BABYLON {
  101174. /** @hidden */
  101175. export var lightUboDeclaration: {
  101176. name: string;
  101177. shader: string;
  101178. };
  101179. }
  101180. declare module BABYLON {
  101181. /** @hidden */
  101182. export var lightsFragmentFunctions: {
  101183. name: string;
  101184. shader: string;
  101185. };
  101186. }
  101187. declare module BABYLON {
  101188. /** @hidden */
  101189. export var shadowsFragmentFunctions: {
  101190. name: string;
  101191. shader: string;
  101192. };
  101193. }
  101194. declare module BABYLON {
  101195. /** @hidden */
  101196. export var fresnelFunction: {
  101197. name: string;
  101198. shader: string;
  101199. };
  101200. }
  101201. declare module BABYLON {
  101202. /** @hidden */
  101203. export var reflectionFunction: {
  101204. name: string;
  101205. shader: string;
  101206. };
  101207. }
  101208. declare module BABYLON {
  101209. /** @hidden */
  101210. export var bumpFragmentFunctions: {
  101211. name: string;
  101212. shader: string;
  101213. };
  101214. }
  101215. declare module BABYLON {
  101216. /** @hidden */
  101217. export var logDepthDeclaration: {
  101218. name: string;
  101219. shader: string;
  101220. };
  101221. }
  101222. declare module BABYLON {
  101223. /** @hidden */
  101224. export var bumpFragment: {
  101225. name: string;
  101226. shader: string;
  101227. };
  101228. }
  101229. declare module BABYLON {
  101230. /** @hidden */
  101231. export var depthPrePass: {
  101232. name: string;
  101233. shader: string;
  101234. };
  101235. }
  101236. declare module BABYLON {
  101237. /** @hidden */
  101238. export var lightFragment: {
  101239. name: string;
  101240. shader: string;
  101241. };
  101242. }
  101243. declare module BABYLON {
  101244. /** @hidden */
  101245. export var logDepthFragment: {
  101246. name: string;
  101247. shader: string;
  101248. };
  101249. }
  101250. declare module BABYLON {
  101251. /** @hidden */
  101252. export var defaultPixelShader: {
  101253. name: string;
  101254. shader: string;
  101255. };
  101256. }
  101257. declare module BABYLON {
  101258. /** @hidden */
  101259. export var defaultVertexDeclaration: {
  101260. name: string;
  101261. shader: string;
  101262. };
  101263. }
  101264. declare module BABYLON {
  101265. /** @hidden */
  101266. export var bumpVertexDeclaration: {
  101267. name: string;
  101268. shader: string;
  101269. };
  101270. }
  101271. declare module BABYLON {
  101272. /** @hidden */
  101273. export var bumpVertex: {
  101274. name: string;
  101275. shader: string;
  101276. };
  101277. }
  101278. declare module BABYLON {
  101279. /** @hidden */
  101280. export var fogVertex: {
  101281. name: string;
  101282. shader: string;
  101283. };
  101284. }
  101285. declare module BABYLON {
  101286. /** @hidden */
  101287. export var shadowsVertex: {
  101288. name: string;
  101289. shader: string;
  101290. };
  101291. }
  101292. declare module BABYLON {
  101293. /** @hidden */
  101294. export var pointCloudVertex: {
  101295. name: string;
  101296. shader: string;
  101297. };
  101298. }
  101299. declare module BABYLON {
  101300. /** @hidden */
  101301. export var logDepthVertex: {
  101302. name: string;
  101303. shader: string;
  101304. };
  101305. }
  101306. declare module BABYLON {
  101307. /** @hidden */
  101308. export var defaultVertexShader: {
  101309. name: string;
  101310. shader: string;
  101311. };
  101312. }
  101313. declare module BABYLON {
  101314. /** @hidden */
  101315. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101316. MAINUV1: boolean;
  101317. MAINUV2: boolean;
  101318. DIFFUSE: boolean;
  101319. DIFFUSEDIRECTUV: number;
  101320. AMBIENT: boolean;
  101321. AMBIENTDIRECTUV: number;
  101322. OPACITY: boolean;
  101323. OPACITYDIRECTUV: number;
  101324. OPACITYRGB: boolean;
  101325. REFLECTION: boolean;
  101326. EMISSIVE: boolean;
  101327. EMISSIVEDIRECTUV: number;
  101328. SPECULAR: boolean;
  101329. SPECULARDIRECTUV: number;
  101330. BUMP: boolean;
  101331. BUMPDIRECTUV: number;
  101332. PARALLAX: boolean;
  101333. PARALLAXOCCLUSION: boolean;
  101334. SPECULAROVERALPHA: boolean;
  101335. CLIPPLANE: boolean;
  101336. CLIPPLANE2: boolean;
  101337. CLIPPLANE3: boolean;
  101338. CLIPPLANE4: boolean;
  101339. ALPHATEST: boolean;
  101340. DEPTHPREPASS: boolean;
  101341. ALPHAFROMDIFFUSE: boolean;
  101342. POINTSIZE: boolean;
  101343. FOG: boolean;
  101344. SPECULARTERM: boolean;
  101345. DIFFUSEFRESNEL: boolean;
  101346. OPACITYFRESNEL: boolean;
  101347. REFLECTIONFRESNEL: boolean;
  101348. REFRACTIONFRESNEL: boolean;
  101349. EMISSIVEFRESNEL: boolean;
  101350. FRESNEL: boolean;
  101351. NORMAL: boolean;
  101352. UV1: boolean;
  101353. UV2: boolean;
  101354. VERTEXCOLOR: boolean;
  101355. VERTEXALPHA: boolean;
  101356. NUM_BONE_INFLUENCERS: number;
  101357. BonesPerMesh: number;
  101358. BONETEXTURE: boolean;
  101359. INSTANCES: boolean;
  101360. GLOSSINESS: boolean;
  101361. ROUGHNESS: boolean;
  101362. EMISSIVEASILLUMINATION: boolean;
  101363. LINKEMISSIVEWITHDIFFUSE: boolean;
  101364. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101365. LIGHTMAP: boolean;
  101366. LIGHTMAPDIRECTUV: number;
  101367. OBJECTSPACE_NORMALMAP: boolean;
  101368. USELIGHTMAPASSHADOWMAP: boolean;
  101369. REFLECTIONMAP_3D: boolean;
  101370. REFLECTIONMAP_SPHERICAL: boolean;
  101371. REFLECTIONMAP_PLANAR: boolean;
  101372. REFLECTIONMAP_CUBIC: boolean;
  101373. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101374. REFLECTIONMAP_PROJECTION: boolean;
  101375. REFLECTIONMAP_SKYBOX: boolean;
  101376. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101377. REFLECTIONMAP_EXPLICIT: boolean;
  101378. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101379. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101380. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101381. INVERTCUBICMAP: boolean;
  101382. LOGARITHMICDEPTH: boolean;
  101383. REFRACTION: boolean;
  101384. REFRACTIONMAP_3D: boolean;
  101385. REFLECTIONOVERALPHA: boolean;
  101386. TWOSIDEDLIGHTING: boolean;
  101387. SHADOWFLOAT: boolean;
  101388. MORPHTARGETS: boolean;
  101389. MORPHTARGETS_NORMAL: boolean;
  101390. MORPHTARGETS_TANGENT: boolean;
  101391. NUM_MORPH_INFLUENCERS: number;
  101392. NONUNIFORMSCALING: boolean;
  101393. PREMULTIPLYALPHA: boolean;
  101394. IMAGEPROCESSING: boolean;
  101395. VIGNETTE: boolean;
  101396. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101397. VIGNETTEBLENDMODEOPAQUE: boolean;
  101398. TONEMAPPING: boolean;
  101399. TONEMAPPING_ACES: boolean;
  101400. CONTRAST: boolean;
  101401. COLORCURVES: boolean;
  101402. COLORGRADING: boolean;
  101403. COLORGRADING3D: boolean;
  101404. SAMPLER3DGREENDEPTH: boolean;
  101405. SAMPLER3DBGRMAP: boolean;
  101406. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101407. MULTIVIEW: boolean;
  101408. /**
  101409. * If the reflection texture on this material is in linear color space
  101410. * @hidden
  101411. */
  101412. IS_REFLECTION_LINEAR: boolean;
  101413. /**
  101414. * If the refraction texture on this material is in linear color space
  101415. * @hidden
  101416. */
  101417. IS_REFRACTION_LINEAR: boolean;
  101418. EXPOSURE: boolean;
  101419. constructor();
  101420. setReflectionMode(modeToEnable: string): void;
  101421. }
  101422. /**
  101423. * This is the default material used in Babylon. It is the best trade off between quality
  101424. * and performances.
  101425. * @see http://doc.babylonjs.com/babylon101/materials
  101426. */
  101427. export class StandardMaterial extends PushMaterial {
  101428. private _diffuseTexture;
  101429. /**
  101430. * The basic texture of the material as viewed under a light.
  101431. */
  101432. diffuseTexture: Nullable<BaseTexture>;
  101433. private _ambientTexture;
  101434. /**
  101435. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101436. */
  101437. ambientTexture: Nullable<BaseTexture>;
  101438. private _opacityTexture;
  101439. /**
  101440. * Define the transparency of the material from a texture.
  101441. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101442. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101443. */
  101444. opacityTexture: Nullable<BaseTexture>;
  101445. private _reflectionTexture;
  101446. /**
  101447. * Define the texture used to display the reflection.
  101448. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101449. */
  101450. reflectionTexture: Nullable<BaseTexture>;
  101451. private _emissiveTexture;
  101452. /**
  101453. * Define texture of the material as if self lit.
  101454. * This will be mixed in the final result even in the absence of light.
  101455. */
  101456. emissiveTexture: Nullable<BaseTexture>;
  101457. private _specularTexture;
  101458. /**
  101459. * Define how the color and intensity of the highlight given by the light in the material.
  101460. */
  101461. specularTexture: Nullable<BaseTexture>;
  101462. private _bumpTexture;
  101463. /**
  101464. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101465. * 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.
  101466. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101467. */
  101468. bumpTexture: Nullable<BaseTexture>;
  101469. private _lightmapTexture;
  101470. /**
  101471. * Complex lighting can be computationally expensive to compute at runtime.
  101472. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101473. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101474. */
  101475. lightmapTexture: Nullable<BaseTexture>;
  101476. private _refractionTexture;
  101477. /**
  101478. * Define the texture used to display the refraction.
  101479. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101480. */
  101481. refractionTexture: Nullable<BaseTexture>;
  101482. /**
  101483. * The color of the material lit by the environmental background lighting.
  101484. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101485. */
  101486. ambientColor: Color3;
  101487. /**
  101488. * The basic color of the material as viewed under a light.
  101489. */
  101490. diffuseColor: Color3;
  101491. /**
  101492. * Define how the color and intensity of the highlight given by the light in the material.
  101493. */
  101494. specularColor: Color3;
  101495. /**
  101496. * Define the color of the material as if self lit.
  101497. * This will be mixed in the final result even in the absence of light.
  101498. */
  101499. emissiveColor: Color3;
  101500. /**
  101501. * Defines how sharp are the highlights in the material.
  101502. * The bigger the value the sharper giving a more glossy feeling to the result.
  101503. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101504. */
  101505. specularPower: number;
  101506. private _useAlphaFromDiffuseTexture;
  101507. /**
  101508. * Does the transparency come from the diffuse texture alpha channel.
  101509. */
  101510. useAlphaFromDiffuseTexture: boolean;
  101511. private _useEmissiveAsIllumination;
  101512. /**
  101513. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101514. */
  101515. useEmissiveAsIllumination: boolean;
  101516. private _linkEmissiveWithDiffuse;
  101517. /**
  101518. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101519. * the emissive level when the final color is close to one.
  101520. */
  101521. linkEmissiveWithDiffuse: boolean;
  101522. private _useSpecularOverAlpha;
  101523. /**
  101524. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101525. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101526. */
  101527. useSpecularOverAlpha: boolean;
  101528. private _useReflectionOverAlpha;
  101529. /**
  101530. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101531. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101532. */
  101533. useReflectionOverAlpha: boolean;
  101534. private _disableLighting;
  101535. /**
  101536. * Does lights from the scene impacts this material.
  101537. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101538. */
  101539. disableLighting: boolean;
  101540. private _useObjectSpaceNormalMap;
  101541. /**
  101542. * Allows using an object space normal map (instead of tangent space).
  101543. */
  101544. useObjectSpaceNormalMap: boolean;
  101545. private _useParallax;
  101546. /**
  101547. * Is parallax enabled or not.
  101548. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101549. */
  101550. useParallax: boolean;
  101551. private _useParallaxOcclusion;
  101552. /**
  101553. * Is parallax occlusion enabled or not.
  101554. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101555. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101556. */
  101557. useParallaxOcclusion: boolean;
  101558. /**
  101559. * 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.
  101560. */
  101561. parallaxScaleBias: number;
  101562. private _roughness;
  101563. /**
  101564. * Helps to define how blurry the reflections should appears in the material.
  101565. */
  101566. roughness: number;
  101567. /**
  101568. * In case of refraction, define the value of the indice of refraction.
  101569. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101570. */
  101571. indexOfRefraction: number;
  101572. /**
  101573. * Invert the refraction texture alongside the y axis.
  101574. * It can be useful with procedural textures or probe for instance.
  101575. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101576. */
  101577. invertRefractionY: boolean;
  101578. /**
  101579. * Defines the alpha limits in alpha test mode.
  101580. */
  101581. alphaCutOff: number;
  101582. private _useLightmapAsShadowmap;
  101583. /**
  101584. * In case of light mapping, define whether the map contains light or shadow informations.
  101585. */
  101586. useLightmapAsShadowmap: boolean;
  101587. private _diffuseFresnelParameters;
  101588. /**
  101589. * Define the diffuse fresnel parameters of the material.
  101590. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101591. */
  101592. diffuseFresnelParameters: FresnelParameters;
  101593. private _opacityFresnelParameters;
  101594. /**
  101595. * Define the opacity fresnel parameters of the material.
  101596. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101597. */
  101598. opacityFresnelParameters: FresnelParameters;
  101599. private _reflectionFresnelParameters;
  101600. /**
  101601. * Define the reflection fresnel parameters of the material.
  101602. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101603. */
  101604. reflectionFresnelParameters: FresnelParameters;
  101605. private _refractionFresnelParameters;
  101606. /**
  101607. * Define the refraction fresnel parameters of the material.
  101608. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101609. */
  101610. refractionFresnelParameters: FresnelParameters;
  101611. private _emissiveFresnelParameters;
  101612. /**
  101613. * Define the emissive fresnel parameters of the material.
  101614. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101615. */
  101616. emissiveFresnelParameters: FresnelParameters;
  101617. private _useReflectionFresnelFromSpecular;
  101618. /**
  101619. * If true automatically deducts the fresnels values from the material specularity.
  101620. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101621. */
  101622. useReflectionFresnelFromSpecular: boolean;
  101623. private _useGlossinessFromSpecularMapAlpha;
  101624. /**
  101625. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101626. */
  101627. useGlossinessFromSpecularMapAlpha: boolean;
  101628. private _maxSimultaneousLights;
  101629. /**
  101630. * Defines the maximum number of lights that can be used in the material
  101631. */
  101632. maxSimultaneousLights: number;
  101633. private _invertNormalMapX;
  101634. /**
  101635. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101636. */
  101637. invertNormalMapX: boolean;
  101638. private _invertNormalMapY;
  101639. /**
  101640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101641. */
  101642. invertNormalMapY: boolean;
  101643. private _twoSidedLighting;
  101644. /**
  101645. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101646. */
  101647. twoSidedLighting: boolean;
  101648. /**
  101649. * Default configuration related to image processing available in the standard Material.
  101650. */
  101651. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101652. /**
  101653. * Gets the image processing configuration used either in this material.
  101654. */
  101655. /**
  101656. * Sets the Default image processing configuration used either in the this material.
  101657. *
  101658. * If sets to null, the scene one is in use.
  101659. */
  101660. imageProcessingConfiguration: ImageProcessingConfiguration;
  101661. /**
  101662. * Keep track of the image processing observer to allow dispose and replace.
  101663. */
  101664. private _imageProcessingObserver;
  101665. /**
  101666. * Attaches a new image processing configuration to the Standard Material.
  101667. * @param configuration
  101668. */
  101669. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101670. /**
  101671. * Gets wether the color curves effect is enabled.
  101672. */
  101673. /**
  101674. * Sets wether the color curves effect is enabled.
  101675. */
  101676. cameraColorCurvesEnabled: boolean;
  101677. /**
  101678. * Gets wether the color grading effect is enabled.
  101679. */
  101680. /**
  101681. * Gets wether the color grading effect is enabled.
  101682. */
  101683. cameraColorGradingEnabled: boolean;
  101684. /**
  101685. * Gets wether tonemapping is enabled or not.
  101686. */
  101687. /**
  101688. * Sets wether tonemapping is enabled or not
  101689. */
  101690. cameraToneMappingEnabled: boolean;
  101691. /**
  101692. * The camera exposure used on this material.
  101693. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101694. * This corresponds to a photographic exposure.
  101695. */
  101696. /**
  101697. * The camera exposure used on this material.
  101698. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101699. * This corresponds to a photographic exposure.
  101700. */
  101701. cameraExposure: number;
  101702. /**
  101703. * Gets The camera contrast used on this material.
  101704. */
  101705. /**
  101706. * Sets The camera contrast used on this material.
  101707. */
  101708. cameraContrast: number;
  101709. /**
  101710. * Gets the Color Grading 2D Lookup Texture.
  101711. */
  101712. /**
  101713. * Sets the Color Grading 2D Lookup Texture.
  101714. */
  101715. cameraColorGradingTexture: Nullable<BaseTexture>;
  101716. /**
  101717. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101718. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101719. * 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;
  101720. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101721. */
  101722. /**
  101723. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101724. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101725. * 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;
  101726. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101727. */
  101728. cameraColorCurves: Nullable<ColorCurves>;
  101729. /**
  101730. * Custom callback helping to override the default shader used in the material.
  101731. */
  101732. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101733. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101734. protected _worldViewProjectionMatrix: Matrix;
  101735. protected _globalAmbientColor: Color3;
  101736. protected _useLogarithmicDepth: boolean;
  101737. /**
  101738. * Instantiates a new standard material.
  101739. * This is the default material used in Babylon. It is the best trade off between quality
  101740. * and performances.
  101741. * @see http://doc.babylonjs.com/babylon101/materials
  101742. * @param name Define the name of the material in the scene
  101743. * @param scene Define the scene the material belong to
  101744. */
  101745. constructor(name: string, scene: Scene);
  101746. /**
  101747. * Gets a boolean indicating that current material needs to register RTT
  101748. */
  101749. readonly hasRenderTargetTextures: boolean;
  101750. /**
  101751. * Gets the current class name of the material e.g. "StandardMaterial"
  101752. * Mainly use in serialization.
  101753. * @returns the class name
  101754. */
  101755. getClassName(): string;
  101756. /**
  101757. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101758. * You can try switching to logarithmic depth.
  101759. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101760. */
  101761. useLogarithmicDepth: boolean;
  101762. /**
  101763. * Specifies if the material will require alpha blending
  101764. * @returns a boolean specifying if alpha blending is needed
  101765. */
  101766. needAlphaBlending(): boolean;
  101767. /**
  101768. * Specifies if this material should be rendered in alpha test mode
  101769. * @returns a boolean specifying if an alpha test is needed.
  101770. */
  101771. needAlphaTesting(): boolean;
  101772. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101773. /**
  101774. * Get the texture used for alpha test purpose.
  101775. * @returns the diffuse texture in case of the standard material.
  101776. */
  101777. getAlphaTestTexture(): Nullable<BaseTexture>;
  101778. /**
  101779. * Get if the submesh is ready to be used and all its information available.
  101780. * Child classes can use it to update shaders
  101781. * @param mesh defines the mesh to check
  101782. * @param subMesh defines which submesh to check
  101783. * @param useInstances specifies that instances should be used
  101784. * @returns a boolean indicating that the submesh is ready or not
  101785. */
  101786. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101787. /**
  101788. * Builds the material UBO layouts.
  101789. * Used internally during the effect preparation.
  101790. */
  101791. buildUniformLayout(): void;
  101792. /**
  101793. * Unbinds the material from the mesh
  101794. */
  101795. unbind(): void;
  101796. /**
  101797. * Binds the submesh to this material by preparing the effect and shader to draw
  101798. * @param world defines the world transformation matrix
  101799. * @param mesh defines the mesh containing the submesh
  101800. * @param subMesh defines the submesh to bind the material to
  101801. */
  101802. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101803. /**
  101804. * Get the list of animatables in the material.
  101805. * @returns the list of animatables object used in the material
  101806. */
  101807. getAnimatables(): IAnimatable[];
  101808. /**
  101809. * Gets the active textures from the material
  101810. * @returns an array of textures
  101811. */
  101812. getActiveTextures(): BaseTexture[];
  101813. /**
  101814. * Specifies if the material uses a texture
  101815. * @param texture defines the texture to check against the material
  101816. * @returns a boolean specifying if the material uses the texture
  101817. */
  101818. hasTexture(texture: BaseTexture): boolean;
  101819. /**
  101820. * Disposes the material
  101821. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101822. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101823. */
  101824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101825. /**
  101826. * Makes a duplicate of the material, and gives it a new name
  101827. * @param name defines the new name for the duplicated material
  101828. * @returns the cloned material
  101829. */
  101830. clone(name: string): StandardMaterial;
  101831. /**
  101832. * Serializes this material in a JSON representation
  101833. * @returns the serialized material object
  101834. */
  101835. serialize(): any;
  101836. /**
  101837. * Creates a standard material from parsed material data
  101838. * @param source defines the JSON representation of the material
  101839. * @param scene defines the hosting scene
  101840. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101841. * @returns a new standard material
  101842. */
  101843. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101844. /**
  101845. * Are diffuse textures enabled in the application.
  101846. */
  101847. static DiffuseTextureEnabled: boolean;
  101848. /**
  101849. * Are ambient textures enabled in the application.
  101850. */
  101851. static AmbientTextureEnabled: boolean;
  101852. /**
  101853. * Are opacity textures enabled in the application.
  101854. */
  101855. static OpacityTextureEnabled: boolean;
  101856. /**
  101857. * Are reflection textures enabled in the application.
  101858. */
  101859. static ReflectionTextureEnabled: boolean;
  101860. /**
  101861. * Are emissive textures enabled in the application.
  101862. */
  101863. static EmissiveTextureEnabled: boolean;
  101864. /**
  101865. * Are specular textures enabled in the application.
  101866. */
  101867. static SpecularTextureEnabled: boolean;
  101868. /**
  101869. * Are bump textures enabled in the application.
  101870. */
  101871. static BumpTextureEnabled: boolean;
  101872. /**
  101873. * Are lightmap textures enabled in the application.
  101874. */
  101875. static LightmapTextureEnabled: boolean;
  101876. /**
  101877. * Are refraction textures enabled in the application.
  101878. */
  101879. static RefractionTextureEnabled: boolean;
  101880. /**
  101881. * Are color grading textures enabled in the application.
  101882. */
  101883. static ColorGradingTextureEnabled: boolean;
  101884. /**
  101885. * Are fresnels enabled in the application.
  101886. */
  101887. static FresnelEnabled: boolean;
  101888. }
  101889. }
  101890. declare module BABYLON {
  101891. /**
  101892. * A class extending Texture allowing drawing on a texture
  101893. * @see http://doc.babylonjs.com/how_to/dynamictexture
  101894. */
  101895. export class DynamicTexture extends Texture {
  101896. private _generateMipMaps;
  101897. private _canvas;
  101898. private _context;
  101899. private _engine;
  101900. /**
  101901. * Creates a DynamicTexture
  101902. * @param name defines the name of the texture
  101903. * @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
  101904. * @param scene defines the scene where you want the texture
  101905. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  101906. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  101907. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  101908. */
  101909. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  101910. /**
  101911. * Get the current class name of the texture useful for serialization or dynamic coding.
  101912. * @returns "DynamicTexture"
  101913. */
  101914. getClassName(): string;
  101915. /**
  101916. * Gets the current state of canRescale
  101917. */
  101918. readonly canRescale: boolean;
  101919. private _recreate;
  101920. /**
  101921. * Scales the texture
  101922. * @param ratio the scale factor to apply to both width and height
  101923. */
  101924. scale(ratio: number): void;
  101925. /**
  101926. * Resizes the texture
  101927. * @param width the new width
  101928. * @param height the new height
  101929. */
  101930. scaleTo(width: number, height: number): void;
  101931. /**
  101932. * Gets the context of the canvas used by the texture
  101933. * @returns the canvas context of the dynamic texture
  101934. */
  101935. getContext(): CanvasRenderingContext2D;
  101936. /**
  101937. * Clears the texture
  101938. */
  101939. clear(): void;
  101940. /**
  101941. * Updates the texture
  101942. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101943. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  101944. */
  101945. update(invertY?: boolean, premulAlpha?: boolean): void;
  101946. /**
  101947. * Draws text onto the texture
  101948. * @param text defines the text to be drawn
  101949. * @param x defines the placement of the text from the left
  101950. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  101951. * @param font defines the font to be used with font-style, font-size, font-name
  101952. * @param color defines the color used for the text
  101953. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  101954. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101955. * @param update defines whether texture is immediately update (default is true)
  101956. */
  101957. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  101958. /**
  101959. * Clones the texture
  101960. * @returns the clone of the texture.
  101961. */
  101962. clone(): DynamicTexture;
  101963. /**
  101964. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  101965. * @returns a serialized dynamic texture object
  101966. */
  101967. serialize(): any;
  101968. /** @hidden */
  101969. _rebuild(): void;
  101970. }
  101971. }
  101972. declare module BABYLON {
  101973. /** @hidden */
  101974. export var imageProcessingPixelShader: {
  101975. name: string;
  101976. shader: string;
  101977. };
  101978. }
  101979. declare module BABYLON {
  101980. /**
  101981. * ImageProcessingPostProcess
  101982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  101983. */
  101984. export class ImageProcessingPostProcess extends PostProcess {
  101985. /**
  101986. * Default configuration related to image processing available in the PBR Material.
  101987. */
  101988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101989. /**
  101990. * Gets the image processing configuration used either in this material.
  101991. */
  101992. /**
  101993. * Sets the Default image processing configuration used either in the this material.
  101994. *
  101995. * If sets to null, the scene one is in use.
  101996. */
  101997. imageProcessingConfiguration: ImageProcessingConfiguration;
  101998. /**
  101999. * Keep track of the image processing observer to allow dispose and replace.
  102000. */
  102001. private _imageProcessingObserver;
  102002. /**
  102003. * Attaches a new image processing configuration to the PBR Material.
  102004. * @param configuration
  102005. */
  102006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102007. /**
  102008. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102009. */
  102010. /**
  102011. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102012. */
  102013. colorCurves: Nullable<ColorCurves>;
  102014. /**
  102015. * Gets wether the color curves effect is enabled.
  102016. */
  102017. /**
  102018. * Sets wether the color curves effect is enabled.
  102019. */
  102020. colorCurvesEnabled: boolean;
  102021. /**
  102022. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102023. */
  102024. /**
  102025. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102026. */
  102027. colorGradingTexture: Nullable<BaseTexture>;
  102028. /**
  102029. * Gets wether the color grading effect is enabled.
  102030. */
  102031. /**
  102032. * Gets wether the color grading effect is enabled.
  102033. */
  102034. colorGradingEnabled: boolean;
  102035. /**
  102036. * Gets exposure used in the effect.
  102037. */
  102038. /**
  102039. * Sets exposure used in the effect.
  102040. */
  102041. exposure: number;
  102042. /**
  102043. * Gets wether tonemapping is enabled or not.
  102044. */
  102045. /**
  102046. * Sets wether tonemapping is enabled or not
  102047. */
  102048. toneMappingEnabled: boolean;
  102049. /**
  102050. * Gets the type of tone mapping effect.
  102051. */
  102052. /**
  102053. * Sets the type of tone mapping effect.
  102054. */
  102055. toneMappingType: number;
  102056. /**
  102057. * Gets contrast used in the effect.
  102058. */
  102059. /**
  102060. * Sets contrast used in the effect.
  102061. */
  102062. contrast: number;
  102063. /**
  102064. * Gets Vignette stretch size.
  102065. */
  102066. /**
  102067. * Sets Vignette stretch size.
  102068. */
  102069. vignetteStretch: number;
  102070. /**
  102071. * Gets Vignette centre X Offset.
  102072. */
  102073. /**
  102074. * Sets Vignette centre X Offset.
  102075. */
  102076. vignetteCentreX: number;
  102077. /**
  102078. * Gets Vignette centre Y Offset.
  102079. */
  102080. /**
  102081. * Sets Vignette centre Y Offset.
  102082. */
  102083. vignetteCentreY: number;
  102084. /**
  102085. * Gets Vignette weight or intensity of the vignette effect.
  102086. */
  102087. /**
  102088. * Sets Vignette weight or intensity of the vignette effect.
  102089. */
  102090. vignetteWeight: number;
  102091. /**
  102092. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102093. * if vignetteEnabled is set to true.
  102094. */
  102095. /**
  102096. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102097. * if vignetteEnabled is set to true.
  102098. */
  102099. vignetteColor: Color4;
  102100. /**
  102101. * Gets Camera field of view used by the Vignette effect.
  102102. */
  102103. /**
  102104. * Sets Camera field of view used by the Vignette effect.
  102105. */
  102106. vignetteCameraFov: number;
  102107. /**
  102108. * Gets the vignette blend mode allowing different kind of effect.
  102109. */
  102110. /**
  102111. * Sets the vignette blend mode allowing different kind of effect.
  102112. */
  102113. vignetteBlendMode: number;
  102114. /**
  102115. * Gets wether the vignette effect is enabled.
  102116. */
  102117. /**
  102118. * Sets wether the vignette effect is enabled.
  102119. */
  102120. vignetteEnabled: boolean;
  102121. private _fromLinearSpace;
  102122. /**
  102123. * Gets wether the input of the processing is in Gamma or Linear Space.
  102124. */
  102125. /**
  102126. * Sets wether the input of the processing is in Gamma or Linear Space.
  102127. */
  102128. fromLinearSpace: boolean;
  102129. /**
  102130. * Defines cache preventing GC.
  102131. */
  102132. private _defines;
  102133. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102134. /**
  102135. * "ImageProcessingPostProcess"
  102136. * @returns "ImageProcessingPostProcess"
  102137. */
  102138. getClassName(): string;
  102139. protected _updateParameters(): void;
  102140. dispose(camera?: Camera): void;
  102141. }
  102142. }
  102143. declare module BABYLON {
  102144. /**
  102145. * Class containing static functions to help procedurally build meshes
  102146. */
  102147. export class GroundBuilder {
  102148. /**
  102149. * Creates a ground mesh
  102150. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102151. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102153. * @param name defines the name of the mesh
  102154. * @param options defines the options used to create the mesh
  102155. * @param scene defines the hosting scene
  102156. * @returns the ground mesh
  102157. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102158. */
  102159. static CreateGround(name: string, options: {
  102160. width?: number;
  102161. height?: number;
  102162. subdivisions?: number;
  102163. subdivisionsX?: number;
  102164. subdivisionsY?: number;
  102165. updatable?: boolean;
  102166. }, scene: any): Mesh;
  102167. /**
  102168. * Creates a tiled ground mesh
  102169. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102170. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102171. * * 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
  102172. * * 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
  102173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102174. * @param name defines the name of the mesh
  102175. * @param options defines the options used to create the mesh
  102176. * @param scene defines the hosting scene
  102177. * @returns the tiled ground mesh
  102178. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102179. */
  102180. static CreateTiledGround(name: string, options: {
  102181. xmin: number;
  102182. zmin: number;
  102183. xmax: number;
  102184. zmax: number;
  102185. subdivisions?: {
  102186. w: number;
  102187. h: number;
  102188. };
  102189. precision?: {
  102190. w: number;
  102191. h: number;
  102192. };
  102193. updatable?: boolean;
  102194. }, scene?: Nullable<Scene>): Mesh;
  102195. /**
  102196. * Creates a ground mesh from a height map
  102197. * * The parameter `url` sets the URL of the height map image resource.
  102198. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102199. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102200. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102201. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102202. * * 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.
  102203. * * 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).
  102204. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102206. * @param name defines the name of the mesh
  102207. * @param url defines the url to the height map
  102208. * @param options defines the options used to create the mesh
  102209. * @param scene defines the hosting scene
  102210. * @returns the ground mesh
  102211. * @see https://doc.babylonjs.com/babylon101/height_map
  102212. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102213. */
  102214. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102215. width?: number;
  102216. height?: number;
  102217. subdivisions?: number;
  102218. minHeight?: number;
  102219. maxHeight?: number;
  102220. colorFilter?: Color3;
  102221. alphaFilter?: number;
  102222. updatable?: boolean;
  102223. onReady?: (mesh: GroundMesh) => void;
  102224. }, scene?: Nullable<Scene>): GroundMesh;
  102225. }
  102226. }
  102227. declare module BABYLON {
  102228. /**
  102229. * Class containing static functions to help procedurally build meshes
  102230. */
  102231. export class TorusBuilder {
  102232. /**
  102233. * Creates a torus mesh
  102234. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102235. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102236. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102240. * @param name defines the name of the mesh
  102241. * @param options defines the options used to create the mesh
  102242. * @param scene defines the hosting scene
  102243. * @returns the torus mesh
  102244. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102245. */
  102246. static CreateTorus(name: string, options: {
  102247. diameter?: number;
  102248. thickness?: number;
  102249. tessellation?: number;
  102250. updatable?: boolean;
  102251. sideOrientation?: number;
  102252. frontUVs?: Vector4;
  102253. backUVs?: Vector4;
  102254. }, scene: any): Mesh;
  102255. }
  102256. }
  102257. declare module BABYLON {
  102258. /**
  102259. * Class containing static functions to help procedurally build meshes
  102260. */
  102261. export class CylinderBuilder {
  102262. /**
  102263. * Creates a cylinder or a cone mesh
  102264. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102265. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102266. * * 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.
  102267. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102268. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102269. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102270. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102271. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  102272. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102273. * * 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).
  102274. * * 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
  102275. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102276. * * 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
  102277. * * 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.
  102278. * * If `enclose` is false, a ring surface is one element.
  102279. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102280. * * 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
  102281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102284. * @param name defines the name of the mesh
  102285. * @param options defines the options used to create the mesh
  102286. * @param scene defines the hosting scene
  102287. * @returns the cylinder mesh
  102288. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102289. */
  102290. static CreateCylinder(name: string, options: {
  102291. height?: number;
  102292. diameterTop?: number;
  102293. diameterBottom?: number;
  102294. diameter?: number;
  102295. tessellation?: number;
  102296. subdivisions?: number;
  102297. arc?: number;
  102298. faceColors?: Color4[];
  102299. faceUV?: Vector4[];
  102300. updatable?: boolean;
  102301. hasRings?: boolean;
  102302. enclose?: boolean;
  102303. cap?: number;
  102304. sideOrientation?: number;
  102305. frontUVs?: Vector4;
  102306. backUVs?: Vector4;
  102307. }, scene: any): Mesh;
  102308. }
  102309. }
  102310. declare module BABYLON {
  102311. /**
  102312. * Options to modify the vr teleportation behavior.
  102313. */
  102314. export interface VRTeleportationOptions {
  102315. /**
  102316. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102317. */
  102318. floorMeshName?: string;
  102319. /**
  102320. * A list of meshes to be used as the teleportation floor. (default: empty)
  102321. */
  102322. floorMeshes?: Mesh[];
  102323. }
  102324. /**
  102325. * Options to modify the vr experience helper's behavior.
  102326. */
  102327. export interface VRExperienceHelperOptions extends WebVROptions {
  102328. /**
  102329. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102330. */
  102331. createDeviceOrientationCamera?: boolean;
  102332. /**
  102333. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102334. */
  102335. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102336. /**
  102337. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102338. */
  102339. laserToggle?: boolean;
  102340. /**
  102341. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102342. */
  102343. floorMeshes?: Mesh[];
  102344. /**
  102345. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102346. */
  102347. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102348. }
  102349. /**
  102350. * Event containing information after VR has been entered
  102351. */
  102352. export class OnAfterEnteringVRObservableEvent {
  102353. /**
  102354. * If entering vr was successful
  102355. */
  102356. success: boolean;
  102357. }
  102358. /**
  102359. * Helps to quickly add VR support to an existing scene.
  102360. * See http://doc.babylonjs.com/how_to/webvr_helper
  102361. */
  102362. export class VRExperienceHelper {
  102363. /** Options to modify the vr experience helper's behavior. */
  102364. webVROptions: VRExperienceHelperOptions;
  102365. private _scene;
  102366. private _position;
  102367. private _btnVR;
  102368. private _btnVRDisplayed;
  102369. private _webVRsupported;
  102370. private _webVRready;
  102371. private _webVRrequesting;
  102372. private _webVRpresenting;
  102373. private _hasEnteredVR;
  102374. private _fullscreenVRpresenting;
  102375. private _canvas;
  102376. private _webVRCamera;
  102377. private _vrDeviceOrientationCamera;
  102378. private _deviceOrientationCamera;
  102379. private _existingCamera;
  102380. private _onKeyDown;
  102381. private _onVrDisplayPresentChange;
  102382. private _onVRDisplayChanged;
  102383. private _onVRRequestPresentStart;
  102384. private _onVRRequestPresentComplete;
  102385. /**
  102386. * Observable raised right before entering VR.
  102387. */
  102388. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102389. /**
  102390. * Observable raised when entering VR has completed.
  102391. */
  102392. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102393. /**
  102394. * Observable raised when exiting VR.
  102395. */
  102396. onExitingVRObservable: Observable<VRExperienceHelper>;
  102397. /**
  102398. * Observable raised when controller mesh is loaded.
  102399. */
  102400. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102401. /** Return this.onEnteringVRObservable
  102402. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102403. */
  102404. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102405. /** Return this.onExitingVRObservable
  102406. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102407. */
  102408. readonly onExitingVR: Observable<VRExperienceHelper>;
  102409. /** Return this.onControllerMeshLoadedObservable
  102410. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102411. */
  102412. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102413. private _rayLength;
  102414. private _useCustomVRButton;
  102415. private _teleportationRequested;
  102416. private _teleportActive;
  102417. private _floorMeshName;
  102418. private _floorMeshesCollection;
  102419. private _rotationAllowed;
  102420. private _teleportBackwardsVector;
  102421. private _teleportationTarget;
  102422. private _isDefaultTeleportationTarget;
  102423. private _postProcessMove;
  102424. private _teleportationFillColor;
  102425. private _teleportationBorderColor;
  102426. private _rotationAngle;
  102427. private _haloCenter;
  102428. private _cameraGazer;
  102429. private _padSensibilityUp;
  102430. private _padSensibilityDown;
  102431. private _leftController;
  102432. private _rightController;
  102433. /**
  102434. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102435. */
  102436. onNewMeshSelected: Observable<AbstractMesh>;
  102437. /**
  102438. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102439. */
  102440. onNewMeshPicked: Observable<PickingInfo>;
  102441. private _circleEase;
  102442. /**
  102443. * Observable raised before camera teleportation
  102444. */
  102445. onBeforeCameraTeleport: Observable<Vector3>;
  102446. /**
  102447. * Observable raised after camera teleportation
  102448. */
  102449. onAfterCameraTeleport: Observable<Vector3>;
  102450. /**
  102451. * Observable raised when current selected mesh gets unselected
  102452. */
  102453. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102454. private _raySelectionPredicate;
  102455. /**
  102456. * To be optionaly changed by user to define custom ray selection
  102457. */
  102458. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102459. /**
  102460. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102461. */
  102462. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102463. /**
  102464. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102465. */
  102466. teleportationEnabled: boolean;
  102467. private _defaultHeight;
  102468. private _teleportationInitialized;
  102469. private _interactionsEnabled;
  102470. private _interactionsRequested;
  102471. private _displayGaze;
  102472. private _displayLaserPointer;
  102473. /**
  102474. * The mesh used to display where the user is going to teleport.
  102475. */
  102476. /**
  102477. * Sets the mesh to be used to display where the user is going to teleport.
  102478. */
  102479. teleportationTarget: Mesh;
  102480. /**
  102481. * 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
  102482. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102483. * See http://doc.babylonjs.com/resources/baking_transformations
  102484. */
  102485. gazeTrackerMesh: Mesh;
  102486. /**
  102487. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102488. */
  102489. updateGazeTrackerScale: boolean;
  102490. /**
  102491. * If the gaze trackers color should be updated when selecting meshes
  102492. */
  102493. updateGazeTrackerColor: boolean;
  102494. /**
  102495. * The gaze tracking mesh corresponding to the left controller
  102496. */
  102497. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102498. /**
  102499. * The gaze tracking mesh corresponding to the right controller
  102500. */
  102501. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102502. /**
  102503. * If the ray of the gaze should be displayed.
  102504. */
  102505. /**
  102506. * Sets if the ray of the gaze should be displayed.
  102507. */
  102508. displayGaze: boolean;
  102509. /**
  102510. * If the ray of the LaserPointer should be displayed.
  102511. */
  102512. /**
  102513. * Sets if the ray of the LaserPointer should be displayed.
  102514. */
  102515. displayLaserPointer: boolean;
  102516. /**
  102517. * The deviceOrientationCamera used as the camera when not in VR.
  102518. */
  102519. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102520. /**
  102521. * Based on the current WebVR support, returns the current VR camera used.
  102522. */
  102523. readonly currentVRCamera: Nullable<Camera>;
  102524. /**
  102525. * The webVRCamera which is used when in VR.
  102526. */
  102527. readonly webVRCamera: WebVRFreeCamera;
  102528. /**
  102529. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102530. */
  102531. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102532. private readonly _teleportationRequestInitiated;
  102533. /**
  102534. * Defines wether or not Pointer lock should be requested when switching to
  102535. * full screen.
  102536. */
  102537. requestPointerLockOnFullScreen: boolean;
  102538. /**
  102539. * Instantiates a VRExperienceHelper.
  102540. * Helps to quickly add VR support to an existing scene.
  102541. * @param scene The scene the VRExperienceHelper belongs to.
  102542. * @param webVROptions Options to modify the vr experience helper's behavior.
  102543. */
  102544. constructor(scene: Scene,
  102545. /** Options to modify the vr experience helper's behavior. */
  102546. webVROptions?: VRExperienceHelperOptions);
  102547. private _onDefaultMeshLoaded;
  102548. private _onResize;
  102549. private _onFullscreenChange;
  102550. /**
  102551. * Gets a value indicating if we are currently in VR mode.
  102552. */
  102553. readonly isInVRMode: boolean;
  102554. private onVrDisplayPresentChange;
  102555. private onVRDisplayChanged;
  102556. private moveButtonToBottomRight;
  102557. private displayVRButton;
  102558. private updateButtonVisibility;
  102559. private _cachedAngularSensibility;
  102560. /**
  102561. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102562. * Otherwise, will use the fullscreen API.
  102563. */
  102564. enterVR(): void;
  102565. /**
  102566. * Attempt to exit VR, or fullscreen.
  102567. */
  102568. exitVR(): void;
  102569. /**
  102570. * The position of the vr experience helper.
  102571. */
  102572. /**
  102573. * Sets the position of the vr experience helper.
  102574. */
  102575. position: Vector3;
  102576. /**
  102577. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102578. */
  102579. enableInteractions(): void;
  102580. private readonly _noControllerIsActive;
  102581. private beforeRender;
  102582. private _isTeleportationFloor;
  102583. /**
  102584. * Adds a floor mesh to be used for teleportation.
  102585. * @param floorMesh the mesh to be used for teleportation.
  102586. */
  102587. addFloorMesh(floorMesh: Mesh): void;
  102588. /**
  102589. * Removes a floor mesh from being used for teleportation.
  102590. * @param floorMesh the mesh to be removed.
  102591. */
  102592. removeFloorMesh(floorMesh: Mesh): void;
  102593. /**
  102594. * Enables interactions and teleportation using the VR controllers and gaze.
  102595. * @param vrTeleportationOptions options to modify teleportation behavior.
  102596. */
  102597. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102598. private _onNewGamepadConnected;
  102599. private _tryEnableInteractionOnController;
  102600. private _onNewGamepadDisconnected;
  102601. private _enableInteractionOnController;
  102602. private _checkTeleportWithRay;
  102603. private _checkRotate;
  102604. private _checkTeleportBackwards;
  102605. private _enableTeleportationOnController;
  102606. private _createTeleportationCircles;
  102607. private _displayTeleportationTarget;
  102608. private _hideTeleportationTarget;
  102609. private _rotateCamera;
  102610. private _moveTeleportationSelectorTo;
  102611. private _workingVector;
  102612. private _workingQuaternion;
  102613. private _workingMatrix;
  102614. /**
  102615. * Teleports the users feet to the desired location
  102616. * @param location The location where the user's feet should be placed
  102617. */
  102618. teleportCamera(location: Vector3): void;
  102619. private _convertNormalToDirectionOfRay;
  102620. private _castRayAndSelectObject;
  102621. private _notifySelectedMeshUnselected;
  102622. /**
  102623. * Sets the color of the laser ray from the vr controllers.
  102624. * @param color new color for the ray.
  102625. */
  102626. changeLaserColor(color: Color3): void;
  102627. /**
  102628. * Sets the color of the ray from the vr headsets gaze.
  102629. * @param color new color for the ray.
  102630. */
  102631. changeGazeColor(color: Color3): void;
  102632. /**
  102633. * Exits VR and disposes of the vr experience helper
  102634. */
  102635. dispose(): void;
  102636. /**
  102637. * Gets the name of the VRExperienceHelper class
  102638. * @returns "VRExperienceHelper"
  102639. */
  102640. getClassName(): string;
  102641. }
  102642. }
  102643. declare module BABYLON {
  102644. /**
  102645. * Manages an XRSession
  102646. * @see https://doc.babylonjs.com/how_to/webxr
  102647. */
  102648. export class WebXRSessionManager implements IDisposable {
  102649. private scene;
  102650. /**
  102651. * Fires every time a new xrFrame arrives which can be used to update the camera
  102652. */
  102653. onXRFrameObservable: Observable<any>;
  102654. /**
  102655. * Fires when the xr session is ended either by the device or manually done
  102656. */
  102657. onXRSessionEnded: Observable<any>;
  102658. /** @hidden */
  102659. _xrSession: XRSession;
  102660. /** @hidden */
  102661. _frameOfReference: XRFrameOfReference;
  102662. /** @hidden */
  102663. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102664. /** @hidden */
  102665. _currentXRFrame: Nullable<XRFrame>;
  102666. private _xrNavigator;
  102667. private _xrDevice;
  102668. private _tmpMatrix;
  102669. /**
  102670. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102671. * @param scene The scene which the session should be created for
  102672. */
  102673. constructor(scene: Scene);
  102674. /**
  102675. * Initializes the manager
  102676. * After initialization enterXR can be called to start an XR session
  102677. * @returns Promise which resolves after it is initialized
  102678. */
  102679. initializeAsync(): Promise<void>;
  102680. /**
  102681. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102682. * @param sessionCreationOptions xr options to create the session with
  102683. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102684. * @returns Promise which resolves after it enters XR
  102685. */
  102686. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102687. /**
  102688. * Stops the xrSession and restores the renderloop
  102689. * @returns Promise which resolves after it exits XR
  102690. */
  102691. exitXRAsync(): Promise<void>;
  102692. /**
  102693. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102694. * @param ray ray to cast into the environment
  102695. * @returns Promise which resolves with a collision point in the environment if it exists
  102696. */
  102697. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102698. /**
  102699. * Checks if a session would be supported for the creation options specified
  102700. * @param options creation options to check if they are supported
  102701. * @returns true if supported
  102702. */
  102703. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102704. /**
  102705. * @hidden
  102706. * Converts the render layer of xrSession to a render target
  102707. * @param session session to create render target for
  102708. * @param scene scene the new render target should be created for
  102709. */
  102710. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102711. /**
  102712. * Disposes of the session manager
  102713. */
  102714. dispose(): void;
  102715. }
  102716. }
  102717. declare module BABYLON {
  102718. /**
  102719. * WebXR Camera which holds the views for the xrSession
  102720. * @see https://doc.babylonjs.com/how_to/webxr
  102721. */
  102722. export class WebXRCamera extends FreeCamera {
  102723. private static _TmpMatrix;
  102724. /**
  102725. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102726. * @param name the name of the camera
  102727. * @param scene the scene to add the camera to
  102728. */
  102729. constructor(name: string, scene: Scene);
  102730. private _updateNumberOfRigCameras;
  102731. /** @hidden */
  102732. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102733. /**
  102734. * Updates the cameras position from the current pose information of the XR session
  102735. * @param xrSessionManager the session containing pose information
  102736. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102737. */
  102738. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102739. }
  102740. }
  102741. declare module BABYLON {
  102742. /**
  102743. * States of the webXR experience
  102744. */
  102745. export enum WebXRState {
  102746. /**
  102747. * Transitioning to being in XR mode
  102748. */
  102749. ENTERING_XR = 0,
  102750. /**
  102751. * Transitioning to non XR mode
  102752. */
  102753. EXITING_XR = 1,
  102754. /**
  102755. * In XR mode and presenting
  102756. */
  102757. IN_XR = 2,
  102758. /**
  102759. * Not entered XR mode
  102760. */
  102761. NOT_IN_XR = 3
  102762. }
  102763. /**
  102764. * Helper class used to enable XR
  102765. * @see https://doc.babylonjs.com/how_to/webxr
  102766. */
  102767. export class WebXRExperienceHelper implements IDisposable {
  102768. private scene;
  102769. /**
  102770. * 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
  102771. */
  102772. container: AbstractMesh;
  102773. /**
  102774. * Camera used to render xr content
  102775. */
  102776. camera: WebXRCamera;
  102777. /**
  102778. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102779. */
  102780. state: WebXRState;
  102781. private _setState;
  102782. private static _TmpVector;
  102783. /**
  102784. * Fires when the state of the experience helper has changed
  102785. */
  102786. onStateChangedObservable: Observable<WebXRState>;
  102787. /** @hidden */
  102788. _sessionManager: WebXRSessionManager;
  102789. private _nonVRCamera;
  102790. private _originalSceneAutoClear;
  102791. private _supported;
  102792. /**
  102793. * Creates the experience helper
  102794. * @param scene the scene to attach the experience helper to
  102795. * @returns a promise for the experience helper
  102796. */
  102797. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  102798. /**
  102799. * Creates a WebXRExperienceHelper
  102800. * @param scene The scene the helper should be created in
  102801. */
  102802. private constructor();
  102803. /**
  102804. * Exits XR mode and returns the scene to its original state
  102805. * @returns promise that resolves after xr mode has exited
  102806. */
  102807. exitXRAsync(): Promise<void>;
  102808. /**
  102809. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  102810. * @param sessionCreationOptions options for the XR session
  102811. * @param frameOfReference frame of reference of the XR session
  102812. * @returns promise that resolves after xr mode has entered
  102813. */
  102814. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  102815. /**
  102816. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102817. * @param ray ray to cast into the environment
  102818. * @returns Promise which resolves with a collision point in the environment if it exists
  102819. */
  102820. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102821. /**
  102822. * Updates the global position of the camera by moving the camera's container
  102823. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  102824. * @param position The desired global position of the camera
  102825. */
  102826. setPositionOfCameraUsingContainer(position: Vector3): void;
  102827. /**
  102828. * Rotates the xr camera by rotating the camera's container around the camera's position
  102829. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  102830. * @param rotation the desired quaternion rotation to apply to the camera
  102831. */
  102832. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  102833. /**
  102834. * Checks if the creation options are supported by the xr session
  102835. * @param options creation options
  102836. * @returns true if supported
  102837. */
  102838. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102839. /**
  102840. * Disposes of the experience helper
  102841. */
  102842. dispose(): void;
  102843. }
  102844. }
  102845. declare module BABYLON {
  102846. /**
  102847. * Button which can be used to enter a different mode of XR
  102848. */
  102849. export class WebXREnterExitUIButton {
  102850. /** button element */
  102851. element: HTMLElement;
  102852. /** XR initialization options for the button */
  102853. initializationOptions: XRSessionCreationOptions;
  102854. /**
  102855. * Creates a WebXREnterExitUIButton
  102856. * @param element button element
  102857. * @param initializationOptions XR initialization options for the button
  102858. */
  102859. constructor(
  102860. /** button element */
  102861. element: HTMLElement,
  102862. /** XR initialization options for the button */
  102863. initializationOptions: XRSessionCreationOptions);
  102864. /**
  102865. * Overwritable function which can be used to update the button's visuals when the state changes
  102866. * @param activeButton the current active button in the UI
  102867. */
  102868. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  102869. }
  102870. /**
  102871. * Options to create the webXR UI
  102872. */
  102873. export class WebXREnterExitUIOptions {
  102874. /**
  102875. * Context to enter xr with
  102876. */
  102877. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  102878. /**
  102879. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  102880. */
  102881. customButtons?: Array<WebXREnterExitUIButton>;
  102882. }
  102883. /**
  102884. * UI to allow the user to enter/exit XR mode
  102885. */
  102886. export class WebXREnterExitUI implements IDisposable {
  102887. private scene;
  102888. private _overlay;
  102889. private _buttons;
  102890. private _activeButton;
  102891. /**
  102892. * Fired every time the active button is changed.
  102893. *
  102894. * When xr is entered via a button that launches xr that button will be the callback parameter
  102895. *
  102896. * When exiting xr the callback parameter will be null)
  102897. */
  102898. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  102899. /**
  102900. * Creates UI to allow the user to enter/exit XR mode
  102901. * @param scene the scene to add the ui to
  102902. * @param helper the xr experience helper to enter/exit xr with
  102903. * @param options options to configure the UI
  102904. * @returns the created ui
  102905. */
  102906. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  102907. private constructor();
  102908. private _updateButtons;
  102909. /**
  102910. * Disposes of the object
  102911. */
  102912. dispose(): void;
  102913. }
  102914. }
  102915. declare module BABYLON {
  102916. /**
  102917. * Represents an XR input
  102918. */
  102919. export class WebXRController {
  102920. /**
  102921. * 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
  102922. */
  102923. grip?: AbstractMesh;
  102924. /**
  102925. * Pointer which can be used to select objects or attach a visible laser to
  102926. */
  102927. pointer: AbstractMesh;
  102928. /**
  102929. * Creates the controller
  102930. * @see https://doc.babylonjs.com/how_to/webxr
  102931. * @param scene the scene which the controller should be associated to
  102932. */
  102933. constructor(scene: Scene);
  102934. /**
  102935. * Disposes of the object
  102936. */
  102937. dispose(): void;
  102938. }
  102939. /**
  102940. * XR input used to track XR inputs such as controllers/rays
  102941. */
  102942. export class WebXRInput implements IDisposable {
  102943. private helper;
  102944. /**
  102945. * XR controllers being tracked
  102946. */
  102947. controllers: Array<WebXRController>;
  102948. private _tmpMatrix;
  102949. private _frameObserver;
  102950. /**
  102951. * Initializes the WebXRInput
  102952. * @param helper experience helper which the input should be created for
  102953. */
  102954. constructor(helper: WebXRExperienceHelper);
  102955. /**
  102956. * Disposes of the object
  102957. */
  102958. dispose(): void;
  102959. }
  102960. }
  102961. declare module BABYLON {
  102962. /**
  102963. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  102964. */
  102965. export class WebXRManagedOutputCanvas implements IDisposable {
  102966. private _canvas;
  102967. /**
  102968. * xrpresent context of the canvas which can be used to display/mirror xr content
  102969. */
  102970. canvasContext: Nullable<WebGLRenderingContext>;
  102971. /**
  102972. * Initializes the canvas to be added/removed upon entering/exiting xr
  102973. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  102974. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  102975. */
  102976. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  102977. /**
  102978. * Disposes of the object
  102979. */
  102980. dispose(): void;
  102981. private _setManagedOutputCanvas;
  102982. private _addCanvas;
  102983. private _removeCanvas;
  102984. }
  102985. }
  102986. declare module BABYLON {
  102987. /**
  102988. * Contains an array of blocks representing the octree
  102989. */
  102990. export interface IOctreeContainer<T> {
  102991. /**
  102992. * Blocks within the octree
  102993. */
  102994. blocks: Array<OctreeBlock<T>>;
  102995. }
  102996. /**
  102997. * Class used to store a cell in an octree
  102998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102999. */
  103000. export class OctreeBlock<T> {
  103001. /**
  103002. * Gets the content of the current block
  103003. */
  103004. entries: T[];
  103005. /**
  103006. * Gets the list of block children
  103007. */
  103008. blocks: Array<OctreeBlock<T>>;
  103009. private _depth;
  103010. private _maxDepth;
  103011. private _capacity;
  103012. private _minPoint;
  103013. private _maxPoint;
  103014. private _boundingVectors;
  103015. private _creationFunc;
  103016. /**
  103017. * Creates a new block
  103018. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103019. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103020. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103021. * @param depth defines the current depth of this block in the octree
  103022. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103023. * @param creationFunc defines a callback to call when an element is added to the block
  103024. */
  103025. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103026. /**
  103027. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103028. */
  103029. readonly capacity: number;
  103030. /**
  103031. * Gets the minimum vector (in world space) of the block's bounding box
  103032. */
  103033. readonly minPoint: Vector3;
  103034. /**
  103035. * Gets the maximum vector (in world space) of the block's bounding box
  103036. */
  103037. readonly maxPoint: Vector3;
  103038. /**
  103039. * Add a new element to this block
  103040. * @param entry defines the element to add
  103041. */
  103042. addEntry(entry: T): void;
  103043. /**
  103044. * Remove an element from this block
  103045. * @param entry defines the element to remove
  103046. */
  103047. removeEntry(entry: T): void;
  103048. /**
  103049. * Add an array of elements to this block
  103050. * @param entries defines the array of elements to add
  103051. */
  103052. addEntries(entries: T[]): void;
  103053. /**
  103054. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103055. * @param frustumPlanes defines the frustum planes to test
  103056. * @param selection defines the array to store current content if selection is positive
  103057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103058. */
  103059. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103060. /**
  103061. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103062. * @param sphereCenter defines the bounding sphere center
  103063. * @param sphereRadius defines the bounding sphere radius
  103064. * @param selection defines the array to store current content if selection is positive
  103065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103066. */
  103067. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103068. /**
  103069. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103070. * @param ray defines the ray to test with
  103071. * @param selection defines the array to store current content if selection is positive
  103072. */
  103073. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103074. /**
  103075. * Subdivide the content into child blocks (this block will then be empty)
  103076. */
  103077. createInnerBlocks(): void;
  103078. /**
  103079. * @hidden
  103080. */
  103081. 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;
  103082. }
  103083. }
  103084. declare module BABYLON {
  103085. /**
  103086. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103088. */
  103089. export class Octree<T> {
  103090. /** 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.) */
  103091. maxDepth: number;
  103092. /**
  103093. * Blocks within the octree containing objects
  103094. */
  103095. blocks: Array<OctreeBlock<T>>;
  103096. /**
  103097. * Content stored in the octree
  103098. */
  103099. dynamicContent: T[];
  103100. private _maxBlockCapacity;
  103101. private _selectionContent;
  103102. private _creationFunc;
  103103. /**
  103104. * Creates a octree
  103105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103106. * @param creationFunc function to be used to instatiate the octree
  103107. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103108. * @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.)
  103109. */
  103110. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103111. /** 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.) */
  103112. maxDepth?: number);
  103113. /**
  103114. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103115. * @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);
  103116. * @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);
  103117. * @param entries meshes to be added to the octree blocks
  103118. */
  103119. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103120. /**
  103121. * Adds a mesh to the octree
  103122. * @param entry Mesh to add to the octree
  103123. */
  103124. addMesh(entry: T): void;
  103125. /**
  103126. * Remove an element from the octree
  103127. * @param entry defines the element to remove
  103128. */
  103129. removeMesh(entry: T): void;
  103130. /**
  103131. * Selects an array of meshes within the frustum
  103132. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103133. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103134. * @returns array of meshes within the frustum
  103135. */
  103136. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103137. /**
  103138. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103139. * @param sphereCenter defines the bounding sphere center
  103140. * @param sphereRadius defines the bounding sphere radius
  103141. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103142. * @returns an array of objects that intersect the sphere
  103143. */
  103144. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103145. /**
  103146. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103147. * @param ray defines the ray to test with
  103148. * @returns array of intersected objects
  103149. */
  103150. intersectsRay(ray: Ray): SmartArray<T>;
  103151. /**
  103152. * Adds a mesh into the octree block if it intersects the block
  103153. */
  103154. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103155. /**
  103156. * Adds a submesh into the octree block if it intersects the block
  103157. */
  103158. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103159. }
  103160. }
  103161. declare module BABYLON {
  103162. interface Scene {
  103163. /**
  103164. * @hidden
  103165. * Backing Filed
  103166. */
  103167. _selectionOctree: Octree<AbstractMesh>;
  103168. /**
  103169. * Gets the octree used to boost mesh selection (picking)
  103170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103171. */
  103172. selectionOctree: Octree<AbstractMesh>;
  103173. /**
  103174. * Creates or updates the octree used to boost selection (picking)
  103175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103176. * @param maxCapacity defines the maximum capacity per leaf
  103177. * @param maxDepth defines the maximum depth of the octree
  103178. * @returns an octree of AbstractMesh
  103179. */
  103180. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103181. }
  103182. interface AbstractMesh {
  103183. /**
  103184. * @hidden
  103185. * Backing Field
  103186. */
  103187. _submeshesOctree: Octree<SubMesh>;
  103188. /**
  103189. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103190. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103191. * @param maxCapacity defines the maximum size of each block (64 by default)
  103192. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103193. * @returns the new octree
  103194. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103196. */
  103197. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103198. }
  103199. /**
  103200. * Defines the octree scene component responsible to manage any octrees
  103201. * in a given scene.
  103202. */
  103203. export class OctreeSceneComponent {
  103204. /**
  103205. * The component name help to identify the component in the list of scene components.
  103206. */
  103207. readonly name: string;
  103208. /**
  103209. * The scene the component belongs to.
  103210. */
  103211. scene: Scene;
  103212. /**
  103213. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103214. */
  103215. readonly checksIsEnabled: boolean;
  103216. /**
  103217. * Creates a new instance of the component for the given scene
  103218. * @param scene Defines the scene to register the component in
  103219. */
  103220. constructor(scene: Scene);
  103221. /**
  103222. * Registers the component in a given scene
  103223. */
  103224. register(): void;
  103225. /**
  103226. * Return the list of active meshes
  103227. * @returns the list of active meshes
  103228. */
  103229. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103230. /**
  103231. * Return the list of active sub meshes
  103232. * @param mesh The mesh to get the candidates sub meshes from
  103233. * @returns the list of active sub meshes
  103234. */
  103235. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103236. private _tempRay;
  103237. /**
  103238. * Return the list of sub meshes intersecting with a given local ray
  103239. * @param mesh defines the mesh to find the submesh for
  103240. * @param localRay defines the ray in local space
  103241. * @returns the list of intersecting sub meshes
  103242. */
  103243. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103244. /**
  103245. * Return the list of sub meshes colliding with a collider
  103246. * @param mesh defines the mesh to find the submesh for
  103247. * @param collider defines the collider to evaluate the collision against
  103248. * @returns the list of colliding sub meshes
  103249. */
  103250. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103251. /**
  103252. * Rebuilds the elements related to this component in case of
  103253. * context lost for instance.
  103254. */
  103255. rebuild(): void;
  103256. /**
  103257. * Disposes the component and the associated ressources.
  103258. */
  103259. dispose(): void;
  103260. }
  103261. }
  103262. declare module BABYLON {
  103263. /**
  103264. * Renders a layer on top of an existing scene
  103265. */
  103266. export class UtilityLayerRenderer implements IDisposable {
  103267. /** the original scene that will be rendered on top of */
  103268. originalScene: Scene;
  103269. private _pointerCaptures;
  103270. private _lastPointerEvents;
  103271. private static _DefaultUtilityLayer;
  103272. private static _DefaultKeepDepthUtilityLayer;
  103273. private _sharedGizmoLight;
  103274. private _renderCamera;
  103275. /**
  103276. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103277. * @returns the camera that is used when rendering the utility layer
  103278. */
  103279. getRenderCamera(): Nullable<Camera>;
  103280. /**
  103281. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103282. * @param cam the camera that should be used when rendering the utility layer
  103283. */
  103284. setRenderCamera(cam: Nullable<Camera>): void;
  103285. /**
  103286. * @hidden
  103287. * Light which used by gizmos to get light shading
  103288. */
  103289. _getSharedGizmoLight(): HemisphericLight;
  103290. /**
  103291. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103292. */
  103293. pickUtilitySceneFirst: boolean;
  103294. /**
  103295. * 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)
  103296. */
  103297. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103298. /**
  103299. * 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)
  103300. */
  103301. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103302. /**
  103303. * The scene that is rendered on top of the original scene
  103304. */
  103305. utilityLayerScene: Scene;
  103306. /**
  103307. * If the utility layer should automatically be rendered on top of existing scene
  103308. */
  103309. shouldRender: boolean;
  103310. /**
  103311. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103312. */
  103313. onlyCheckPointerDownEvents: boolean;
  103314. /**
  103315. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103316. */
  103317. processAllEvents: boolean;
  103318. /**
  103319. * Observable raised when the pointer move from the utility layer scene to the main scene
  103320. */
  103321. onPointerOutObservable: Observable<number>;
  103322. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103323. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103324. private _afterRenderObserver;
  103325. private _sceneDisposeObserver;
  103326. private _originalPointerObserver;
  103327. /**
  103328. * Instantiates a UtilityLayerRenderer
  103329. * @param originalScene the original scene that will be rendered on top of
  103330. * @param handleEvents boolean indicating if the utility layer should handle events
  103331. */
  103332. constructor(
  103333. /** the original scene that will be rendered on top of */
  103334. originalScene: Scene, handleEvents?: boolean);
  103335. private _notifyObservers;
  103336. /**
  103337. * Renders the utility layers scene on top of the original scene
  103338. */
  103339. render(): void;
  103340. /**
  103341. * Disposes of the renderer
  103342. */
  103343. dispose(): void;
  103344. private _updateCamera;
  103345. }
  103346. }
  103347. declare module BABYLON {
  103348. /**
  103349. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103350. */
  103351. export class Gizmo implements IDisposable {
  103352. /** The utility layer the gizmo will be added to */
  103353. gizmoLayer: UtilityLayerRenderer;
  103354. /**
  103355. * The root mesh of the gizmo
  103356. */
  103357. _rootMesh: Mesh;
  103358. private _attachedMesh;
  103359. /**
  103360. * Ratio for the scale of the gizmo (Default: 1)
  103361. */
  103362. scaleRatio: number;
  103363. /**
  103364. * If a custom mesh has been set (Default: false)
  103365. */
  103366. protected _customMeshSet: boolean;
  103367. /**
  103368. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103369. * * When set, interactions will be enabled
  103370. */
  103371. attachedMesh: Nullable<AbstractMesh>;
  103372. /**
  103373. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103374. * @param mesh The mesh to replace the default mesh of the gizmo
  103375. */
  103376. setCustomMesh(mesh: Mesh): void;
  103377. /**
  103378. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103379. */
  103380. updateGizmoRotationToMatchAttachedMesh: boolean;
  103381. /**
  103382. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103383. */
  103384. updateGizmoPositionToMatchAttachedMesh: boolean;
  103385. /**
  103386. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103387. */
  103388. protected _updateScale: boolean;
  103389. protected _interactionsEnabled: boolean;
  103390. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103391. private _beforeRenderObserver;
  103392. private _tempVector;
  103393. /**
  103394. * Creates a gizmo
  103395. * @param gizmoLayer The utility layer the gizmo will be added to
  103396. */
  103397. constructor(
  103398. /** The utility layer the gizmo will be added to */
  103399. gizmoLayer?: UtilityLayerRenderer);
  103400. /**
  103401. * Updates the gizmo to match the attached mesh's position/rotation
  103402. */
  103403. protected _update(): void;
  103404. /**
  103405. * Disposes of the gizmo
  103406. */
  103407. dispose(): void;
  103408. }
  103409. }
  103410. declare module BABYLON {
  103411. /**
  103412. * Single plane drag gizmo
  103413. */
  103414. export class PlaneDragGizmo extends Gizmo {
  103415. /**
  103416. * Drag behavior responsible for the gizmos dragging interactions
  103417. */
  103418. dragBehavior: PointerDragBehavior;
  103419. private _pointerObserver;
  103420. /**
  103421. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103422. */
  103423. snapDistance: number;
  103424. /**
  103425. * Event that fires each time the gizmo snaps to a new location.
  103426. * * snapDistance is the the change in distance
  103427. */
  103428. onSnapObservable: Observable<{
  103429. snapDistance: number;
  103430. }>;
  103431. private _plane;
  103432. private _coloredMaterial;
  103433. private _hoverMaterial;
  103434. private _isEnabled;
  103435. private _parent;
  103436. /** @hidden */
  103437. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103438. /** @hidden */
  103439. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103440. /**
  103441. * Creates a PlaneDragGizmo
  103442. * @param gizmoLayer The utility layer the gizmo will be added to
  103443. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103444. * @param color The color of the gizmo
  103445. */
  103446. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103447. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103448. /**
  103449. * If the gizmo is enabled
  103450. */
  103451. isEnabled: boolean;
  103452. /**
  103453. * Disposes of the gizmo
  103454. */
  103455. dispose(): void;
  103456. }
  103457. }
  103458. declare module BABYLON {
  103459. /**
  103460. * Gizmo that enables dragging a mesh along 3 axis
  103461. */
  103462. export class PositionGizmo extends Gizmo {
  103463. /**
  103464. * Internal gizmo used for interactions on the x axis
  103465. */
  103466. xGizmo: AxisDragGizmo;
  103467. /**
  103468. * Internal gizmo used for interactions on the y axis
  103469. */
  103470. yGizmo: AxisDragGizmo;
  103471. /**
  103472. * Internal gizmo used for interactions on the z axis
  103473. */
  103474. zGizmo: AxisDragGizmo;
  103475. /**
  103476. * Internal gizmo used for interactions on the yz plane
  103477. */
  103478. xPlaneGizmo: PlaneDragGizmo;
  103479. /**
  103480. * Internal gizmo used for interactions on the xz plane
  103481. */
  103482. yPlaneGizmo: PlaneDragGizmo;
  103483. /**
  103484. * Internal gizmo used for interactions on the xy plane
  103485. */
  103486. zPlaneGizmo: PlaneDragGizmo;
  103487. /**
  103488. * private variables
  103489. */
  103490. private _meshAttached;
  103491. private _updateGizmoRotationToMatchAttachedMesh;
  103492. private _snapDistance;
  103493. private _scaleRatio;
  103494. /** Fires an event when any of it's sub gizmos are dragged */
  103495. onDragStartObservable: Observable<{}>;
  103496. /** Fires an event when any of it's sub gizmos are released from dragging */
  103497. onDragEndObservable: Observable<{}>;
  103498. /**
  103499. * If set to true, planar drag is enabled
  103500. */
  103501. private _planarGizmoEnabled;
  103502. attachedMesh: Nullable<AbstractMesh>;
  103503. /**
  103504. * Creates a PositionGizmo
  103505. * @param gizmoLayer The utility layer the gizmo will be added to
  103506. */
  103507. constructor(gizmoLayer?: UtilityLayerRenderer);
  103508. /**
  103509. * If the planar drag gizmo is enabled
  103510. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103511. */
  103512. planarGizmoEnabled: boolean;
  103513. updateGizmoRotationToMatchAttachedMesh: boolean;
  103514. /**
  103515. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103516. */
  103517. snapDistance: number;
  103518. /**
  103519. * Ratio for the scale of the gizmo (Default: 1)
  103520. */
  103521. scaleRatio: number;
  103522. /**
  103523. * Disposes of the gizmo
  103524. */
  103525. dispose(): void;
  103526. /**
  103527. * CustomMeshes are not supported by this gizmo
  103528. * @param mesh The mesh to replace the default mesh of the gizmo
  103529. */
  103530. setCustomMesh(mesh: Mesh): void;
  103531. }
  103532. }
  103533. declare module BABYLON {
  103534. /**
  103535. * Single axis drag gizmo
  103536. */
  103537. export class AxisDragGizmo extends Gizmo {
  103538. /**
  103539. * Drag behavior responsible for the gizmos dragging interactions
  103540. */
  103541. dragBehavior: PointerDragBehavior;
  103542. private _pointerObserver;
  103543. /**
  103544. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103545. */
  103546. snapDistance: number;
  103547. /**
  103548. * Event that fires each time the gizmo snaps to a new location.
  103549. * * snapDistance is the the change in distance
  103550. */
  103551. onSnapObservable: Observable<{
  103552. snapDistance: number;
  103553. }>;
  103554. private _isEnabled;
  103555. private _parent;
  103556. private _arrow;
  103557. private _coloredMaterial;
  103558. private _hoverMaterial;
  103559. /** @hidden */
  103560. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103561. /** @hidden */
  103562. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103563. /**
  103564. * Creates an AxisDragGizmo
  103565. * @param gizmoLayer The utility layer the gizmo will be added to
  103566. * @param dragAxis The axis which the gizmo will be able to drag on
  103567. * @param color The color of the gizmo
  103568. */
  103569. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103570. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103571. /**
  103572. * If the gizmo is enabled
  103573. */
  103574. isEnabled: boolean;
  103575. /**
  103576. * Disposes of the gizmo
  103577. */
  103578. dispose(): void;
  103579. }
  103580. }
  103581. declare module BABYLON.Debug {
  103582. /**
  103583. * The Axes viewer will show 3 axes in a specific point in space
  103584. */
  103585. export class AxesViewer {
  103586. private _xAxis;
  103587. private _yAxis;
  103588. private _zAxis;
  103589. private _scaleLinesFactor;
  103590. private _instanced;
  103591. /**
  103592. * Gets the hosting scene
  103593. */
  103594. scene: Scene;
  103595. /**
  103596. * Gets or sets a number used to scale line length
  103597. */
  103598. scaleLines: number;
  103599. /** Gets the node hierarchy used to render x-axis */
  103600. readonly xAxis: TransformNode;
  103601. /** Gets the node hierarchy used to render y-axis */
  103602. readonly yAxis: TransformNode;
  103603. /** Gets the node hierarchy used to render z-axis */
  103604. readonly zAxis: TransformNode;
  103605. /**
  103606. * Creates a new AxesViewer
  103607. * @param scene defines the hosting scene
  103608. * @param scaleLines defines a number used to scale line length (1 by default)
  103609. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103610. * @param xAxis defines the node hierarchy used to render the x-axis
  103611. * @param yAxis defines the node hierarchy used to render the y-axis
  103612. * @param zAxis defines the node hierarchy used to render the z-axis
  103613. */
  103614. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103615. /**
  103616. * Force the viewer to update
  103617. * @param position defines the position of the viewer
  103618. * @param xaxis defines the x axis of the viewer
  103619. * @param yaxis defines the y axis of the viewer
  103620. * @param zaxis defines the z axis of the viewer
  103621. */
  103622. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103623. /**
  103624. * Creates an instance of this axes viewer.
  103625. * @returns a new axes viewer with instanced meshes
  103626. */
  103627. createInstance(): AxesViewer;
  103628. /** Releases resources */
  103629. dispose(): void;
  103630. private static _SetRenderingGroupId;
  103631. }
  103632. }
  103633. declare module BABYLON.Debug {
  103634. /**
  103635. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103636. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103637. */
  103638. export class BoneAxesViewer extends AxesViewer {
  103639. /**
  103640. * Gets or sets the target mesh where to display the axes viewer
  103641. */
  103642. mesh: Nullable<Mesh>;
  103643. /**
  103644. * Gets or sets the target bone where to display the axes viewer
  103645. */
  103646. bone: Nullable<Bone>;
  103647. /** Gets current position */
  103648. pos: Vector3;
  103649. /** Gets direction of X axis */
  103650. xaxis: Vector3;
  103651. /** Gets direction of Y axis */
  103652. yaxis: Vector3;
  103653. /** Gets direction of Z axis */
  103654. zaxis: Vector3;
  103655. /**
  103656. * Creates a new BoneAxesViewer
  103657. * @param scene defines the hosting scene
  103658. * @param bone defines the target bone
  103659. * @param mesh defines the target mesh
  103660. * @param scaleLines defines a scaling factor for line length (1 by default)
  103661. */
  103662. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103663. /**
  103664. * Force the viewer to update
  103665. */
  103666. update(): void;
  103667. /** Releases resources */
  103668. dispose(): void;
  103669. }
  103670. }
  103671. declare module BABYLON {
  103672. /**
  103673. * Interface used to define scene explorer extensibility option
  103674. */
  103675. export interface IExplorerExtensibilityOption {
  103676. /**
  103677. * Define the option label
  103678. */
  103679. label: string;
  103680. /**
  103681. * Defines the action to execute on click
  103682. */
  103683. action: (entity: any) => void;
  103684. }
  103685. /**
  103686. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103687. */
  103688. export interface IExplorerExtensibilityGroup {
  103689. /**
  103690. * Defines a predicate to test if a given type mut be extended
  103691. */
  103692. predicate: (entity: any) => boolean;
  103693. /**
  103694. * Gets the list of options added to a type
  103695. */
  103696. entries: IExplorerExtensibilityOption[];
  103697. }
  103698. /**
  103699. * Interface used to define the options to use to create the Inspector
  103700. */
  103701. export interface IInspectorOptions {
  103702. /**
  103703. * Display in overlay mode (default: false)
  103704. */
  103705. overlay?: boolean;
  103706. /**
  103707. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103708. */
  103709. globalRoot?: HTMLElement;
  103710. /**
  103711. * Display the Scene explorer
  103712. */
  103713. showExplorer?: boolean;
  103714. /**
  103715. * Display the property inspector
  103716. */
  103717. showInspector?: boolean;
  103718. /**
  103719. * Display in embed mode (both panes on the right)
  103720. */
  103721. embedMode?: boolean;
  103722. /**
  103723. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103724. */
  103725. handleResize?: boolean;
  103726. /**
  103727. * Allow the panes to popup (default: true)
  103728. */
  103729. enablePopup?: boolean;
  103730. /**
  103731. * Allow the panes to be closed by users (default: true)
  103732. */
  103733. enableClose?: boolean;
  103734. /**
  103735. * Optional list of extensibility entries
  103736. */
  103737. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103738. /**
  103739. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103740. */
  103741. inspectorURL?: string;
  103742. }
  103743. interface Scene {
  103744. /**
  103745. * @hidden
  103746. * Backing field
  103747. */
  103748. _debugLayer: DebugLayer;
  103749. /**
  103750. * Gets the debug layer (aka Inspector) associated with the scene
  103751. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103752. */
  103753. debugLayer: DebugLayer;
  103754. }
  103755. /**
  103756. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103757. * what is happening in your scene
  103758. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103759. */
  103760. export class DebugLayer {
  103761. /**
  103762. * Define the url to get the inspector script from.
  103763. * By default it uses the babylonjs CDN.
  103764. * @ignoreNaming
  103765. */
  103766. static InspectorURL: string;
  103767. private _scene;
  103768. private BJSINSPECTOR;
  103769. /**
  103770. * Observable triggered when a property is changed through the inspector.
  103771. */
  103772. onPropertyChangedObservable: Observable<{
  103773. object: any;
  103774. property: string;
  103775. value: any;
  103776. initialValue: any;
  103777. }>;
  103778. /**
  103779. * Instantiates a new debug layer.
  103780. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103781. * what is happening in your scene
  103782. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103783. * @param scene Defines the scene to inspect
  103784. */
  103785. constructor(scene: Scene);
  103786. /** Creates the inspector window. */
  103787. private _createInspector;
  103788. /**
  103789. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103790. * @param entity defines the entity to select
  103791. * @param lineContainerTitle defines the specific block to highlight
  103792. */
  103793. select(entity: any, lineContainerTitle?: string): void;
  103794. /** Get the inspector from bundle or global */
  103795. private _getGlobalInspector;
  103796. /**
  103797. * Get if the inspector is visible or not.
  103798. * @returns true if visible otherwise, false
  103799. */
  103800. isVisible(): boolean;
  103801. /**
  103802. * Hide the inspector and close its window.
  103803. */
  103804. hide(): void;
  103805. /**
  103806. * Launch the debugLayer.
  103807. * @param config Define the configuration of the inspector
  103808. * @return a promise fulfilled when the debug layer is visible
  103809. */
  103810. show(config?: IInspectorOptions): Promise<DebugLayer>;
  103811. }
  103812. }
  103813. declare module BABYLON {
  103814. /**
  103815. * Class containing static functions to help procedurally build meshes
  103816. */
  103817. export class BoxBuilder {
  103818. /**
  103819. * Creates a box mesh
  103820. * * The parameter `size` sets the size (float) of each box side (default 1)
  103821. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103822. * * 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)
  103823. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103827. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103828. * @param name defines the name of the mesh
  103829. * @param options defines the options used to create the mesh
  103830. * @param scene defines the hosting scene
  103831. * @returns the box mesh
  103832. */
  103833. static CreateBox(name: string, options: {
  103834. size?: number;
  103835. width?: number;
  103836. height?: number;
  103837. depth?: number;
  103838. faceUV?: Vector4[];
  103839. faceColors?: Color4[];
  103840. sideOrientation?: number;
  103841. frontUVs?: Vector4;
  103842. backUVs?: Vector4;
  103843. wrap?: boolean;
  103844. topBaseAt?: number;
  103845. bottomBaseAt?: number;
  103846. updatable?: boolean;
  103847. }, scene?: Nullable<Scene>): Mesh;
  103848. }
  103849. }
  103850. declare module BABYLON {
  103851. /**
  103852. * Class containing static functions to help procedurally build meshes
  103853. */
  103854. export class SphereBuilder {
  103855. /**
  103856. * Creates a sphere mesh
  103857. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103858. * * 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`)
  103859. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103860. * * 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
  103861. * * 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)
  103862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103865. * @param name defines the name of the mesh
  103866. * @param options defines the options used to create the mesh
  103867. * @param scene defines the hosting scene
  103868. * @returns the sphere mesh
  103869. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103870. */
  103871. static CreateSphere(name: string, options: {
  103872. segments?: number;
  103873. diameter?: number;
  103874. diameterX?: number;
  103875. diameterY?: number;
  103876. diameterZ?: number;
  103877. arc?: number;
  103878. slice?: number;
  103879. sideOrientation?: number;
  103880. frontUVs?: Vector4;
  103881. backUVs?: Vector4;
  103882. updatable?: boolean;
  103883. }, scene: any): Mesh;
  103884. }
  103885. }
  103886. declare module BABYLON.Debug {
  103887. /**
  103888. * Used to show the physics impostor around the specific mesh
  103889. */
  103890. export class PhysicsViewer {
  103891. /** @hidden */
  103892. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  103893. /** @hidden */
  103894. protected _meshes: Array<Nullable<AbstractMesh>>;
  103895. /** @hidden */
  103896. protected _scene: Nullable<Scene>;
  103897. /** @hidden */
  103898. protected _numMeshes: number;
  103899. /** @hidden */
  103900. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  103901. private _renderFunction;
  103902. private _utilityLayer;
  103903. private _debugBoxMesh;
  103904. private _debugSphereMesh;
  103905. private _debugCylinderMesh;
  103906. private _debugMaterial;
  103907. private _debugMeshMeshes;
  103908. /**
  103909. * Creates a new PhysicsViewer
  103910. * @param scene defines the hosting scene
  103911. */
  103912. constructor(scene: Scene);
  103913. /** @hidden */
  103914. protected _updateDebugMeshes(): void;
  103915. /**
  103916. * Renders a specified physic impostor
  103917. * @param impostor defines the impostor to render
  103918. * @param targetMesh defines the mesh represented by the impostor
  103919. * @returns the new debug mesh used to render the impostor
  103920. */
  103921. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  103922. /**
  103923. * Hides a specified physic impostor
  103924. * @param impostor defines the impostor to hide
  103925. */
  103926. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  103927. private _getDebugMaterial;
  103928. private _getDebugBoxMesh;
  103929. private _getDebugSphereMesh;
  103930. private _getDebugCylinderMesh;
  103931. private _getDebugMeshMesh;
  103932. private _getDebugMesh;
  103933. /** Releases all resources */
  103934. dispose(): void;
  103935. }
  103936. }
  103937. declare module BABYLON {
  103938. /**
  103939. * Class containing static functions to help procedurally build meshes
  103940. */
  103941. export class LinesBuilder {
  103942. /**
  103943. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103944. * * 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
  103945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103946. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103947. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103948. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103949. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103950. * * 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
  103951. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103954. * @param name defines the name of the new line system
  103955. * @param options defines the options used to create the line system
  103956. * @param scene defines the hosting scene
  103957. * @returns a new line system mesh
  103958. */
  103959. static CreateLineSystem(name: string, options: {
  103960. lines: Vector3[][];
  103961. updatable?: boolean;
  103962. instance?: Nullable<LinesMesh>;
  103963. colors?: Nullable<Color4[][]>;
  103964. useVertexAlpha?: boolean;
  103965. }, scene: Nullable<Scene>): LinesMesh;
  103966. /**
  103967. * Creates a line mesh
  103968. * 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
  103969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103970. * * The parameter `points` is an array successive Vector3
  103971. * * 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
  103972. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103974. * * When updating an instance, remember that only point positions can change, not the number of points
  103975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103977. * @param name defines the name of the new line system
  103978. * @param options defines the options used to create the line system
  103979. * @param scene defines the hosting scene
  103980. * @returns a new line mesh
  103981. */
  103982. static CreateLines(name: string, options: {
  103983. points: Vector3[];
  103984. updatable?: boolean;
  103985. instance?: Nullable<LinesMesh>;
  103986. colors?: Color4[];
  103987. useVertexAlpha?: boolean;
  103988. }, scene?: Nullable<Scene>): LinesMesh;
  103989. /**
  103990. * Creates a dashed line mesh
  103991. * * 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
  103992. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103993. * * The parameter `points` is an array successive Vector3
  103994. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103995. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103996. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103997. * * 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
  103998. * * When updating an instance, remember that only point positions can change, not the number of points
  103999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104000. * @param name defines the name of the mesh
  104001. * @param options defines the options used to create the mesh
  104002. * @param scene defines the hosting scene
  104003. * @returns the dashed line mesh
  104004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104005. */
  104006. static CreateDashedLines(name: string, options: {
  104007. points: Vector3[];
  104008. dashSize?: number;
  104009. gapSize?: number;
  104010. dashNb?: number;
  104011. updatable?: boolean;
  104012. instance?: LinesMesh;
  104013. }, scene?: Nullable<Scene>): LinesMesh;
  104014. }
  104015. }
  104016. declare module BABYLON {
  104017. /**
  104018. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104019. * in order to better appreciate the issue one might have.
  104020. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104021. */
  104022. export class RayHelper {
  104023. /**
  104024. * Defines the ray we are currently tryin to visualize.
  104025. */
  104026. ray: Nullable<Ray>;
  104027. private _renderPoints;
  104028. private _renderLine;
  104029. private _renderFunction;
  104030. private _scene;
  104031. private _updateToMeshFunction;
  104032. private _attachedToMesh;
  104033. private _meshSpaceDirection;
  104034. private _meshSpaceOrigin;
  104035. /**
  104036. * Helper function to create a colored helper in a scene in one line.
  104037. * @param ray Defines the ray we are currently tryin to visualize
  104038. * @param scene Defines the scene the ray is used in
  104039. * @param color Defines the color we want to see the ray in
  104040. * @returns The newly created ray helper.
  104041. */
  104042. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104043. /**
  104044. * Instantiate a new ray helper.
  104045. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104046. * in order to better appreciate the issue one might have.
  104047. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104048. * @param ray Defines the ray we are currently tryin to visualize
  104049. */
  104050. constructor(ray: Ray);
  104051. /**
  104052. * Shows the ray we are willing to debug.
  104053. * @param scene Defines the scene the ray needs to be rendered in
  104054. * @param color Defines the color the ray needs to be rendered in
  104055. */
  104056. show(scene: Scene, color?: Color3): void;
  104057. /**
  104058. * Hides the ray we are debugging.
  104059. */
  104060. hide(): void;
  104061. private _render;
  104062. /**
  104063. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104064. * @param mesh Defines the mesh we want the helper attached to
  104065. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104066. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104067. * @param length Defines the length of the ray
  104068. */
  104069. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104070. /**
  104071. * Detach the ray helper from the mesh it has previously been attached to.
  104072. */
  104073. detachFromMesh(): void;
  104074. private _updateToMesh;
  104075. /**
  104076. * Dispose the helper and release its associated resources.
  104077. */
  104078. dispose(): void;
  104079. }
  104080. }
  104081. declare module BABYLON.Debug {
  104082. /**
  104083. * Class used to render a debug view of a given skeleton
  104084. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104085. */
  104086. export class SkeletonViewer {
  104087. /** defines the skeleton to render */
  104088. skeleton: Skeleton;
  104089. /** defines the mesh attached to the skeleton */
  104090. mesh: AbstractMesh;
  104091. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104092. autoUpdateBonesMatrices: boolean;
  104093. /** defines the rendering group id to use with the viewer */
  104094. renderingGroupId: number;
  104095. /** Gets or sets the color used to render the skeleton */
  104096. color: Color3;
  104097. private _scene;
  104098. private _debugLines;
  104099. private _debugMesh;
  104100. private _isEnabled;
  104101. private _renderFunction;
  104102. private _utilityLayer;
  104103. /**
  104104. * Returns the mesh used to render the bones
  104105. */
  104106. readonly debugMesh: Nullable<LinesMesh>;
  104107. /**
  104108. * Creates a new SkeletonViewer
  104109. * @param skeleton defines the skeleton to render
  104110. * @param mesh defines the mesh attached to the skeleton
  104111. * @param scene defines the hosting scene
  104112. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104113. * @param renderingGroupId defines the rendering group id to use with the viewer
  104114. */
  104115. constructor(
  104116. /** defines the skeleton to render */
  104117. skeleton: Skeleton,
  104118. /** defines the mesh attached to the skeleton */
  104119. mesh: AbstractMesh, scene: Scene,
  104120. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104121. autoUpdateBonesMatrices?: boolean,
  104122. /** defines the rendering group id to use with the viewer */
  104123. renderingGroupId?: number);
  104124. /** Gets or sets a boolean indicating if the viewer is enabled */
  104125. isEnabled: boolean;
  104126. private _getBonePosition;
  104127. private _getLinesForBonesWithLength;
  104128. private _getLinesForBonesNoLength;
  104129. /** Update the viewer to sync with current skeleton state */
  104130. update(): void;
  104131. /** Release associated resources */
  104132. dispose(): void;
  104133. }
  104134. }
  104135. declare module BABYLON {
  104136. /**
  104137. * Options to create the null engine
  104138. */
  104139. export class NullEngineOptions {
  104140. /**
  104141. * Render width (Default: 512)
  104142. */
  104143. renderWidth: number;
  104144. /**
  104145. * Render height (Default: 256)
  104146. */
  104147. renderHeight: number;
  104148. /**
  104149. * Texture size (Default: 512)
  104150. */
  104151. textureSize: number;
  104152. /**
  104153. * If delta time between frames should be constant
  104154. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104155. */
  104156. deterministicLockstep: boolean;
  104157. /**
  104158. * Maximum about of steps between frames (Default: 4)
  104159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104160. */
  104161. lockstepMaxSteps: number;
  104162. }
  104163. /**
  104164. * The null engine class provides support for headless version of babylon.js.
  104165. * This can be used in server side scenario or for testing purposes
  104166. */
  104167. export class NullEngine extends Engine {
  104168. private _options;
  104169. /**
  104170. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104171. */
  104172. isDeterministicLockStep(): boolean;
  104173. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104174. getLockstepMaxSteps(): number;
  104175. /**
  104176. * Sets hardware scaling, used to save performance if needed
  104177. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104178. */
  104179. getHardwareScalingLevel(): number;
  104180. constructor(options?: NullEngineOptions);
  104181. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104182. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104183. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104184. getRenderWidth(useScreen?: boolean): number;
  104185. getRenderHeight(useScreen?: boolean): number;
  104186. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104187. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104188. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104189. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104190. bindSamplers(effect: Effect): void;
  104191. enableEffect(effect: Effect): void;
  104192. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104193. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104194. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104195. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104196. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104197. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104198. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104199. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104200. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104201. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104202. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104203. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104204. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104205. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104206. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104207. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104208. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104209. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104210. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104211. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104212. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104213. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104214. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104215. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104216. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104217. bindBuffers(vertexBuffers: {
  104218. [key: string]: VertexBuffer;
  104219. }, indexBuffer: DataBuffer, effect: Effect): void;
  104220. wipeCaches(bruteForce?: boolean): void;
  104221. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104222. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104223. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104224. /** @hidden */
  104225. _createTexture(): WebGLTexture;
  104226. /** @hidden */
  104227. _releaseTexture(texture: InternalTexture): void;
  104228. 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;
  104229. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104230. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104231. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104232. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104233. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104234. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104235. areAllEffectsReady(): boolean;
  104236. /**
  104237. * @hidden
  104238. * Get the current error code of the webGL context
  104239. * @returns the error code
  104240. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104241. */
  104242. getError(): number;
  104243. /** @hidden */
  104244. _getUnpackAlignement(): number;
  104245. /** @hidden */
  104246. _unpackFlipY(value: boolean): void;
  104247. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104248. /**
  104249. * Updates a dynamic vertex buffer.
  104250. * @param vertexBuffer the vertex buffer to update
  104251. * @param data the data used to update the vertex buffer
  104252. * @param byteOffset the byte offset of the data (optional)
  104253. * @param byteLength the byte length of the data (optional)
  104254. */
  104255. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104256. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104257. /** @hidden */
  104258. _bindTexture(channel: number, texture: InternalTexture): void;
  104259. /** @hidden */
  104260. _releaseBuffer(buffer: DataBuffer): boolean;
  104261. releaseEffects(): void;
  104262. displayLoadingUI(): void;
  104263. hideLoadingUI(): void;
  104264. /** @hidden */
  104265. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104266. /** @hidden */
  104267. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104268. /** @hidden */
  104269. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104270. /** @hidden */
  104271. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104272. }
  104273. }
  104274. declare module BABYLON {
  104275. /** @hidden */
  104276. export class _OcclusionDataStorage {
  104277. /** @hidden */
  104278. occlusionInternalRetryCounter: number;
  104279. /** @hidden */
  104280. isOcclusionQueryInProgress: boolean;
  104281. /** @hidden */
  104282. isOccluded: boolean;
  104283. /** @hidden */
  104284. occlusionRetryCount: number;
  104285. /** @hidden */
  104286. occlusionType: number;
  104287. /** @hidden */
  104288. occlusionQueryAlgorithmType: number;
  104289. }
  104290. interface Engine {
  104291. /**
  104292. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104293. * @return the new query
  104294. */
  104295. createQuery(): WebGLQuery;
  104296. /**
  104297. * Delete and release a webGL query
  104298. * @param query defines the query to delete
  104299. * @return the current engine
  104300. */
  104301. deleteQuery(query: WebGLQuery): Engine;
  104302. /**
  104303. * Check if a given query has resolved and got its value
  104304. * @param query defines the query to check
  104305. * @returns true if the query got its value
  104306. */
  104307. isQueryResultAvailable(query: WebGLQuery): boolean;
  104308. /**
  104309. * Gets the value of a given query
  104310. * @param query defines the query to check
  104311. * @returns the value of the query
  104312. */
  104313. getQueryResult(query: WebGLQuery): number;
  104314. /**
  104315. * Initiates an occlusion query
  104316. * @param algorithmType defines the algorithm to use
  104317. * @param query defines the query to use
  104318. * @returns the current engine
  104319. * @see http://doc.babylonjs.com/features/occlusionquery
  104320. */
  104321. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104322. /**
  104323. * Ends an occlusion query
  104324. * @see http://doc.babylonjs.com/features/occlusionquery
  104325. * @param algorithmType defines the algorithm to use
  104326. * @returns the current engine
  104327. */
  104328. endOcclusionQuery(algorithmType: number): Engine;
  104329. /**
  104330. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104331. * Please note that only one query can be issued at a time
  104332. * @returns a time token used to track the time span
  104333. */
  104334. startTimeQuery(): Nullable<_TimeToken>;
  104335. /**
  104336. * Ends a time query
  104337. * @param token defines the token used to measure the time span
  104338. * @returns the time spent (in ns)
  104339. */
  104340. endTimeQuery(token: _TimeToken): int;
  104341. /** @hidden */
  104342. _currentNonTimestampToken: Nullable<_TimeToken>;
  104343. /** @hidden */
  104344. _createTimeQuery(): WebGLQuery;
  104345. /** @hidden */
  104346. _deleteTimeQuery(query: WebGLQuery): void;
  104347. /** @hidden */
  104348. _getGlAlgorithmType(algorithmType: number): number;
  104349. /** @hidden */
  104350. _getTimeQueryResult(query: WebGLQuery): any;
  104351. /** @hidden */
  104352. _getTimeQueryAvailability(query: WebGLQuery): any;
  104353. }
  104354. interface AbstractMesh {
  104355. /**
  104356. * Backing filed
  104357. * @hidden
  104358. */
  104359. __occlusionDataStorage: _OcclusionDataStorage;
  104360. /**
  104361. * Access property
  104362. * @hidden
  104363. */
  104364. _occlusionDataStorage: _OcclusionDataStorage;
  104365. /**
  104366. * 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.
  104367. * The default value is -1 which means don't break the query and wait till the result
  104368. * @see http://doc.babylonjs.com/features/occlusionquery
  104369. */
  104370. occlusionRetryCount: number;
  104371. /**
  104372. * 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:
  104373. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104374. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104375. * * 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.
  104376. * @see http://doc.babylonjs.com/features/occlusionquery
  104377. */
  104378. occlusionType: number;
  104379. /**
  104380. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104381. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104382. * * 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.
  104383. * @see http://doc.babylonjs.com/features/occlusionquery
  104384. */
  104385. occlusionQueryAlgorithmType: number;
  104386. /**
  104387. * 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
  104388. * @see http://doc.babylonjs.com/features/occlusionquery
  104389. */
  104390. isOccluded: boolean;
  104391. /**
  104392. * Flag to check the progress status of the query
  104393. * @see http://doc.babylonjs.com/features/occlusionquery
  104394. */
  104395. isOcclusionQueryInProgress: boolean;
  104396. }
  104397. }
  104398. declare module BABYLON {
  104399. /** @hidden */
  104400. export var _forceTransformFeedbackToBundle: boolean;
  104401. interface Engine {
  104402. /**
  104403. * Creates a webGL transform feedback object
  104404. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104405. * @returns the webGL transform feedback object
  104406. */
  104407. createTransformFeedback(): WebGLTransformFeedback;
  104408. /**
  104409. * Delete a webGL transform feedback object
  104410. * @param value defines the webGL transform feedback object to delete
  104411. */
  104412. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104413. /**
  104414. * Bind a webGL transform feedback object to the webgl context
  104415. * @param value defines the webGL transform feedback object to bind
  104416. */
  104417. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104418. /**
  104419. * Begins a transform feedback operation
  104420. * @param usePoints defines if points or triangles must be used
  104421. */
  104422. beginTransformFeedback(usePoints: boolean): void;
  104423. /**
  104424. * Ends a transform feedback operation
  104425. */
  104426. endTransformFeedback(): void;
  104427. /**
  104428. * Specify the varyings to use with transform feedback
  104429. * @param program defines the associated webGL program
  104430. * @param value defines the list of strings representing the varying names
  104431. */
  104432. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104433. /**
  104434. * Bind a webGL buffer for a transform feedback operation
  104435. * @param value defines the webGL buffer to bind
  104436. */
  104437. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104438. }
  104439. }
  104440. declare module BABYLON {
  104441. /**
  104442. * Creation options of the multi render target texture.
  104443. */
  104444. export interface IMultiRenderTargetOptions {
  104445. /**
  104446. * Define if the texture needs to create mip maps after render.
  104447. */
  104448. generateMipMaps?: boolean;
  104449. /**
  104450. * Define the types of all the draw buffers we want to create
  104451. */
  104452. types?: number[];
  104453. /**
  104454. * Define the sampling modes of all the draw buffers we want to create
  104455. */
  104456. samplingModes?: number[];
  104457. /**
  104458. * Define if a depth buffer is required
  104459. */
  104460. generateDepthBuffer?: boolean;
  104461. /**
  104462. * Define if a stencil buffer is required
  104463. */
  104464. generateStencilBuffer?: boolean;
  104465. /**
  104466. * Define if a depth texture is required instead of a depth buffer
  104467. */
  104468. generateDepthTexture?: boolean;
  104469. /**
  104470. * Define the number of desired draw buffers
  104471. */
  104472. textureCount?: number;
  104473. /**
  104474. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104475. */
  104476. doNotChangeAspectRatio?: boolean;
  104477. /**
  104478. * Define the default type of the buffers we are creating
  104479. */
  104480. defaultType?: number;
  104481. }
  104482. /**
  104483. * A multi render target, like a render target provides the ability to render to a texture.
  104484. * Unlike the render target, it can render to several draw buffers in one draw.
  104485. * This is specially interesting in deferred rendering or for any effects requiring more than
  104486. * just one color from a single pass.
  104487. */
  104488. export class MultiRenderTarget extends RenderTargetTexture {
  104489. private _internalTextures;
  104490. private _textures;
  104491. private _multiRenderTargetOptions;
  104492. /**
  104493. * Get if draw buffers are currently supported by the used hardware and browser.
  104494. */
  104495. readonly isSupported: boolean;
  104496. /**
  104497. * Get the list of textures generated by the multi render target.
  104498. */
  104499. readonly textures: Texture[];
  104500. /**
  104501. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104502. */
  104503. readonly depthTexture: Texture;
  104504. /**
  104505. * Set the wrapping mode on U of all the textures we are rendering to.
  104506. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104507. */
  104508. wrapU: number;
  104509. /**
  104510. * Set the wrapping mode on V of all the textures we are rendering to.
  104511. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104512. */
  104513. wrapV: number;
  104514. /**
  104515. * Instantiate a new multi render target texture.
  104516. * A multi render target, like a render target provides the ability to render to a texture.
  104517. * Unlike the render target, it can render to several draw buffers in one draw.
  104518. * This is specially interesting in deferred rendering or for any effects requiring more than
  104519. * just one color from a single pass.
  104520. * @param name Define the name of the texture
  104521. * @param size Define the size of the buffers to render to
  104522. * @param count Define the number of target we are rendering into
  104523. * @param scene Define the scene the texture belongs to
  104524. * @param options Define the options used to create the multi render target
  104525. */
  104526. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104527. /** @hidden */
  104528. _rebuild(): void;
  104529. private _createInternalTextures;
  104530. private _createTextures;
  104531. /**
  104532. * Define the number of samples used if MSAA is enabled.
  104533. */
  104534. samples: number;
  104535. /**
  104536. * Resize all the textures in the multi render target.
  104537. * Be carrefull as it will recreate all the data in the new texture.
  104538. * @param size Define the new size
  104539. */
  104540. resize(size: any): void;
  104541. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104542. /**
  104543. * Dispose the render targets and their associated resources
  104544. */
  104545. dispose(): void;
  104546. /**
  104547. * Release all the underlying texture used as draw buffers.
  104548. */
  104549. releaseInternalTextures(): void;
  104550. }
  104551. }
  104552. declare module BABYLON {
  104553. interface Engine {
  104554. /**
  104555. * Unbind a list of render target textures from the webGL context
  104556. * This is used only when drawBuffer extension or webGL2 are active
  104557. * @param textures defines the render target textures to unbind
  104558. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104559. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104560. */
  104561. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104562. /**
  104563. * Create a multi render target texture
  104564. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104565. * @param size defines the size of the texture
  104566. * @param options defines the creation options
  104567. * @returns the cube texture as an InternalTexture
  104568. */
  104569. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104570. /**
  104571. * Update the sample count for a given multiple render target texture
  104572. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104573. * @param textures defines the textures to update
  104574. * @param samples defines the sample count to set
  104575. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104576. */
  104577. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104578. }
  104579. }
  104580. declare module BABYLON {
  104581. /**
  104582. * Gather the list of clipboard event types as constants.
  104583. */
  104584. export class ClipboardEventTypes {
  104585. /**
  104586. * The clipboard event is fired when a copy command is active (pressed).
  104587. */
  104588. static readonly COPY: number;
  104589. /**
  104590. * The clipboard event is fired when a cut command is active (pressed).
  104591. */
  104592. static readonly CUT: number;
  104593. /**
  104594. * The clipboard event is fired when a paste command is active (pressed).
  104595. */
  104596. static readonly PASTE: number;
  104597. }
  104598. /**
  104599. * This class is used to store clipboard related info for the onClipboardObservable event.
  104600. */
  104601. export class ClipboardInfo {
  104602. /**
  104603. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104604. */
  104605. type: number;
  104606. /**
  104607. * Defines the related dom event
  104608. */
  104609. event: ClipboardEvent;
  104610. /**
  104611. *Creates an instance of ClipboardInfo.
  104612. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104613. * @param event Defines the related dom event
  104614. */
  104615. constructor(
  104616. /**
  104617. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104618. */
  104619. type: number,
  104620. /**
  104621. * Defines the related dom event
  104622. */
  104623. event: ClipboardEvent);
  104624. /**
  104625. * Get the clipboard event's type from the keycode.
  104626. * @param keyCode Defines the keyCode for the current keyboard event.
  104627. * @return {number}
  104628. */
  104629. static GetTypeFromCharacter(keyCode: number): number;
  104630. }
  104631. }
  104632. declare module BABYLON {
  104633. /**
  104634. * Class used to represent data loading progression
  104635. */
  104636. export class SceneLoaderProgressEvent {
  104637. /** defines if data length to load can be evaluated */
  104638. readonly lengthComputable: boolean;
  104639. /** defines the loaded data length */
  104640. readonly loaded: number;
  104641. /** defines the data length to load */
  104642. readonly total: number;
  104643. /**
  104644. * Create a new progress event
  104645. * @param lengthComputable defines if data length to load can be evaluated
  104646. * @param loaded defines the loaded data length
  104647. * @param total defines the data length to load
  104648. */
  104649. constructor(
  104650. /** defines if data length to load can be evaluated */
  104651. lengthComputable: boolean,
  104652. /** defines the loaded data length */
  104653. loaded: number,
  104654. /** defines the data length to load */
  104655. total: number);
  104656. /**
  104657. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104658. * @param event defines the source event
  104659. * @returns a new SceneLoaderProgressEvent
  104660. */
  104661. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104662. }
  104663. /**
  104664. * Interface used by SceneLoader plugins to define supported file extensions
  104665. */
  104666. export interface ISceneLoaderPluginExtensions {
  104667. /**
  104668. * Defines the list of supported extensions
  104669. */
  104670. [extension: string]: {
  104671. isBinary: boolean;
  104672. };
  104673. }
  104674. /**
  104675. * Interface used by SceneLoader plugin factory
  104676. */
  104677. export interface ISceneLoaderPluginFactory {
  104678. /**
  104679. * Defines the name of the factory
  104680. */
  104681. name: string;
  104682. /**
  104683. * Function called to create a new plugin
  104684. * @return the new plugin
  104685. */
  104686. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104687. /**
  104688. * Boolean indicating if the plugin can direct load specific data
  104689. */
  104690. canDirectLoad?: (data: string) => boolean;
  104691. }
  104692. /**
  104693. * Interface used to define a SceneLoader plugin
  104694. */
  104695. export interface ISceneLoaderPlugin {
  104696. /**
  104697. * The friendly name of this plugin.
  104698. */
  104699. name: string;
  104700. /**
  104701. * The file extensions supported by this plugin.
  104702. */
  104703. extensions: string | ISceneLoaderPluginExtensions;
  104704. /**
  104705. * Import meshes into a scene.
  104706. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104707. * @param scene The scene to import into
  104708. * @param data The data to import
  104709. * @param rootUrl The root url for scene and resources
  104710. * @param meshes The meshes array to import into
  104711. * @param particleSystems The particle systems array to import into
  104712. * @param skeletons The skeletons array to import into
  104713. * @param onError The callback when import fails
  104714. * @returns True if successful or false otherwise
  104715. */
  104716. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104717. /**
  104718. * Load into a scene.
  104719. * @param scene The scene to load into
  104720. * @param data The data to import
  104721. * @param rootUrl The root url for scene and resources
  104722. * @param onError The callback when import fails
  104723. * @returns true if successful or false otherwise
  104724. */
  104725. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104726. /**
  104727. * The callback that returns true if the data can be directly loaded.
  104728. */
  104729. canDirectLoad?: (data: string) => boolean;
  104730. /**
  104731. * The callback that allows custom handling of the root url based on the response url.
  104732. */
  104733. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104734. /**
  104735. * Load into an asset container.
  104736. * @param scene The scene to load into
  104737. * @param data The data to import
  104738. * @param rootUrl The root url for scene and resources
  104739. * @param onError The callback when import fails
  104740. * @returns The loaded asset container
  104741. */
  104742. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104743. }
  104744. /**
  104745. * Interface used to define an async SceneLoader plugin
  104746. */
  104747. export interface ISceneLoaderPluginAsync {
  104748. /**
  104749. * The friendly name of this plugin.
  104750. */
  104751. name: string;
  104752. /**
  104753. * The file extensions supported by this plugin.
  104754. */
  104755. extensions: string | ISceneLoaderPluginExtensions;
  104756. /**
  104757. * Import meshes into a scene.
  104758. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104759. * @param scene The scene to import into
  104760. * @param data The data to import
  104761. * @param rootUrl The root url for scene and resources
  104762. * @param onProgress The callback when the load progresses
  104763. * @param fileName Defines the name of the file to load
  104764. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104765. */
  104766. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104767. meshes: AbstractMesh[];
  104768. particleSystems: IParticleSystem[];
  104769. skeletons: Skeleton[];
  104770. animationGroups: AnimationGroup[];
  104771. }>;
  104772. /**
  104773. * Load into a scene.
  104774. * @param scene The scene to load into
  104775. * @param data The data to import
  104776. * @param rootUrl The root url for scene and resources
  104777. * @param onProgress The callback when the load progresses
  104778. * @param fileName Defines the name of the file to load
  104779. * @returns Nothing
  104780. */
  104781. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104782. /**
  104783. * The callback that returns true if the data can be directly loaded.
  104784. */
  104785. canDirectLoad?: (data: string) => boolean;
  104786. /**
  104787. * The callback that allows custom handling of the root url based on the response url.
  104788. */
  104789. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104790. /**
  104791. * Load into an asset container.
  104792. * @param scene The scene to load into
  104793. * @param data The data to import
  104794. * @param rootUrl The root url for scene and resources
  104795. * @param onProgress The callback when the load progresses
  104796. * @param fileName Defines the name of the file to load
  104797. * @returns The loaded asset container
  104798. */
  104799. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104800. }
  104801. /**
  104802. * Class used to load scene from various file formats using registered plugins
  104803. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104804. */
  104805. export class SceneLoader {
  104806. /**
  104807. * No logging while loading
  104808. */
  104809. static readonly NO_LOGGING: number;
  104810. /**
  104811. * Minimal logging while loading
  104812. */
  104813. static readonly MINIMAL_LOGGING: number;
  104814. /**
  104815. * Summary logging while loading
  104816. */
  104817. static readonly SUMMARY_LOGGING: number;
  104818. /**
  104819. * Detailled logging while loading
  104820. */
  104821. static readonly DETAILED_LOGGING: number;
  104822. /**
  104823. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104824. */
  104825. static ForceFullSceneLoadingForIncremental: boolean;
  104826. /**
  104827. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104828. */
  104829. static ShowLoadingScreen: boolean;
  104830. /**
  104831. * Defines the current logging level (while loading the scene)
  104832. * @ignorenaming
  104833. */
  104834. static loggingLevel: number;
  104835. /**
  104836. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104837. */
  104838. static CleanBoneMatrixWeights: boolean;
  104839. /**
  104840. * Event raised when a plugin is used to load a scene
  104841. */
  104842. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  104843. private static _registeredPlugins;
  104844. private static _getDefaultPlugin;
  104845. private static _getPluginForExtension;
  104846. private static _getPluginForDirectLoad;
  104847. private static _getPluginForFilename;
  104848. private static _getDirectLoad;
  104849. private static _loadData;
  104850. private static _getFileInfo;
  104851. /**
  104852. * Gets a plugin that can load the given extension
  104853. * @param extension defines the extension to load
  104854. * @returns a plugin or null if none works
  104855. */
  104856. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  104857. /**
  104858. * Gets a boolean indicating that the given extension can be loaded
  104859. * @param extension defines the extension to load
  104860. * @returns true if the extension is supported
  104861. */
  104862. static IsPluginForExtensionAvailable(extension: string): boolean;
  104863. /**
  104864. * Adds a new plugin to the list of registered plugins
  104865. * @param plugin defines the plugin to add
  104866. */
  104867. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  104868. /**
  104869. * Import meshes into a scene
  104870. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104871. * @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)
  104872. * @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)
  104873. * @param scene the instance of BABYLON.Scene to append to
  104874. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104875. * @param onProgress a callback with a progress event for each file being loaded
  104876. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104877. * @param pluginExtension the extension used to determine the plugin
  104878. * @returns The loaded plugin
  104879. */
  104880. 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>;
  104881. /**
  104882. * Import meshes into a scene
  104883. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104884. * @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)
  104885. * @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)
  104886. * @param scene the instance of BABYLON.Scene to append to
  104887. * @param onProgress a callback with a progress event for each file being loaded
  104888. * @param pluginExtension the extension used to determine the plugin
  104889. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104890. */
  104891. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104892. meshes: AbstractMesh[];
  104893. particleSystems: IParticleSystem[];
  104894. skeletons: Skeleton[];
  104895. animationGroups: AnimationGroup[];
  104896. }>;
  104897. /**
  104898. * Load a scene
  104899. * @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)
  104900. * @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)
  104901. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104902. * @param onSuccess a callback with the scene when import succeeds
  104903. * @param onProgress a callback with a progress event for each file being loaded
  104904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104905. * @param pluginExtension the extension used to determine the plugin
  104906. * @returns The loaded plugin
  104907. */
  104908. 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>;
  104909. /**
  104910. * Load a scene
  104911. * @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)
  104912. * @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)
  104913. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104914. * @param onProgress a callback with a progress event for each file being loaded
  104915. * @param pluginExtension the extension used to determine the plugin
  104916. * @returns The loaded scene
  104917. */
  104918. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104919. /**
  104920. * Append a scene
  104921. * @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)
  104922. * @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)
  104923. * @param scene is the instance of BABYLON.Scene to append to
  104924. * @param onSuccess a callback with the scene when import succeeds
  104925. * @param onProgress a callback with a progress event for each file being loaded
  104926. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104927. * @param pluginExtension the extension used to determine the plugin
  104928. * @returns The loaded plugin
  104929. */
  104930. 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>;
  104931. /**
  104932. * Append a scene
  104933. * @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)
  104934. * @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)
  104935. * @param scene is the instance of BABYLON.Scene to append to
  104936. * @param onProgress a callback with a progress event for each file being loaded
  104937. * @param pluginExtension the extension used to determine the plugin
  104938. * @returns The given scene
  104939. */
  104940. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104941. /**
  104942. * Load a scene into an asset container
  104943. * @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)
  104944. * @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)
  104945. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104946. * @param onSuccess a callback with the scene when import succeeds
  104947. * @param onProgress a callback with a progress event for each file being loaded
  104948. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104949. * @param pluginExtension the extension used to determine the plugin
  104950. * @returns The loaded plugin
  104951. */
  104952. 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>;
  104953. /**
  104954. * Load a scene into an asset container
  104955. * @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)
  104956. * @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)
  104957. * @param scene is the instance of Scene to append to
  104958. * @param onProgress a callback with a progress event for each file being loaded
  104959. * @param pluginExtension the extension used to determine the plugin
  104960. * @returns The loaded asset container
  104961. */
  104962. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104963. }
  104964. }
  104965. declare module BABYLON {
  104966. /**
  104967. * Google Daydream controller
  104968. */
  104969. export class DaydreamController extends WebVRController {
  104970. /**
  104971. * Base Url for the controller model.
  104972. */
  104973. static MODEL_BASE_URL: string;
  104974. /**
  104975. * File name for the controller model.
  104976. */
  104977. static MODEL_FILENAME: string;
  104978. /**
  104979. * Gamepad Id prefix used to identify Daydream Controller.
  104980. */
  104981. static readonly GAMEPAD_ID_PREFIX: string;
  104982. /**
  104983. * Creates a new DaydreamController from a gamepad
  104984. * @param vrGamepad the gamepad that the controller should be created from
  104985. */
  104986. constructor(vrGamepad: any);
  104987. /**
  104988. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104989. * @param scene scene in which to add meshes
  104990. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104991. */
  104992. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104993. /**
  104994. * Called once for each button that changed state since the last frame
  104995. * @param buttonIdx Which button index changed
  104996. * @param state New state of the button
  104997. * @param changes Which properties on the state changed since last frame
  104998. */
  104999. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105000. }
  105001. }
  105002. declare module BABYLON {
  105003. /**
  105004. * Gear VR Controller
  105005. */
  105006. export class GearVRController extends WebVRController {
  105007. /**
  105008. * Base Url for the controller model.
  105009. */
  105010. static MODEL_BASE_URL: string;
  105011. /**
  105012. * File name for the controller model.
  105013. */
  105014. static MODEL_FILENAME: string;
  105015. /**
  105016. * Gamepad Id prefix used to identify this controller.
  105017. */
  105018. static readonly GAMEPAD_ID_PREFIX: string;
  105019. private readonly _buttonIndexToObservableNameMap;
  105020. /**
  105021. * Creates a new GearVRController from a gamepad
  105022. * @param vrGamepad the gamepad that the controller should be created from
  105023. */
  105024. constructor(vrGamepad: any);
  105025. /**
  105026. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105027. * @param scene scene in which to add meshes
  105028. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105029. */
  105030. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105031. /**
  105032. * Called once for each button that changed state since the last frame
  105033. * @param buttonIdx Which button index changed
  105034. * @param state New state of the button
  105035. * @param changes Which properties on the state changed since last frame
  105036. */
  105037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105038. }
  105039. }
  105040. declare module BABYLON {
  105041. /**
  105042. * Generic Controller
  105043. */
  105044. export class GenericController extends WebVRController {
  105045. /**
  105046. * Base Url for the controller model.
  105047. */
  105048. static readonly MODEL_BASE_URL: string;
  105049. /**
  105050. * File name for the controller model.
  105051. */
  105052. static readonly MODEL_FILENAME: string;
  105053. /**
  105054. * Creates a new GenericController from a gamepad
  105055. * @param vrGamepad the gamepad that the controller should be created from
  105056. */
  105057. constructor(vrGamepad: any);
  105058. /**
  105059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105060. * @param scene scene in which to add meshes
  105061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105062. */
  105063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105064. /**
  105065. * Called once for each button that changed state since the last frame
  105066. * @param buttonIdx Which button index changed
  105067. * @param state New state of the button
  105068. * @param changes Which properties on the state changed since last frame
  105069. */
  105070. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /**
  105075. * Oculus Touch Controller
  105076. */
  105077. export class OculusTouchController extends WebVRController {
  105078. /**
  105079. * Base Url for the controller model.
  105080. */
  105081. static MODEL_BASE_URL: string;
  105082. /**
  105083. * File name for the left controller model.
  105084. */
  105085. static MODEL_LEFT_FILENAME: string;
  105086. /**
  105087. * File name for the right controller model.
  105088. */
  105089. static MODEL_RIGHT_FILENAME: string;
  105090. /**
  105091. * Fired when the secondary trigger on this controller is modified
  105092. */
  105093. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105094. /**
  105095. * Fired when the thumb rest on this controller is modified
  105096. */
  105097. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105098. /**
  105099. * Creates a new OculusTouchController from a gamepad
  105100. * @param vrGamepad the gamepad that the controller should be created from
  105101. */
  105102. constructor(vrGamepad: any);
  105103. /**
  105104. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105105. * @param scene scene in which to add meshes
  105106. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105107. */
  105108. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105109. /**
  105110. * Fired when the A button on this controller is modified
  105111. */
  105112. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105113. /**
  105114. * Fired when the B button on this controller is modified
  105115. */
  105116. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105117. /**
  105118. * Fired when the X button on this controller is modified
  105119. */
  105120. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105121. /**
  105122. * Fired when the Y button on this controller is modified
  105123. */
  105124. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105125. /**
  105126. * Called once for each button that changed state since the last frame
  105127. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105128. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105129. * 2) secondary trigger (same)
  105130. * 3) A (right) X (left), touch, pressed = value
  105131. * 4) B / Y
  105132. * 5) thumb rest
  105133. * @param buttonIdx Which button index changed
  105134. * @param state New state of the button
  105135. * @param changes Which properties on the state changed since last frame
  105136. */
  105137. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105138. }
  105139. }
  105140. declare module BABYLON {
  105141. /**
  105142. * Vive Controller
  105143. */
  105144. export class ViveController extends WebVRController {
  105145. /**
  105146. * Base Url for the controller model.
  105147. */
  105148. static MODEL_BASE_URL: string;
  105149. /**
  105150. * File name for the controller model.
  105151. */
  105152. static MODEL_FILENAME: string;
  105153. /**
  105154. * Creates a new ViveController from a gamepad
  105155. * @param vrGamepad the gamepad that the controller should be created from
  105156. */
  105157. constructor(vrGamepad: any);
  105158. /**
  105159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105160. * @param scene scene in which to add meshes
  105161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105162. */
  105163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105164. /**
  105165. * Fired when the left button on this controller is modified
  105166. */
  105167. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105168. /**
  105169. * Fired when the right button on this controller is modified
  105170. */
  105171. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105172. /**
  105173. * Fired when the menu button on this controller is modified
  105174. */
  105175. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105176. /**
  105177. * Called once for each button that changed state since the last frame
  105178. * Vive mapping:
  105179. * 0: touchpad
  105180. * 1: trigger
  105181. * 2: left AND right buttons
  105182. * 3: menu button
  105183. * @param buttonIdx Which button index changed
  105184. * @param state New state of the button
  105185. * @param changes Which properties on the state changed since last frame
  105186. */
  105187. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105188. }
  105189. }
  105190. declare module BABYLON {
  105191. /**
  105192. * Defines the WindowsMotionController object that the state of the windows motion controller
  105193. */
  105194. export class WindowsMotionController extends WebVRController {
  105195. /**
  105196. * The base url used to load the left and right controller models
  105197. */
  105198. static MODEL_BASE_URL: string;
  105199. /**
  105200. * The name of the left controller model file
  105201. */
  105202. static MODEL_LEFT_FILENAME: string;
  105203. /**
  105204. * The name of the right controller model file
  105205. */
  105206. static MODEL_RIGHT_FILENAME: string;
  105207. /**
  105208. * The controller name prefix for this controller type
  105209. */
  105210. static readonly GAMEPAD_ID_PREFIX: string;
  105211. /**
  105212. * The controller id pattern for this controller type
  105213. */
  105214. private static readonly GAMEPAD_ID_PATTERN;
  105215. private _loadedMeshInfo;
  105216. private readonly _mapping;
  105217. /**
  105218. * Fired when the trackpad on this controller is clicked
  105219. */
  105220. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105221. /**
  105222. * Fired when the trackpad on this controller is modified
  105223. */
  105224. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105225. /**
  105226. * The current x and y values of this controller's trackpad
  105227. */
  105228. trackpad: StickValues;
  105229. /**
  105230. * Creates a new WindowsMotionController from a gamepad
  105231. * @param vrGamepad the gamepad that the controller should be created from
  105232. */
  105233. constructor(vrGamepad: any);
  105234. /**
  105235. * Fired when the trigger on this controller is modified
  105236. */
  105237. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105238. /**
  105239. * Fired when the menu button on this controller is modified
  105240. */
  105241. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105242. /**
  105243. * Fired when the grip button on this controller is modified
  105244. */
  105245. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105246. /**
  105247. * Fired when the thumbstick button on this controller is modified
  105248. */
  105249. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105250. /**
  105251. * Fired when the touchpad button on this controller is modified
  105252. */
  105253. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105254. /**
  105255. * Fired when the touchpad values on this controller are modified
  105256. */
  105257. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105258. private _updateTrackpad;
  105259. /**
  105260. * Called once per frame by the engine.
  105261. */
  105262. update(): void;
  105263. /**
  105264. * Called once for each button that changed state since the last frame
  105265. * @param buttonIdx Which button index changed
  105266. * @param state New state of the button
  105267. * @param changes Which properties on the state changed since last frame
  105268. */
  105269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105270. /**
  105271. * Moves the buttons on the controller mesh based on their current state
  105272. * @param buttonName the name of the button to move
  105273. * @param buttonValue the value of the button which determines the buttons new position
  105274. */
  105275. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105276. /**
  105277. * Moves the axis on the controller mesh based on its current state
  105278. * @param axis the index of the axis
  105279. * @param axisValue the value of the axis which determines the meshes new position
  105280. * @hidden
  105281. */
  105282. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105283. /**
  105284. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105285. * @param scene scene in which to add meshes
  105286. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105287. */
  105288. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105289. /**
  105290. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105291. * can be transformed by button presses and axes values, based on this._mapping.
  105292. *
  105293. * @param scene scene in which the meshes exist
  105294. * @param meshes list of meshes that make up the controller model to process
  105295. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105296. */
  105297. private processModel;
  105298. private createMeshInfo;
  105299. /**
  105300. * Gets the ray of the controller in the direction the controller is pointing
  105301. * @param length the length the resulting ray should be
  105302. * @returns a ray in the direction the controller is pointing
  105303. */
  105304. getForwardRay(length?: number): Ray;
  105305. /**
  105306. * Disposes of the controller
  105307. */
  105308. dispose(): void;
  105309. }
  105310. }
  105311. declare module BABYLON {
  105312. /**
  105313. * Class containing static functions to help procedurally build meshes
  105314. */
  105315. export class PolyhedronBuilder {
  105316. /**
  105317. * Creates a polyhedron mesh
  105318. * * 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
  105319. * * The parameter `size` (positive float, default 1) sets the polygon size
  105320. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105321. * * 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`
  105322. * * 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
  105323. * * 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)`)
  105324. * * 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
  105325. * * 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
  105326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105329. * @param name defines the name of the mesh
  105330. * @param options defines the options used to create the mesh
  105331. * @param scene defines the hosting scene
  105332. * @returns the polyhedron mesh
  105333. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105334. */
  105335. static CreatePolyhedron(name: string, options: {
  105336. type?: number;
  105337. size?: number;
  105338. sizeX?: number;
  105339. sizeY?: number;
  105340. sizeZ?: number;
  105341. custom?: any;
  105342. faceUV?: Vector4[];
  105343. faceColors?: Color4[];
  105344. flat?: boolean;
  105345. updatable?: boolean;
  105346. sideOrientation?: number;
  105347. frontUVs?: Vector4;
  105348. backUVs?: Vector4;
  105349. }, scene?: Nullable<Scene>): Mesh;
  105350. }
  105351. }
  105352. declare module BABYLON {
  105353. /**
  105354. * Gizmo that enables scaling a mesh along 3 axis
  105355. */
  105356. export class ScaleGizmo extends Gizmo {
  105357. /**
  105358. * Internal gizmo used for interactions on the x axis
  105359. */
  105360. xGizmo: AxisScaleGizmo;
  105361. /**
  105362. * Internal gizmo used for interactions on the y axis
  105363. */
  105364. yGizmo: AxisScaleGizmo;
  105365. /**
  105366. * Internal gizmo used for interactions on the z axis
  105367. */
  105368. zGizmo: AxisScaleGizmo;
  105369. /**
  105370. * Internal gizmo used to scale all axis equally
  105371. */
  105372. uniformScaleGizmo: AxisScaleGizmo;
  105373. private _meshAttached;
  105374. private _updateGizmoRotationToMatchAttachedMesh;
  105375. private _snapDistance;
  105376. private _scaleRatio;
  105377. private _uniformScalingMesh;
  105378. private _octahedron;
  105379. /** Fires an event when any of it's sub gizmos are dragged */
  105380. onDragStartObservable: Observable<{}>;
  105381. /** Fires an event when any of it's sub gizmos are released from dragging */
  105382. onDragEndObservable: Observable<{}>;
  105383. attachedMesh: Nullable<AbstractMesh>;
  105384. /**
  105385. * Creates a ScaleGizmo
  105386. * @param gizmoLayer The utility layer the gizmo will be added to
  105387. */
  105388. constructor(gizmoLayer?: UtilityLayerRenderer);
  105389. updateGizmoRotationToMatchAttachedMesh: boolean;
  105390. /**
  105391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105392. */
  105393. snapDistance: number;
  105394. /**
  105395. * Ratio for the scale of the gizmo (Default: 1)
  105396. */
  105397. scaleRatio: number;
  105398. /**
  105399. * Disposes of the gizmo
  105400. */
  105401. dispose(): void;
  105402. }
  105403. }
  105404. declare module BABYLON {
  105405. /**
  105406. * Single axis scale gizmo
  105407. */
  105408. export class AxisScaleGizmo extends Gizmo {
  105409. /**
  105410. * Drag behavior responsible for the gizmos dragging interactions
  105411. */
  105412. dragBehavior: PointerDragBehavior;
  105413. private _pointerObserver;
  105414. /**
  105415. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105416. */
  105417. snapDistance: number;
  105418. /**
  105419. * Event that fires each time the gizmo snaps to a new location.
  105420. * * snapDistance is the the change in distance
  105421. */
  105422. onSnapObservable: Observable<{
  105423. snapDistance: number;
  105424. }>;
  105425. /**
  105426. * If the scaling operation should be done on all axis (default: false)
  105427. */
  105428. uniformScaling: boolean;
  105429. private _isEnabled;
  105430. private _parent;
  105431. private _arrow;
  105432. private _coloredMaterial;
  105433. private _hoverMaterial;
  105434. /**
  105435. * Creates an AxisScaleGizmo
  105436. * @param gizmoLayer The utility layer the gizmo will be added to
  105437. * @param dragAxis The axis which the gizmo will be able to scale on
  105438. * @param color The color of the gizmo
  105439. */
  105440. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105441. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105442. /**
  105443. * If the gizmo is enabled
  105444. */
  105445. isEnabled: boolean;
  105446. /**
  105447. * Disposes of the gizmo
  105448. */
  105449. dispose(): void;
  105450. /**
  105451. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105452. * @param mesh The mesh to replace the default mesh of the gizmo
  105453. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105454. */
  105455. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105456. }
  105457. }
  105458. declare module BABYLON {
  105459. /**
  105460. * Bounding box gizmo
  105461. */
  105462. export class BoundingBoxGizmo extends Gizmo {
  105463. private _lineBoundingBox;
  105464. private _rotateSpheresParent;
  105465. private _scaleBoxesParent;
  105466. private _boundingDimensions;
  105467. private _renderObserver;
  105468. private _pointerObserver;
  105469. private _scaleDragSpeed;
  105470. private _tmpQuaternion;
  105471. private _tmpVector;
  105472. private _tmpRotationMatrix;
  105473. /**
  105474. * 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)
  105475. */
  105476. ignoreChildren: boolean;
  105477. /**
  105478. * 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)
  105479. */
  105480. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105481. /**
  105482. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105483. */
  105484. rotationSphereSize: number;
  105485. /**
  105486. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105487. */
  105488. scaleBoxSize: number;
  105489. /**
  105490. * 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)
  105491. */
  105492. fixedDragMeshScreenSize: boolean;
  105493. /**
  105494. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105495. */
  105496. fixedDragMeshScreenSizeDistanceFactor: number;
  105497. /**
  105498. * Fired when a rotation sphere or scale box is dragged
  105499. */
  105500. onDragStartObservable: Observable<{}>;
  105501. /**
  105502. * Fired when a scale box is dragged
  105503. */
  105504. onScaleBoxDragObservable: Observable<{}>;
  105505. /**
  105506. * Fired when a scale box drag is ended
  105507. */
  105508. onScaleBoxDragEndObservable: Observable<{}>;
  105509. /**
  105510. * Fired when a rotation sphere is dragged
  105511. */
  105512. onRotationSphereDragObservable: Observable<{}>;
  105513. /**
  105514. * Fired when a rotation sphere drag is ended
  105515. */
  105516. onRotationSphereDragEndObservable: Observable<{}>;
  105517. /**
  105518. * 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)
  105519. */
  105520. scalePivot: Nullable<Vector3>;
  105521. /**
  105522. * Mesh used as a pivot to rotate the attached mesh
  105523. */
  105524. private _anchorMesh;
  105525. private _existingMeshScale;
  105526. private _dragMesh;
  105527. private pointerDragBehavior;
  105528. private coloredMaterial;
  105529. private hoverColoredMaterial;
  105530. /**
  105531. * Sets the color of the bounding box gizmo
  105532. * @param color the color to set
  105533. */
  105534. setColor(color: Color3): void;
  105535. /**
  105536. * Creates an BoundingBoxGizmo
  105537. * @param gizmoLayer The utility layer the gizmo will be added to
  105538. * @param color The color of the gizmo
  105539. */
  105540. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105541. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105542. private _selectNode;
  105543. /**
  105544. * Updates the bounding box information for the Gizmo
  105545. */
  105546. updateBoundingBox(): void;
  105547. private _updateRotationSpheres;
  105548. private _updateScaleBoxes;
  105549. /**
  105550. * Enables rotation on the specified axis and disables rotation on the others
  105551. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105552. */
  105553. setEnabledRotationAxis(axis: string): void;
  105554. /**
  105555. * Enables/disables scaling
  105556. * @param enable if scaling should be enabled
  105557. */
  105558. setEnabledScaling(enable: boolean): void;
  105559. private _updateDummy;
  105560. /**
  105561. * Enables a pointer drag behavior on the bounding box of the gizmo
  105562. */
  105563. enableDragBehavior(): void;
  105564. /**
  105565. * Disposes of the gizmo
  105566. */
  105567. dispose(): void;
  105568. /**
  105569. * 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)
  105570. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105571. * @returns the bounding box mesh with the passed in mesh as a child
  105572. */
  105573. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105574. /**
  105575. * CustomMeshes are not supported by this gizmo
  105576. * @param mesh The mesh to replace the default mesh of the gizmo
  105577. */
  105578. setCustomMesh(mesh: Mesh): void;
  105579. }
  105580. }
  105581. declare module BABYLON {
  105582. /**
  105583. * Single plane rotation gizmo
  105584. */
  105585. export class PlaneRotationGizmo extends Gizmo {
  105586. /**
  105587. * Drag behavior responsible for the gizmos dragging interactions
  105588. */
  105589. dragBehavior: PointerDragBehavior;
  105590. private _pointerObserver;
  105591. /**
  105592. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105593. */
  105594. snapDistance: number;
  105595. /**
  105596. * Event that fires each time the gizmo snaps to a new location.
  105597. * * snapDistance is the the change in distance
  105598. */
  105599. onSnapObservable: Observable<{
  105600. snapDistance: number;
  105601. }>;
  105602. private _isEnabled;
  105603. private _parent;
  105604. /**
  105605. * Creates a PlaneRotationGizmo
  105606. * @param gizmoLayer The utility layer the gizmo will be added to
  105607. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105608. * @param color The color of the gizmo
  105609. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105610. */
  105611. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105612. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105613. /**
  105614. * If the gizmo is enabled
  105615. */
  105616. isEnabled: boolean;
  105617. /**
  105618. * Disposes of the gizmo
  105619. */
  105620. dispose(): void;
  105621. }
  105622. }
  105623. declare module BABYLON {
  105624. /**
  105625. * Gizmo that enables rotating a mesh along 3 axis
  105626. */
  105627. export class RotationGizmo extends Gizmo {
  105628. /**
  105629. * Internal gizmo used for interactions on the x axis
  105630. */
  105631. xGizmo: PlaneRotationGizmo;
  105632. /**
  105633. * Internal gizmo used for interactions on the y axis
  105634. */
  105635. yGizmo: PlaneRotationGizmo;
  105636. /**
  105637. * Internal gizmo used for interactions on the z axis
  105638. */
  105639. zGizmo: PlaneRotationGizmo;
  105640. /** Fires an event when any of it's sub gizmos are dragged */
  105641. onDragStartObservable: Observable<{}>;
  105642. /** Fires an event when any of it's sub gizmos are released from dragging */
  105643. onDragEndObservable: Observable<{}>;
  105644. private _meshAttached;
  105645. attachedMesh: Nullable<AbstractMesh>;
  105646. /**
  105647. * Creates a RotationGizmo
  105648. * @param gizmoLayer The utility layer the gizmo will be added to
  105649. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105650. */
  105651. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105652. updateGizmoRotationToMatchAttachedMesh: boolean;
  105653. /**
  105654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105655. */
  105656. snapDistance: number;
  105657. /**
  105658. * Ratio for the scale of the gizmo (Default: 1)
  105659. */
  105660. scaleRatio: number;
  105661. /**
  105662. * Disposes of the gizmo
  105663. */
  105664. dispose(): void;
  105665. /**
  105666. * CustomMeshes are not supported by this gizmo
  105667. * @param mesh The mesh to replace the default mesh of the gizmo
  105668. */
  105669. setCustomMesh(mesh: Mesh): void;
  105670. }
  105671. }
  105672. declare module BABYLON {
  105673. /**
  105674. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105675. */
  105676. export class GizmoManager implements IDisposable {
  105677. private scene;
  105678. /**
  105679. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105680. */
  105681. gizmos: {
  105682. positionGizmo: Nullable<PositionGizmo>;
  105683. rotationGizmo: Nullable<RotationGizmo>;
  105684. scaleGizmo: Nullable<ScaleGizmo>;
  105685. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105686. };
  105687. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105688. clearGizmoOnEmptyPointerEvent: boolean;
  105689. /** Fires an event when the manager is attached to a mesh */
  105690. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105691. private _gizmosEnabled;
  105692. private _pointerObserver;
  105693. private _attachedMesh;
  105694. private _boundingBoxColor;
  105695. private _defaultUtilityLayer;
  105696. private _defaultKeepDepthUtilityLayer;
  105697. /**
  105698. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105699. */
  105700. boundingBoxDragBehavior: SixDofDragBehavior;
  105701. /**
  105702. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105703. */
  105704. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105705. /**
  105706. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105707. */
  105708. usePointerToAttachGizmos: boolean;
  105709. /**
  105710. * Utility layer that the bounding box gizmo belongs to
  105711. */
  105712. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  105713. /**
  105714. * Utility layer that all gizmos besides bounding box belong to
  105715. */
  105716. readonly utilityLayer: UtilityLayerRenderer;
  105717. /**
  105718. * Instatiates a gizmo manager
  105719. * @param scene the scene to overlay the gizmos on top of
  105720. */
  105721. constructor(scene: Scene);
  105722. /**
  105723. * Attaches a set of gizmos to the specified mesh
  105724. * @param mesh The mesh the gizmo's should be attached to
  105725. */
  105726. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105727. /**
  105728. * If the position gizmo is enabled
  105729. */
  105730. positionGizmoEnabled: boolean;
  105731. /**
  105732. * If the rotation gizmo is enabled
  105733. */
  105734. rotationGizmoEnabled: boolean;
  105735. /**
  105736. * If the scale gizmo is enabled
  105737. */
  105738. scaleGizmoEnabled: boolean;
  105739. /**
  105740. * If the boundingBox gizmo is enabled
  105741. */
  105742. boundingBoxGizmoEnabled: boolean;
  105743. /**
  105744. * Disposes of the gizmo manager
  105745. */
  105746. dispose(): void;
  105747. }
  105748. }
  105749. declare module BABYLON {
  105750. /**
  105751. * A directional light is defined by a direction (what a surprise!).
  105752. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105753. * 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.
  105754. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105755. */
  105756. export class DirectionalLight extends ShadowLight {
  105757. private _shadowFrustumSize;
  105758. /**
  105759. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105760. */
  105761. /**
  105762. * Specifies a fix frustum size for the shadow generation.
  105763. */
  105764. shadowFrustumSize: number;
  105765. private _shadowOrthoScale;
  105766. /**
  105767. * Gets the shadow projection scale against the optimal computed one.
  105768. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105769. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105770. */
  105771. /**
  105772. * Sets the shadow projection scale against the optimal computed one.
  105773. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105774. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105775. */
  105776. shadowOrthoScale: number;
  105777. /**
  105778. * Automatically compute the projection matrix to best fit (including all the casters)
  105779. * on each frame.
  105780. */
  105781. autoUpdateExtends: boolean;
  105782. private _orthoLeft;
  105783. private _orthoRight;
  105784. private _orthoTop;
  105785. private _orthoBottom;
  105786. /**
  105787. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105788. * The directional light is emitted from everywhere in the given direction.
  105789. * It can cast shadows.
  105790. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105791. * @param name The friendly name of the light
  105792. * @param direction The direction of the light
  105793. * @param scene The scene the light belongs to
  105794. */
  105795. constructor(name: string, direction: Vector3, scene: Scene);
  105796. /**
  105797. * Returns the string "DirectionalLight".
  105798. * @return The class name
  105799. */
  105800. getClassName(): string;
  105801. /**
  105802. * Returns the integer 1.
  105803. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105804. */
  105805. getTypeID(): number;
  105806. /**
  105807. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105808. * Returns the DirectionalLight Shadow projection matrix.
  105809. */
  105810. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105811. /**
  105812. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105813. * Returns the DirectionalLight Shadow projection matrix.
  105814. */
  105815. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105816. /**
  105817. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105818. * Returns the DirectionalLight Shadow projection matrix.
  105819. */
  105820. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105821. protected _buildUniformLayout(): void;
  105822. /**
  105823. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105824. * @param effect The effect to update
  105825. * @param lightIndex The index of the light in the effect to update
  105826. * @returns The directional light
  105827. */
  105828. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105829. /**
  105830. * Gets the minZ used for shadow according to both the scene and the light.
  105831. *
  105832. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105833. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105834. * @param activeCamera The camera we are returning the min for
  105835. * @returns the depth min z
  105836. */
  105837. getDepthMinZ(activeCamera: Camera): number;
  105838. /**
  105839. * Gets the maxZ used for shadow according to both the scene and the light.
  105840. *
  105841. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105842. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105843. * @param activeCamera The camera we are returning the max for
  105844. * @returns the depth max z
  105845. */
  105846. getDepthMaxZ(activeCamera: Camera): number;
  105847. /**
  105848. * Prepares the list of defines specific to the light type.
  105849. * @param defines the list of defines
  105850. * @param lightIndex defines the index of the light for the effect
  105851. */
  105852. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105853. }
  105854. }
  105855. declare module BABYLON {
  105856. /**
  105857. * Class containing static functions to help procedurally build meshes
  105858. */
  105859. export class HemisphereBuilder {
  105860. /**
  105861. * Creates a hemisphere mesh
  105862. * @param name defines the name of the mesh
  105863. * @param options defines the options used to create the mesh
  105864. * @param scene defines the hosting scene
  105865. * @returns the hemisphere mesh
  105866. */
  105867. static CreateHemisphere(name: string, options: {
  105868. segments?: number;
  105869. diameter?: number;
  105870. sideOrientation?: number;
  105871. }, scene: any): Mesh;
  105872. }
  105873. }
  105874. declare module BABYLON {
  105875. /**
  105876. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105877. * These values define a cone of light starting from the position, emitting toward the direction.
  105878. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105879. * and the exponent defines the speed of the decay of the light with distance (reach).
  105880. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105881. */
  105882. export class SpotLight extends ShadowLight {
  105883. private _angle;
  105884. private _innerAngle;
  105885. private _cosHalfAngle;
  105886. private _lightAngleScale;
  105887. private _lightAngleOffset;
  105888. /**
  105889. * Gets the cone angle of the spot light in Radians.
  105890. */
  105891. /**
  105892. * Sets the cone angle of the spot light in Radians.
  105893. */
  105894. angle: number;
  105895. /**
  105896. * Only used in gltf falloff mode, this defines the angle where
  105897. * the directional falloff will start before cutting at angle which could be seen
  105898. * as outer angle.
  105899. */
  105900. /**
  105901. * Only used in gltf falloff mode, this defines the angle where
  105902. * the directional falloff will start before cutting at angle which could be seen
  105903. * as outer angle.
  105904. */
  105905. innerAngle: number;
  105906. private _shadowAngleScale;
  105907. /**
  105908. * Allows scaling the angle of the light for shadow generation only.
  105909. */
  105910. /**
  105911. * Allows scaling the angle of the light for shadow generation only.
  105912. */
  105913. shadowAngleScale: number;
  105914. /**
  105915. * The light decay speed with the distance from the emission spot.
  105916. */
  105917. exponent: number;
  105918. private _projectionTextureMatrix;
  105919. /**
  105920. * Allows reading the projecton texture
  105921. */
  105922. readonly projectionTextureMatrix: Matrix;
  105923. protected _projectionTextureLightNear: number;
  105924. /**
  105925. * Gets the near clip of the Spotlight for texture projection.
  105926. */
  105927. /**
  105928. * Sets the near clip of the Spotlight for texture projection.
  105929. */
  105930. projectionTextureLightNear: number;
  105931. protected _projectionTextureLightFar: number;
  105932. /**
  105933. * Gets the far clip of the Spotlight for texture projection.
  105934. */
  105935. /**
  105936. * Sets the far clip of the Spotlight for texture projection.
  105937. */
  105938. projectionTextureLightFar: number;
  105939. protected _projectionTextureUpDirection: Vector3;
  105940. /**
  105941. * Gets the Up vector of the Spotlight for texture projection.
  105942. */
  105943. /**
  105944. * Sets the Up vector of the Spotlight for texture projection.
  105945. */
  105946. projectionTextureUpDirection: Vector3;
  105947. private _projectionTexture;
  105948. /**
  105949. * Gets the projection texture of the light.
  105950. */
  105951. /**
  105952. * Sets the projection texture of the light.
  105953. */
  105954. projectionTexture: Nullable<BaseTexture>;
  105955. private _projectionTextureViewLightDirty;
  105956. private _projectionTextureProjectionLightDirty;
  105957. private _projectionTextureDirty;
  105958. private _projectionTextureViewTargetVector;
  105959. private _projectionTextureViewLightMatrix;
  105960. private _projectionTextureProjectionLightMatrix;
  105961. private _projectionTextureScalingMatrix;
  105962. /**
  105963. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105964. * It can cast shadows.
  105965. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105966. * @param name The light friendly name
  105967. * @param position The position of the spot light in the scene
  105968. * @param direction The direction of the light in the scene
  105969. * @param angle The cone angle of the light in Radians
  105970. * @param exponent The light decay speed with the distance from the emission spot
  105971. * @param scene The scene the lights belongs to
  105972. */
  105973. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105974. /**
  105975. * Returns the string "SpotLight".
  105976. * @returns the class name
  105977. */
  105978. getClassName(): string;
  105979. /**
  105980. * Returns the integer 2.
  105981. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105982. */
  105983. getTypeID(): number;
  105984. /**
  105985. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105986. */
  105987. protected _setDirection(value: Vector3): void;
  105988. /**
  105989. * Overrides the position setter to recompute the projection texture view light Matrix.
  105990. */
  105991. protected _setPosition(value: Vector3): void;
  105992. /**
  105993. * 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.
  105994. * Returns the SpotLight.
  105995. */
  105996. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105997. protected _computeProjectionTextureViewLightMatrix(): void;
  105998. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105999. /**
  106000. * Main function for light texture projection matrix computing.
  106001. */
  106002. protected _computeProjectionTextureMatrix(): void;
  106003. protected _buildUniformLayout(): void;
  106004. private _computeAngleValues;
  106005. /**
  106006. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106007. * @param effect The effect to update
  106008. * @param lightIndex The index of the light in the effect to update
  106009. * @returns The spot light
  106010. */
  106011. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106012. /**
  106013. * Disposes the light and the associated resources.
  106014. */
  106015. dispose(): void;
  106016. /**
  106017. * Prepares the list of defines specific to the light type.
  106018. * @param defines the list of defines
  106019. * @param lightIndex defines the index of the light for the effect
  106020. */
  106021. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106022. }
  106023. }
  106024. declare module BABYLON {
  106025. /**
  106026. * Gizmo that enables viewing a light
  106027. */
  106028. export class LightGizmo extends Gizmo {
  106029. private _lightMesh;
  106030. private _material;
  106031. private cachedPosition;
  106032. private cachedForward;
  106033. /**
  106034. * Creates a LightGizmo
  106035. * @param gizmoLayer The utility layer the gizmo will be added to
  106036. */
  106037. constructor(gizmoLayer?: UtilityLayerRenderer);
  106038. private _light;
  106039. /**
  106040. * The light that the gizmo is attached to
  106041. */
  106042. light: Nullable<Light>;
  106043. /**
  106044. * @hidden
  106045. * Updates the gizmo to match the attached mesh's position/rotation
  106046. */
  106047. protected _update(): void;
  106048. private static _Scale;
  106049. /**
  106050. * Creates the lines for a light mesh
  106051. */
  106052. private static _createLightLines;
  106053. /**
  106054. * Disposes of the light gizmo
  106055. */
  106056. dispose(): void;
  106057. private static _CreateHemisphericLightMesh;
  106058. private static _CreatePointLightMesh;
  106059. private static _CreateSpotLightMesh;
  106060. private static _CreateDirectionalLightMesh;
  106061. }
  106062. }
  106063. declare module BABYLON {
  106064. /** @hidden */
  106065. export var backgroundFragmentDeclaration: {
  106066. name: string;
  106067. shader: string;
  106068. };
  106069. }
  106070. declare module BABYLON {
  106071. /** @hidden */
  106072. export var backgroundUboDeclaration: {
  106073. name: string;
  106074. shader: string;
  106075. };
  106076. }
  106077. declare module BABYLON {
  106078. /** @hidden */
  106079. export var backgroundPixelShader: {
  106080. name: string;
  106081. shader: string;
  106082. };
  106083. }
  106084. declare module BABYLON {
  106085. /** @hidden */
  106086. export var backgroundVertexDeclaration: {
  106087. name: string;
  106088. shader: string;
  106089. };
  106090. }
  106091. declare module BABYLON {
  106092. /** @hidden */
  106093. export var backgroundVertexShader: {
  106094. name: string;
  106095. shader: string;
  106096. };
  106097. }
  106098. declare module BABYLON {
  106099. /**
  106100. * Background material used to create an efficient environement around your scene.
  106101. */
  106102. export class BackgroundMaterial extends PushMaterial {
  106103. /**
  106104. * Standard reflectance value at parallel view angle.
  106105. */
  106106. static StandardReflectance0: number;
  106107. /**
  106108. * Standard reflectance value at grazing angle.
  106109. */
  106110. static StandardReflectance90: number;
  106111. protected _primaryColor: Color3;
  106112. /**
  106113. * Key light Color (multiply against the environement texture)
  106114. */
  106115. primaryColor: Color3;
  106116. protected __perceptualColor: Nullable<Color3>;
  106117. /**
  106118. * Experimental Internal Use Only.
  106119. *
  106120. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106121. * This acts as a helper to set the primary color to a more "human friendly" value.
  106122. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106123. * output color as close as possible from the chosen value.
  106124. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106125. * part of lighting setup.)
  106126. */
  106127. _perceptualColor: Nullable<Color3>;
  106128. protected _primaryColorShadowLevel: float;
  106129. /**
  106130. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106131. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106132. */
  106133. primaryColorShadowLevel: float;
  106134. protected _primaryColorHighlightLevel: float;
  106135. /**
  106136. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106137. * The primary color is used at the level chosen to define what the white area would look.
  106138. */
  106139. primaryColorHighlightLevel: float;
  106140. protected _reflectionTexture: Nullable<BaseTexture>;
  106141. /**
  106142. * Reflection Texture used in the material.
  106143. * Should be author in a specific way for the best result (refer to the documentation).
  106144. */
  106145. reflectionTexture: Nullable<BaseTexture>;
  106146. protected _reflectionBlur: float;
  106147. /**
  106148. * Reflection Texture level of blur.
  106149. *
  106150. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106151. * texture twice.
  106152. */
  106153. reflectionBlur: float;
  106154. protected _diffuseTexture: Nullable<BaseTexture>;
  106155. /**
  106156. * Diffuse Texture used in the material.
  106157. * Should be author in a specific way for the best result (refer to the documentation).
  106158. */
  106159. diffuseTexture: Nullable<BaseTexture>;
  106160. protected _shadowLights: Nullable<IShadowLight[]>;
  106161. /**
  106162. * Specify the list of lights casting shadow on the material.
  106163. * All scene shadow lights will be included if null.
  106164. */
  106165. shadowLights: Nullable<IShadowLight[]>;
  106166. protected _shadowLevel: float;
  106167. /**
  106168. * Helps adjusting the shadow to a softer level if required.
  106169. * 0 means black shadows and 1 means no shadows.
  106170. */
  106171. shadowLevel: float;
  106172. protected _sceneCenter: Vector3;
  106173. /**
  106174. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106175. * It is usually zero but might be interesting to modify according to your setup.
  106176. */
  106177. sceneCenter: Vector3;
  106178. protected _opacityFresnel: boolean;
  106179. /**
  106180. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106181. * This helps ensuring a nice transition when the camera goes under the ground.
  106182. */
  106183. opacityFresnel: boolean;
  106184. protected _reflectionFresnel: boolean;
  106185. /**
  106186. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106187. * This helps adding a mirror texture on the ground.
  106188. */
  106189. reflectionFresnel: boolean;
  106190. protected _reflectionFalloffDistance: number;
  106191. /**
  106192. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106193. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106194. */
  106195. reflectionFalloffDistance: number;
  106196. protected _reflectionAmount: number;
  106197. /**
  106198. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106199. */
  106200. reflectionAmount: number;
  106201. protected _reflectionReflectance0: number;
  106202. /**
  106203. * This specifies the weight of the reflection at grazing angle.
  106204. */
  106205. reflectionReflectance0: number;
  106206. protected _reflectionReflectance90: number;
  106207. /**
  106208. * This specifies the weight of the reflection at a perpendicular point of view.
  106209. */
  106210. reflectionReflectance90: number;
  106211. /**
  106212. * Sets the reflection reflectance fresnel values according to the default standard
  106213. * empirically know to work well :-)
  106214. */
  106215. reflectionStandardFresnelWeight: number;
  106216. protected _useRGBColor: boolean;
  106217. /**
  106218. * Helps to directly use the maps channels instead of their level.
  106219. */
  106220. useRGBColor: boolean;
  106221. protected _enableNoise: boolean;
  106222. /**
  106223. * This helps reducing the banding effect that could occur on the background.
  106224. */
  106225. enableNoise: boolean;
  106226. /**
  106227. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106228. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106229. * Recommended to be keep at 1.0 except for special cases.
  106230. */
  106231. fovMultiplier: number;
  106232. private _fovMultiplier;
  106233. /**
  106234. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106235. */
  106236. useEquirectangularFOV: boolean;
  106237. private _maxSimultaneousLights;
  106238. /**
  106239. * Number of Simultaneous lights allowed on the material.
  106240. */
  106241. maxSimultaneousLights: int;
  106242. /**
  106243. * Default configuration related to image processing available in the Background Material.
  106244. */
  106245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106246. /**
  106247. * Keep track of the image processing observer to allow dispose and replace.
  106248. */
  106249. private _imageProcessingObserver;
  106250. /**
  106251. * Attaches a new image processing configuration to the PBR Material.
  106252. * @param configuration (if null the scene configuration will be use)
  106253. */
  106254. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106255. /**
  106256. * Gets the image processing configuration used either in this material.
  106257. */
  106258. /**
  106259. * Sets the Default image processing configuration used either in the this material.
  106260. *
  106261. * If sets to null, the scene one is in use.
  106262. */
  106263. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106264. /**
  106265. * Gets wether the color curves effect is enabled.
  106266. */
  106267. /**
  106268. * Sets wether the color curves effect is enabled.
  106269. */
  106270. cameraColorCurvesEnabled: boolean;
  106271. /**
  106272. * Gets wether the color grading effect is enabled.
  106273. */
  106274. /**
  106275. * Gets wether the color grading effect is enabled.
  106276. */
  106277. cameraColorGradingEnabled: boolean;
  106278. /**
  106279. * Gets wether tonemapping is enabled or not.
  106280. */
  106281. /**
  106282. * Sets wether tonemapping is enabled or not
  106283. */
  106284. cameraToneMappingEnabled: boolean;
  106285. /**
  106286. * The camera exposure used on this material.
  106287. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106288. * This corresponds to a photographic exposure.
  106289. */
  106290. /**
  106291. * The camera exposure used on this material.
  106292. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106293. * This corresponds to a photographic exposure.
  106294. */
  106295. cameraExposure: float;
  106296. /**
  106297. * Gets The camera contrast used on this material.
  106298. */
  106299. /**
  106300. * Sets The camera contrast used on this material.
  106301. */
  106302. cameraContrast: float;
  106303. /**
  106304. * Gets the Color Grading 2D Lookup Texture.
  106305. */
  106306. /**
  106307. * Sets the Color Grading 2D Lookup Texture.
  106308. */
  106309. cameraColorGradingTexture: Nullable<BaseTexture>;
  106310. /**
  106311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106313. * 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;
  106314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106315. */
  106316. /**
  106317. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106318. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106319. * 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;
  106320. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106321. */
  106322. cameraColorCurves: Nullable<ColorCurves>;
  106323. /**
  106324. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106325. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106326. */
  106327. switchToBGR: boolean;
  106328. private _renderTargets;
  106329. private _reflectionControls;
  106330. private _white;
  106331. private _primaryShadowColor;
  106332. private _primaryHighlightColor;
  106333. /**
  106334. * Instantiates a Background Material in the given scene
  106335. * @param name The friendly name of the material
  106336. * @param scene The scene to add the material to
  106337. */
  106338. constructor(name: string, scene: Scene);
  106339. /**
  106340. * Gets a boolean indicating that current material needs to register RTT
  106341. */
  106342. readonly hasRenderTargetTextures: boolean;
  106343. /**
  106344. * The entire material has been created in order to prevent overdraw.
  106345. * @returns false
  106346. */
  106347. needAlphaTesting(): boolean;
  106348. /**
  106349. * The entire material has been created in order to prevent overdraw.
  106350. * @returns true if blending is enable
  106351. */
  106352. needAlphaBlending(): boolean;
  106353. /**
  106354. * Checks wether the material is ready to be rendered for a given mesh.
  106355. * @param mesh The mesh to render
  106356. * @param subMesh The submesh to check against
  106357. * @param useInstances Specify wether or not the material is used with instances
  106358. * @returns true if all the dependencies are ready (Textures, Effects...)
  106359. */
  106360. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106361. /**
  106362. * Compute the primary color according to the chosen perceptual color.
  106363. */
  106364. private _computePrimaryColorFromPerceptualColor;
  106365. /**
  106366. * Compute the highlights and shadow colors according to their chosen levels.
  106367. */
  106368. private _computePrimaryColors;
  106369. /**
  106370. * Build the uniform buffer used in the material.
  106371. */
  106372. buildUniformLayout(): void;
  106373. /**
  106374. * Unbind the material.
  106375. */
  106376. unbind(): void;
  106377. /**
  106378. * Bind only the world matrix to the material.
  106379. * @param world The world matrix to bind.
  106380. */
  106381. bindOnlyWorldMatrix(world: Matrix): void;
  106382. /**
  106383. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106384. * @param world The world matrix to bind.
  106385. * @param subMesh The submesh to bind for.
  106386. */
  106387. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106388. /**
  106389. * Dispose the material.
  106390. * @param forceDisposeEffect Force disposal of the associated effect.
  106391. * @param forceDisposeTextures Force disposal of the associated textures.
  106392. */
  106393. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106394. /**
  106395. * Clones the material.
  106396. * @param name The cloned name.
  106397. * @returns The cloned material.
  106398. */
  106399. clone(name: string): BackgroundMaterial;
  106400. /**
  106401. * Serializes the current material to its JSON representation.
  106402. * @returns The JSON representation.
  106403. */
  106404. serialize(): any;
  106405. /**
  106406. * Gets the class name of the material
  106407. * @returns "BackgroundMaterial"
  106408. */
  106409. getClassName(): string;
  106410. /**
  106411. * Parse a JSON input to create back a background material.
  106412. * @param source The JSON data to parse
  106413. * @param scene The scene to create the parsed material in
  106414. * @param rootUrl The root url of the assets the material depends upon
  106415. * @returns the instantiated BackgroundMaterial.
  106416. */
  106417. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106418. }
  106419. }
  106420. declare module BABYLON {
  106421. /**
  106422. * Represents the different options available during the creation of
  106423. * a Environment helper.
  106424. *
  106425. * This can control the default ground, skybox and image processing setup of your scene.
  106426. */
  106427. export interface IEnvironmentHelperOptions {
  106428. /**
  106429. * Specifies wether or not to create a ground.
  106430. * True by default.
  106431. */
  106432. createGround: boolean;
  106433. /**
  106434. * Specifies the ground size.
  106435. * 15 by default.
  106436. */
  106437. groundSize: number;
  106438. /**
  106439. * The texture used on the ground for the main color.
  106440. * Comes from the BabylonJS CDN by default.
  106441. *
  106442. * Remarks: Can be either a texture or a url.
  106443. */
  106444. groundTexture: string | BaseTexture;
  106445. /**
  106446. * The color mixed in the ground texture by default.
  106447. * BabylonJS clearColor by default.
  106448. */
  106449. groundColor: Color3;
  106450. /**
  106451. * Specifies the ground opacity.
  106452. * 1 by default.
  106453. */
  106454. groundOpacity: number;
  106455. /**
  106456. * Enables the ground to receive shadows.
  106457. * True by default.
  106458. */
  106459. enableGroundShadow: boolean;
  106460. /**
  106461. * Helps preventing the shadow to be fully black on the ground.
  106462. * 0.5 by default.
  106463. */
  106464. groundShadowLevel: number;
  106465. /**
  106466. * Creates a mirror texture attach to the ground.
  106467. * false by default.
  106468. */
  106469. enableGroundMirror: boolean;
  106470. /**
  106471. * Specifies the ground mirror size ratio.
  106472. * 0.3 by default as the default kernel is 64.
  106473. */
  106474. groundMirrorSizeRatio: number;
  106475. /**
  106476. * Specifies the ground mirror blur kernel size.
  106477. * 64 by default.
  106478. */
  106479. groundMirrorBlurKernel: number;
  106480. /**
  106481. * Specifies the ground mirror visibility amount.
  106482. * 1 by default
  106483. */
  106484. groundMirrorAmount: number;
  106485. /**
  106486. * Specifies the ground mirror reflectance weight.
  106487. * This uses the standard weight of the background material to setup the fresnel effect
  106488. * of the mirror.
  106489. * 1 by default.
  106490. */
  106491. groundMirrorFresnelWeight: number;
  106492. /**
  106493. * Specifies the ground mirror Falloff distance.
  106494. * This can helps reducing the size of the reflection.
  106495. * 0 by Default.
  106496. */
  106497. groundMirrorFallOffDistance: number;
  106498. /**
  106499. * Specifies the ground mirror texture type.
  106500. * Unsigned Int by Default.
  106501. */
  106502. groundMirrorTextureType: number;
  106503. /**
  106504. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106505. * the shown objects.
  106506. */
  106507. groundYBias: number;
  106508. /**
  106509. * Specifies wether or not to create a skybox.
  106510. * True by default.
  106511. */
  106512. createSkybox: boolean;
  106513. /**
  106514. * Specifies the skybox size.
  106515. * 20 by default.
  106516. */
  106517. skyboxSize: number;
  106518. /**
  106519. * The texture used on the skybox for the main color.
  106520. * Comes from the BabylonJS CDN by default.
  106521. *
  106522. * Remarks: Can be either a texture or a url.
  106523. */
  106524. skyboxTexture: string | BaseTexture;
  106525. /**
  106526. * The color mixed in the skybox texture by default.
  106527. * BabylonJS clearColor by default.
  106528. */
  106529. skyboxColor: Color3;
  106530. /**
  106531. * The background rotation around the Y axis of the scene.
  106532. * This helps aligning the key lights of your scene with the background.
  106533. * 0 by default.
  106534. */
  106535. backgroundYRotation: number;
  106536. /**
  106537. * Compute automatically the size of the elements to best fit with the scene.
  106538. */
  106539. sizeAuto: boolean;
  106540. /**
  106541. * Default position of the rootMesh if autoSize is not true.
  106542. */
  106543. rootPosition: Vector3;
  106544. /**
  106545. * Sets up the image processing in the scene.
  106546. * true by default.
  106547. */
  106548. setupImageProcessing: boolean;
  106549. /**
  106550. * The texture used as your environment texture in the scene.
  106551. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106552. *
  106553. * Remarks: Can be either a texture or a url.
  106554. */
  106555. environmentTexture: string | BaseTexture;
  106556. /**
  106557. * The value of the exposure to apply to the scene.
  106558. * 0.6 by default if setupImageProcessing is true.
  106559. */
  106560. cameraExposure: number;
  106561. /**
  106562. * The value of the contrast to apply to the scene.
  106563. * 1.6 by default if setupImageProcessing is true.
  106564. */
  106565. cameraContrast: number;
  106566. /**
  106567. * Specifies wether or not tonemapping should be enabled in the scene.
  106568. * true by default if setupImageProcessing is true.
  106569. */
  106570. toneMappingEnabled: boolean;
  106571. }
  106572. /**
  106573. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106574. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106575. * It also helps with the default setup of your imageProcessing configuration.
  106576. */
  106577. export class EnvironmentHelper {
  106578. /**
  106579. * Default ground texture URL.
  106580. */
  106581. private static _groundTextureCDNUrl;
  106582. /**
  106583. * Default skybox texture URL.
  106584. */
  106585. private static _skyboxTextureCDNUrl;
  106586. /**
  106587. * Default environment texture URL.
  106588. */
  106589. private static _environmentTextureCDNUrl;
  106590. /**
  106591. * Creates the default options for the helper.
  106592. */
  106593. private static _getDefaultOptions;
  106594. private _rootMesh;
  106595. /**
  106596. * Gets the root mesh created by the helper.
  106597. */
  106598. readonly rootMesh: Mesh;
  106599. private _skybox;
  106600. /**
  106601. * Gets the skybox created by the helper.
  106602. */
  106603. readonly skybox: Nullable<Mesh>;
  106604. private _skyboxTexture;
  106605. /**
  106606. * Gets the skybox texture created by the helper.
  106607. */
  106608. readonly skyboxTexture: Nullable<BaseTexture>;
  106609. private _skyboxMaterial;
  106610. /**
  106611. * Gets the skybox material created by the helper.
  106612. */
  106613. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106614. private _ground;
  106615. /**
  106616. * Gets the ground mesh created by the helper.
  106617. */
  106618. readonly ground: Nullable<Mesh>;
  106619. private _groundTexture;
  106620. /**
  106621. * Gets the ground texture created by the helper.
  106622. */
  106623. readonly groundTexture: Nullable<BaseTexture>;
  106624. private _groundMirror;
  106625. /**
  106626. * Gets the ground mirror created by the helper.
  106627. */
  106628. readonly groundMirror: Nullable<MirrorTexture>;
  106629. /**
  106630. * Gets the ground mirror render list to helps pushing the meshes
  106631. * you wish in the ground reflection.
  106632. */
  106633. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106634. private _groundMaterial;
  106635. /**
  106636. * Gets the ground material created by the helper.
  106637. */
  106638. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106639. /**
  106640. * Stores the creation options.
  106641. */
  106642. private readonly _scene;
  106643. private _options;
  106644. /**
  106645. * This observable will be notified with any error during the creation of the environment,
  106646. * mainly texture creation errors.
  106647. */
  106648. onErrorObservable: Observable<{
  106649. message?: string;
  106650. exception?: any;
  106651. }>;
  106652. /**
  106653. * constructor
  106654. * @param options Defines the options we want to customize the helper
  106655. * @param scene The scene to add the material to
  106656. */
  106657. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106658. /**
  106659. * Updates the background according to the new options
  106660. * @param options
  106661. */
  106662. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106663. /**
  106664. * Sets the primary color of all the available elements.
  106665. * @param color the main color to affect to the ground and the background
  106666. */
  106667. setMainColor(color: Color3): void;
  106668. /**
  106669. * Setup the image processing according to the specified options.
  106670. */
  106671. private _setupImageProcessing;
  106672. /**
  106673. * Setup the environment texture according to the specified options.
  106674. */
  106675. private _setupEnvironmentTexture;
  106676. /**
  106677. * Setup the background according to the specified options.
  106678. */
  106679. private _setupBackground;
  106680. /**
  106681. * Get the scene sizes according to the setup.
  106682. */
  106683. private _getSceneSize;
  106684. /**
  106685. * Setup the ground according to the specified options.
  106686. */
  106687. private _setupGround;
  106688. /**
  106689. * Setup the ground material according to the specified options.
  106690. */
  106691. private _setupGroundMaterial;
  106692. /**
  106693. * Setup the ground diffuse texture according to the specified options.
  106694. */
  106695. private _setupGroundDiffuseTexture;
  106696. /**
  106697. * Setup the ground mirror texture according to the specified options.
  106698. */
  106699. private _setupGroundMirrorTexture;
  106700. /**
  106701. * Setup the ground to receive the mirror texture.
  106702. */
  106703. private _setupMirrorInGroundMaterial;
  106704. /**
  106705. * Setup the skybox according to the specified options.
  106706. */
  106707. private _setupSkybox;
  106708. /**
  106709. * Setup the skybox material according to the specified options.
  106710. */
  106711. private _setupSkyboxMaterial;
  106712. /**
  106713. * Setup the skybox reflection texture according to the specified options.
  106714. */
  106715. private _setupSkyboxReflectionTexture;
  106716. private _errorHandler;
  106717. /**
  106718. * Dispose all the elements created by the Helper.
  106719. */
  106720. dispose(): void;
  106721. }
  106722. }
  106723. declare module BABYLON {
  106724. /**
  106725. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106726. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106727. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106728. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106729. */
  106730. export class PhotoDome extends TransformNode {
  106731. /**
  106732. * Define the image as a Monoscopic panoramic 360 image.
  106733. */
  106734. static readonly MODE_MONOSCOPIC: number;
  106735. /**
  106736. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106737. */
  106738. static readonly MODE_TOPBOTTOM: number;
  106739. /**
  106740. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106741. */
  106742. static readonly MODE_SIDEBYSIDE: number;
  106743. private _useDirectMapping;
  106744. /**
  106745. * The texture being displayed on the sphere
  106746. */
  106747. protected _photoTexture: Texture;
  106748. /**
  106749. * Gets or sets the texture being displayed on the sphere
  106750. */
  106751. photoTexture: Texture;
  106752. /**
  106753. * Observable raised when an error occured while loading the 360 image
  106754. */
  106755. onLoadErrorObservable: Observable<string>;
  106756. /**
  106757. * The skybox material
  106758. */
  106759. protected _material: BackgroundMaterial;
  106760. /**
  106761. * The surface used for the skybox
  106762. */
  106763. protected _mesh: Mesh;
  106764. /**
  106765. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106766. * Also see the options.resolution property.
  106767. */
  106768. fovMultiplier: number;
  106769. private _imageMode;
  106770. /**
  106771. * Gets or set the current video mode for the video. It can be:
  106772. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  106773. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  106774. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  106775. */
  106776. imageMode: number;
  106777. /**
  106778. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106779. * @param name Element's name, child elements will append suffixes for their own names.
  106780. * @param urlsOfPhoto defines the url of the photo to display
  106781. * @param options defines an object containing optional or exposed sub element properties
  106782. * @param onError defines a callback called when an error occured while loading the texture
  106783. */
  106784. constructor(name: string, urlOfPhoto: string, options: {
  106785. resolution?: number;
  106786. size?: number;
  106787. useDirectMapping?: boolean;
  106788. faceForward?: boolean;
  106789. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106790. private _onBeforeCameraRenderObserver;
  106791. private _changeImageMode;
  106792. /**
  106793. * Releases resources associated with this node.
  106794. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106795. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106796. */
  106797. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106798. }
  106799. }
  106800. declare module BABYLON {
  106801. /** @hidden */
  106802. export var rgbdDecodePixelShader: {
  106803. name: string;
  106804. shader: string;
  106805. };
  106806. }
  106807. declare module BABYLON {
  106808. /**
  106809. * Class used to host texture specific utilities
  106810. */
  106811. export class BRDFTextureTools {
  106812. /**
  106813. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  106814. * @param texture the texture to expand.
  106815. */
  106816. private static _ExpandDefaultBRDFTexture;
  106817. /**
  106818. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  106819. * @param scene defines the hosting scene
  106820. * @returns the environment BRDF texture
  106821. */
  106822. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  106823. private static _environmentBRDFBase64Texture;
  106824. }
  106825. }
  106826. declare module BABYLON {
  106827. /**
  106828. * @hidden
  106829. */
  106830. export interface IMaterialClearCoatDefines {
  106831. CLEARCOAT: boolean;
  106832. CLEARCOAT_DEFAULTIOR: boolean;
  106833. CLEARCOAT_TEXTURE: boolean;
  106834. CLEARCOAT_TEXTUREDIRECTUV: number;
  106835. CLEARCOAT_BUMP: boolean;
  106836. CLEARCOAT_BUMPDIRECTUV: number;
  106837. CLEARCOAT_TINT: boolean;
  106838. CLEARCOAT_TINT_TEXTURE: boolean;
  106839. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106840. /** @hidden */
  106841. _areTexturesDirty: boolean;
  106842. }
  106843. /**
  106844. * Define the code related to the clear coat parameters of the pbr material.
  106845. */
  106846. export class PBRClearCoatConfiguration {
  106847. /**
  106848. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106849. * The default fits with a polyurethane material.
  106850. */
  106851. private static readonly _DefaultIndiceOfRefraction;
  106852. private _isEnabled;
  106853. /**
  106854. * Defines if the clear coat is enabled in the material.
  106855. */
  106856. isEnabled: boolean;
  106857. /**
  106858. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106859. */
  106860. intensity: number;
  106861. /**
  106862. * Defines the clear coat layer roughness.
  106863. */
  106864. roughness: number;
  106865. private _indiceOfRefraction;
  106866. /**
  106867. * Defines the indice of refraction of the clear coat.
  106868. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106869. * The default fits with a polyurethane material.
  106870. * Changing the default value is more performance intensive.
  106871. */
  106872. indiceOfRefraction: number;
  106873. private _texture;
  106874. /**
  106875. * Stores the clear coat values in a texture.
  106876. */
  106877. texture: Nullable<BaseTexture>;
  106878. private _bumpTexture;
  106879. /**
  106880. * Define the clear coat specific bump texture.
  106881. */
  106882. bumpTexture: Nullable<BaseTexture>;
  106883. private _isTintEnabled;
  106884. /**
  106885. * Defines if the clear coat tint is enabled in the material.
  106886. */
  106887. isTintEnabled: boolean;
  106888. /**
  106889. * Defines the clear coat tint of the material.
  106890. * This is only use if tint is enabled
  106891. */
  106892. tintColor: Color3;
  106893. /**
  106894. * Defines the distance at which the tint color should be found in the
  106895. * clear coat media.
  106896. * This is only use if tint is enabled
  106897. */
  106898. tintColorAtDistance: number;
  106899. /**
  106900. * Defines the clear coat layer thickness.
  106901. * This is only use if tint is enabled
  106902. */
  106903. tintThickness: number;
  106904. private _tintTexture;
  106905. /**
  106906. * Stores the clear tint values in a texture.
  106907. * rgb is tint
  106908. * a is a thickness factor
  106909. */
  106910. tintTexture: Nullable<BaseTexture>;
  106911. /** @hidden */
  106912. private _internalMarkAllSubMeshesAsTexturesDirty;
  106913. /** @hidden */
  106914. _markAllSubMeshesAsTexturesDirty(): void;
  106915. /**
  106916. * Instantiate a new istance of clear coat configuration.
  106917. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106918. */
  106919. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106920. /**
  106921. * Gets wehter the submesh is ready to be used or not.
  106922. * @param defines the list of "defines" to update.
  106923. * @param scene defines the scene the material belongs to.
  106924. * @param engine defines the engine the material belongs to.
  106925. * @param disableBumpMap defines wether the material disables bump or not.
  106926. * @returns - boolean indicating that the submesh is ready or not.
  106927. */
  106928. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106929. /**
  106930. * Checks to see if a texture is used in the material.
  106931. * @param defines the list of "defines" to update.
  106932. * @param scene defines the scene to the material belongs to.
  106933. */
  106934. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106935. /**
  106936. * Binds the material data.
  106937. * @param uniformBuffer defines the Uniform buffer to fill in.
  106938. * @param scene defines the scene the material belongs to.
  106939. * @param engine defines the engine the material belongs to.
  106940. * @param disableBumpMap defines wether the material disables bump or not.
  106941. * @param isFrozen defines wether the material is frozen or not.
  106942. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106943. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106944. */
  106945. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  106946. /**
  106947. * Checks to see if a texture is used in the material.
  106948. * @param texture - Base texture to use.
  106949. * @returns - Boolean specifying if a texture is used in the material.
  106950. */
  106951. hasTexture(texture: BaseTexture): boolean;
  106952. /**
  106953. * Returns an array of the actively used textures.
  106954. * @param activeTextures Array of BaseTextures
  106955. */
  106956. getActiveTextures(activeTextures: BaseTexture[]): void;
  106957. /**
  106958. * Returns the animatable textures.
  106959. * @param animatables Array of animatable textures.
  106960. */
  106961. getAnimatables(animatables: IAnimatable[]): void;
  106962. /**
  106963. * Disposes the resources of the material.
  106964. * @param forceDisposeTextures - Forces the disposal of all textures.
  106965. */
  106966. dispose(forceDisposeTextures?: boolean): void;
  106967. /**
  106968. * Get the current class name of the texture useful for serialization or dynamic coding.
  106969. * @returns "PBRClearCoatConfiguration"
  106970. */
  106971. getClassName(): string;
  106972. /**
  106973. * Add fallbacks to the effect fallbacks list.
  106974. * @param defines defines the Base texture to use.
  106975. * @param fallbacks defines the current fallback list.
  106976. * @param currentRank defines the current fallback rank.
  106977. * @returns the new fallback rank.
  106978. */
  106979. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106980. /**
  106981. * Add the required uniforms to the current list.
  106982. * @param uniforms defines the current uniform list.
  106983. */
  106984. static AddUniforms(uniforms: string[]): void;
  106985. /**
  106986. * Add the required samplers to the current list.
  106987. * @param samplers defines the current sampler list.
  106988. */
  106989. static AddSamplers(samplers: string[]): void;
  106990. /**
  106991. * Add the required uniforms to the current buffer.
  106992. * @param uniformBuffer defines the current uniform buffer.
  106993. */
  106994. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106995. /**
  106996. * Makes a duplicate of the current configuration into another one.
  106997. * @param clearCoatConfiguration define the config where to copy the info
  106998. */
  106999. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107000. /**
  107001. * Serializes this clear coat configuration.
  107002. * @returns - An object with the serialized config.
  107003. */
  107004. serialize(): any;
  107005. /**
  107006. * Parses a Clear Coat Configuration from a serialized object.
  107007. * @param source - Serialized object.
  107008. */
  107009. parse(source: any): void;
  107010. }
  107011. }
  107012. declare module BABYLON {
  107013. /**
  107014. * @hidden
  107015. */
  107016. export interface IMaterialAnisotropicDefines {
  107017. ANISOTROPIC: boolean;
  107018. ANISOTROPIC_TEXTURE: boolean;
  107019. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107020. MAINUV1: boolean;
  107021. _areTexturesDirty: boolean;
  107022. _needUVs: boolean;
  107023. }
  107024. /**
  107025. * Define the code related to the anisotropic parameters of the pbr material.
  107026. */
  107027. export class PBRAnisotropicConfiguration {
  107028. private _isEnabled;
  107029. /**
  107030. * Defines if the anisotropy is enabled in the material.
  107031. */
  107032. isEnabled: boolean;
  107033. /**
  107034. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107035. */
  107036. intensity: number;
  107037. /**
  107038. * Defines if the effect is along the tangents, bitangents or in between.
  107039. * By default, the effect is "strectching" the highlights along the tangents.
  107040. */
  107041. direction: Vector2;
  107042. private _texture;
  107043. /**
  107044. * Stores the anisotropy values in a texture.
  107045. * rg is direction (like normal from -1 to 1)
  107046. * b is a intensity
  107047. */
  107048. texture: Nullable<BaseTexture>;
  107049. /** @hidden */
  107050. private _internalMarkAllSubMeshesAsTexturesDirty;
  107051. /** @hidden */
  107052. _markAllSubMeshesAsTexturesDirty(): void;
  107053. /**
  107054. * Instantiate a new istance of anisotropy configuration.
  107055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107056. */
  107057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107058. /**
  107059. * Specifies that the submesh is ready to be used.
  107060. * @param defines the list of "defines" to update.
  107061. * @param scene defines the scene the material belongs to.
  107062. * @returns - boolean indicating that the submesh is ready or not.
  107063. */
  107064. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107065. /**
  107066. * Checks to see if a texture is used in the material.
  107067. * @param defines the list of "defines" to update.
  107068. * @param mesh the mesh we are preparing the defines for.
  107069. * @param scene defines the scene the material belongs to.
  107070. */
  107071. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107072. /**
  107073. * Binds the material data.
  107074. * @param uniformBuffer defines the Uniform buffer to fill in.
  107075. * @param scene defines the scene the material belongs to.
  107076. * @param isFrozen defines wether the material is frozen or not.
  107077. */
  107078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107079. /**
  107080. * Checks to see if a texture is used in the material.
  107081. * @param texture - Base texture to use.
  107082. * @returns - Boolean specifying if a texture is used in the material.
  107083. */
  107084. hasTexture(texture: BaseTexture): boolean;
  107085. /**
  107086. * Returns an array of the actively used textures.
  107087. * @param activeTextures Array of BaseTextures
  107088. */
  107089. getActiveTextures(activeTextures: BaseTexture[]): void;
  107090. /**
  107091. * Returns the animatable textures.
  107092. * @param animatables Array of animatable textures.
  107093. */
  107094. getAnimatables(animatables: IAnimatable[]): void;
  107095. /**
  107096. * Disposes the resources of the material.
  107097. * @param forceDisposeTextures - Forces the disposal of all textures.
  107098. */
  107099. dispose(forceDisposeTextures?: boolean): void;
  107100. /**
  107101. * Get the current class name of the texture useful for serialization or dynamic coding.
  107102. * @returns "PBRAnisotropicConfiguration"
  107103. */
  107104. getClassName(): string;
  107105. /**
  107106. * Add fallbacks to the effect fallbacks list.
  107107. * @param defines defines the Base texture to use.
  107108. * @param fallbacks defines the current fallback list.
  107109. * @param currentRank defines the current fallback rank.
  107110. * @returns the new fallback rank.
  107111. */
  107112. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107113. /**
  107114. * Add the required uniforms to the current list.
  107115. * @param uniforms defines the current uniform list.
  107116. */
  107117. static AddUniforms(uniforms: string[]): void;
  107118. /**
  107119. * Add the required uniforms to the current buffer.
  107120. * @param uniformBuffer defines the current uniform buffer.
  107121. */
  107122. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107123. /**
  107124. * Add the required samplers to the current list.
  107125. * @param samplers defines the current sampler list.
  107126. */
  107127. static AddSamplers(samplers: string[]): void;
  107128. /**
  107129. * Makes a duplicate of the current configuration into another one.
  107130. * @param anisotropicConfiguration define the config where to copy the info
  107131. */
  107132. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107133. /**
  107134. * Serializes this anisotropy configuration.
  107135. * @returns - An object with the serialized config.
  107136. */
  107137. serialize(): any;
  107138. /**
  107139. * Parses a anisotropy Configuration from a serialized object.
  107140. * @param source - Serialized object.
  107141. */
  107142. parse(source: any): void;
  107143. }
  107144. }
  107145. declare module BABYLON {
  107146. /**
  107147. * @hidden
  107148. */
  107149. export interface IMaterialBRDFDefines {
  107150. BRDF_V_HEIGHT_CORRELATED: boolean;
  107151. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107152. SPHERICAL_HARMONICS: boolean;
  107153. /** @hidden */
  107154. _areMiscDirty: boolean;
  107155. }
  107156. /**
  107157. * Define the code related to the BRDF parameters of the pbr material.
  107158. */
  107159. export class PBRBRDFConfiguration {
  107160. /**
  107161. * Default value used for the energy conservation.
  107162. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107163. */
  107164. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107165. /**
  107166. * Default value used for the Smith Visibility Height Correlated mode.
  107167. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107168. */
  107169. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107170. /**
  107171. * Default value used for the IBL diffuse part.
  107172. * This can help switching back to the polynomials mode globally which is a tiny bit
  107173. * less GPU intensive at the drawback of a lower quality.
  107174. */
  107175. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107176. private _useEnergyConservation;
  107177. /**
  107178. * Defines if the material uses energy conservation.
  107179. */
  107180. useEnergyConservation: boolean;
  107181. private _useSmithVisibilityHeightCorrelated;
  107182. /**
  107183. * LEGACY Mode set to false
  107184. * Defines if the material uses height smith correlated visibility term.
  107185. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107186. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107187. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107188. * Not relying on height correlated will also disable energy conservation.
  107189. */
  107190. useSmithVisibilityHeightCorrelated: boolean;
  107191. private _useSphericalHarmonics;
  107192. /**
  107193. * LEGACY Mode set to false
  107194. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107195. * diffuse part of the IBL.
  107196. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107197. * to the ground truth.
  107198. */
  107199. useSphericalHarmonics: boolean;
  107200. /** @hidden */
  107201. private _internalMarkAllSubMeshesAsMiscDirty;
  107202. /** @hidden */
  107203. _markAllSubMeshesAsMiscDirty(): void;
  107204. /**
  107205. * Instantiate a new istance of clear coat configuration.
  107206. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107207. */
  107208. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107209. /**
  107210. * Checks to see if a texture is used in the material.
  107211. * @param defines the list of "defines" to update.
  107212. */
  107213. prepareDefines(defines: IMaterialBRDFDefines): void;
  107214. /**
  107215. * Get the current class name of the texture useful for serialization or dynamic coding.
  107216. * @returns "PBRClearCoatConfiguration"
  107217. */
  107218. getClassName(): string;
  107219. /**
  107220. * Makes a duplicate of the current configuration into another one.
  107221. * @param brdfConfiguration define the config where to copy the info
  107222. */
  107223. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107224. /**
  107225. * Serializes this BRDF configuration.
  107226. * @returns - An object with the serialized config.
  107227. */
  107228. serialize(): any;
  107229. /**
  107230. * Parses a BRDF Configuration from a serialized object.
  107231. * @param source - Serialized object.
  107232. */
  107233. parse(source: any): void;
  107234. }
  107235. }
  107236. declare module BABYLON {
  107237. /**
  107238. * @hidden
  107239. */
  107240. export interface IMaterialSheenDefines {
  107241. SHEEN: boolean;
  107242. SHEEN_TEXTURE: boolean;
  107243. SHEEN_TEXTUREDIRECTUV: number;
  107244. SHEEN_LINKWITHALBEDO: boolean;
  107245. /** @hidden */
  107246. _areTexturesDirty: boolean;
  107247. }
  107248. /**
  107249. * Define the code related to the Sheen parameters of the pbr material.
  107250. */
  107251. export class PBRSheenConfiguration {
  107252. private _isEnabled;
  107253. /**
  107254. * Defines if the material uses sheen.
  107255. */
  107256. isEnabled: boolean;
  107257. private _linkSheenWithAlbedo;
  107258. /**
  107259. * Defines if the sheen is linked to the sheen color.
  107260. */
  107261. linkSheenWithAlbedo: boolean;
  107262. /**
  107263. * Defines the sheen intensity.
  107264. */
  107265. intensity: number;
  107266. /**
  107267. * Defines the sheen color.
  107268. */
  107269. color: Color3;
  107270. private _texture;
  107271. /**
  107272. * Stores the sheen tint values in a texture.
  107273. * rgb is tint
  107274. * a is a intensity
  107275. */
  107276. texture: Nullable<BaseTexture>;
  107277. /** @hidden */
  107278. private _internalMarkAllSubMeshesAsTexturesDirty;
  107279. /** @hidden */
  107280. _markAllSubMeshesAsTexturesDirty(): void;
  107281. /**
  107282. * Instantiate a new istance of clear coat configuration.
  107283. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107284. */
  107285. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107286. /**
  107287. * Specifies that the submesh is ready to be used.
  107288. * @param defines the list of "defines" to update.
  107289. * @param scene defines the scene the material belongs to.
  107290. * @returns - boolean indicating that the submesh is ready or not.
  107291. */
  107292. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107293. /**
  107294. * Checks to see if a texture is used in the material.
  107295. * @param defines the list of "defines" to update.
  107296. * @param scene defines the scene the material belongs to.
  107297. */
  107298. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107299. /**
  107300. * Binds the material data.
  107301. * @param uniformBuffer defines the Uniform buffer to fill in.
  107302. * @param scene defines the scene the material belongs to.
  107303. * @param isFrozen defines wether the material is frozen or not.
  107304. */
  107305. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107306. /**
  107307. * Checks to see if a texture is used in the material.
  107308. * @param texture - Base texture to use.
  107309. * @returns - Boolean specifying if a texture is used in the material.
  107310. */
  107311. hasTexture(texture: BaseTexture): boolean;
  107312. /**
  107313. * Returns an array of the actively used textures.
  107314. * @param activeTextures Array of BaseTextures
  107315. */
  107316. getActiveTextures(activeTextures: BaseTexture[]): void;
  107317. /**
  107318. * Returns the animatable textures.
  107319. * @param animatables Array of animatable textures.
  107320. */
  107321. getAnimatables(animatables: IAnimatable[]): void;
  107322. /**
  107323. * Disposes the resources of the material.
  107324. * @param forceDisposeTextures - Forces the disposal of all textures.
  107325. */
  107326. dispose(forceDisposeTextures?: boolean): void;
  107327. /**
  107328. * Get the current class name of the texture useful for serialization or dynamic coding.
  107329. * @returns "PBRSheenConfiguration"
  107330. */
  107331. getClassName(): string;
  107332. /**
  107333. * Add fallbacks to the effect fallbacks list.
  107334. * @param defines defines the Base texture to use.
  107335. * @param fallbacks defines the current fallback list.
  107336. * @param currentRank defines the current fallback rank.
  107337. * @returns the new fallback rank.
  107338. */
  107339. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107340. /**
  107341. * Add the required uniforms to the current list.
  107342. * @param uniforms defines the current uniform list.
  107343. */
  107344. static AddUniforms(uniforms: string[]): void;
  107345. /**
  107346. * Add the required uniforms to the current buffer.
  107347. * @param uniformBuffer defines the current uniform buffer.
  107348. */
  107349. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107350. /**
  107351. * Add the required samplers to the current list.
  107352. * @param samplers defines the current sampler list.
  107353. */
  107354. static AddSamplers(samplers: string[]): void;
  107355. /**
  107356. * Makes a duplicate of the current configuration into another one.
  107357. * @param sheenConfiguration define the config where to copy the info
  107358. */
  107359. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107360. /**
  107361. * Serializes this BRDF configuration.
  107362. * @returns - An object with the serialized config.
  107363. */
  107364. serialize(): any;
  107365. /**
  107366. * Parses a Sheen Configuration from a serialized object.
  107367. * @param source - Serialized object.
  107368. */
  107369. parse(source: any): void;
  107370. }
  107371. }
  107372. declare module BABYLON {
  107373. /**
  107374. * @hidden
  107375. */
  107376. export interface IMaterialSubSurfaceDefines {
  107377. SUBSURFACE: boolean;
  107378. SS_REFRACTION: boolean;
  107379. SS_TRANSLUCENCY: boolean;
  107380. SS_SCATERRING: boolean;
  107381. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107382. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107383. SS_REFRACTIONMAP_3D: boolean;
  107384. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107385. SS_LODINREFRACTIONALPHA: boolean;
  107386. SS_GAMMAREFRACTION: boolean;
  107387. SS_RGBDREFRACTION: boolean;
  107388. SS_LINEARSPECULARREFRACTION: boolean;
  107389. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107390. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107391. /** @hidden */
  107392. _areTexturesDirty: boolean;
  107393. }
  107394. /**
  107395. * Define the code related to the sub surface parameters of the pbr material.
  107396. */
  107397. export class PBRSubSurfaceConfiguration {
  107398. private _isRefractionEnabled;
  107399. /**
  107400. * Defines if the refraction is enabled in the material.
  107401. */
  107402. isRefractionEnabled: boolean;
  107403. private _isTranslucencyEnabled;
  107404. /**
  107405. * Defines if the translucency is enabled in the material.
  107406. */
  107407. isTranslucencyEnabled: boolean;
  107408. private _isScatteringEnabled;
  107409. /**
  107410. * Defines the refraction intensity of the material.
  107411. * The refraction when enabled replaces the Diffuse part of the material.
  107412. * The intensity helps transitionning between diffuse and refraction.
  107413. */
  107414. refractionIntensity: number;
  107415. /**
  107416. * Defines the translucency intensity of the material.
  107417. * When translucency has been enabled, this defines how much of the "translucency"
  107418. * is addded to the diffuse part of the material.
  107419. */
  107420. translucencyIntensity: number;
  107421. /**
  107422. * Defines the scattering intensity of the material.
  107423. * When scattering has been enabled, this defines how much of the "scattered light"
  107424. * is addded to the diffuse part of the material.
  107425. */
  107426. scatteringIntensity: number;
  107427. private _thicknessTexture;
  107428. /**
  107429. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107430. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107431. * 0 would mean minimumThickness
  107432. * 1 would mean maximumThickness
  107433. * The other channels might be use as a mask to vary the different effects intensity.
  107434. */
  107435. thicknessTexture: Nullable<BaseTexture>;
  107436. private _refractionTexture;
  107437. /**
  107438. * Defines the texture to use for refraction.
  107439. */
  107440. refractionTexture: Nullable<BaseTexture>;
  107441. private _indexOfRefraction;
  107442. /**
  107443. * Defines the indice of refraction used in the material.
  107444. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107445. */
  107446. indexOfRefraction: number;
  107447. private _invertRefractionY;
  107448. /**
  107449. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107450. */
  107451. invertRefractionY: boolean;
  107452. private _linkRefractionWithTransparency;
  107453. /**
  107454. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107455. * Materials half opaque for instance using refraction could benefit from this control.
  107456. */
  107457. linkRefractionWithTransparency: boolean;
  107458. /**
  107459. * Defines the minimum thickness stored in the thickness map.
  107460. * If no thickness map is defined, this value will be used to simulate thickness.
  107461. */
  107462. minimumThickness: number;
  107463. /**
  107464. * Defines the maximum thickness stored in the thickness map.
  107465. */
  107466. maximumThickness: number;
  107467. /**
  107468. * Defines the volume tint of the material.
  107469. * This is used for both translucency and scattering.
  107470. */
  107471. tintColor: Color3;
  107472. /**
  107473. * Defines the distance at which the tint color should be found in the media.
  107474. * This is used for refraction only.
  107475. */
  107476. tintColorAtDistance: number;
  107477. /**
  107478. * Defines how far each channel transmit through the media.
  107479. * It is defined as a color to simplify it selection.
  107480. */
  107481. diffusionDistance: Color3;
  107482. private _useMaskFromThicknessTexture;
  107483. /**
  107484. * Stores the intensity of the different subsurface effects in the thickness texture.
  107485. * * the green channel is the translucency intensity.
  107486. * * the blue channel is the scattering intensity.
  107487. * * the alpha channel is the refraction intensity.
  107488. */
  107489. useMaskFromThicknessTexture: boolean;
  107490. /** @hidden */
  107491. private _internalMarkAllSubMeshesAsTexturesDirty;
  107492. /** @hidden */
  107493. _markAllSubMeshesAsTexturesDirty(): void;
  107494. /**
  107495. * Instantiate a new istance of sub surface configuration.
  107496. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107497. */
  107498. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107499. /**
  107500. * Gets wehter the submesh is ready to be used or not.
  107501. * @param defines the list of "defines" to update.
  107502. * @param scene defines the scene the material belongs to.
  107503. * @returns - boolean indicating that the submesh is ready or not.
  107504. */
  107505. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107506. /**
  107507. * Checks to see if a texture is used in the material.
  107508. * @param defines the list of "defines" to update.
  107509. * @param scene defines the scene to the material belongs to.
  107510. */
  107511. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107512. /**
  107513. * Binds the material data.
  107514. * @param uniformBuffer defines the Uniform buffer to fill in.
  107515. * @param scene defines the scene the material belongs to.
  107516. * @param engine defines the engine the material belongs to.
  107517. * @param isFrozen defines wether the material is frozen or not.
  107518. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107519. */
  107520. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107521. /**
  107522. * Unbinds the material from the mesh.
  107523. * @param activeEffect defines the effect that should be unbound from.
  107524. * @returns true if unbound, otherwise false
  107525. */
  107526. unbind(activeEffect: Effect): boolean;
  107527. /**
  107528. * Returns the texture used for refraction or null if none is used.
  107529. * @param scene defines the scene the material belongs to.
  107530. * @returns - Refraction texture if present. If no refraction texture and refraction
  107531. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107532. */
  107533. private _getRefractionTexture;
  107534. /**
  107535. * Returns true if alpha blending should be disabled.
  107536. */
  107537. readonly disableAlphaBlending: boolean;
  107538. /**
  107539. * Fills the list of render target textures.
  107540. * @param renderTargets the list of render targets to update
  107541. */
  107542. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107543. /**
  107544. * Checks to see if a texture is used in the material.
  107545. * @param texture - Base texture to use.
  107546. * @returns - Boolean specifying if a texture is used in the material.
  107547. */
  107548. hasTexture(texture: BaseTexture): boolean;
  107549. /**
  107550. * Gets a boolean indicating that current material needs to register RTT
  107551. * @returns true if this uses a render target otherwise false.
  107552. */
  107553. hasRenderTargetTextures(): boolean;
  107554. /**
  107555. * Returns an array of the actively used textures.
  107556. * @param activeTextures Array of BaseTextures
  107557. */
  107558. getActiveTextures(activeTextures: BaseTexture[]): void;
  107559. /**
  107560. * Returns the animatable textures.
  107561. * @param animatables Array of animatable textures.
  107562. */
  107563. getAnimatables(animatables: IAnimatable[]): void;
  107564. /**
  107565. * Disposes the resources of the material.
  107566. * @param forceDisposeTextures - Forces the disposal of all textures.
  107567. */
  107568. dispose(forceDisposeTextures?: boolean): void;
  107569. /**
  107570. * Get the current class name of the texture useful for serialization or dynamic coding.
  107571. * @returns "PBRSubSurfaceConfiguration"
  107572. */
  107573. getClassName(): string;
  107574. /**
  107575. * Add fallbacks to the effect fallbacks list.
  107576. * @param defines defines the Base texture to use.
  107577. * @param fallbacks defines the current fallback list.
  107578. * @param currentRank defines the current fallback rank.
  107579. * @returns the new fallback rank.
  107580. */
  107581. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107582. /**
  107583. * Add the required uniforms to the current list.
  107584. * @param uniforms defines the current uniform list.
  107585. */
  107586. static AddUniforms(uniforms: string[]): void;
  107587. /**
  107588. * Add the required samplers to the current list.
  107589. * @param samplers defines the current sampler list.
  107590. */
  107591. static AddSamplers(samplers: string[]): void;
  107592. /**
  107593. * Add the required uniforms to the current buffer.
  107594. * @param uniformBuffer defines the current uniform buffer.
  107595. */
  107596. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107597. /**
  107598. * Makes a duplicate of the current configuration into another one.
  107599. * @param configuration define the config where to copy the info
  107600. */
  107601. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107602. /**
  107603. * Serializes this Sub Surface configuration.
  107604. * @returns - An object with the serialized config.
  107605. */
  107606. serialize(): any;
  107607. /**
  107608. * Parses a Sub Surface Configuration from a serialized object.
  107609. * @param source - Serialized object.
  107610. */
  107611. parse(source: any): void;
  107612. }
  107613. }
  107614. declare module BABYLON {
  107615. /** @hidden */
  107616. export var pbrFragmentDeclaration: {
  107617. name: string;
  107618. shader: string;
  107619. };
  107620. }
  107621. declare module BABYLON {
  107622. /** @hidden */
  107623. export var pbrUboDeclaration: {
  107624. name: string;
  107625. shader: string;
  107626. };
  107627. }
  107628. declare module BABYLON {
  107629. /** @hidden */
  107630. export var pbrFragmentExtraDeclaration: {
  107631. name: string;
  107632. shader: string;
  107633. };
  107634. }
  107635. declare module BABYLON {
  107636. /** @hidden */
  107637. export var pbrFragmentSamplersDeclaration: {
  107638. name: string;
  107639. shader: string;
  107640. };
  107641. }
  107642. declare module BABYLON {
  107643. /** @hidden */
  107644. export var pbrHelperFunctions: {
  107645. name: string;
  107646. shader: string;
  107647. };
  107648. }
  107649. declare module BABYLON {
  107650. /** @hidden */
  107651. export var harmonicsFunctions: {
  107652. name: string;
  107653. shader: string;
  107654. };
  107655. }
  107656. declare module BABYLON {
  107657. /** @hidden */
  107658. export var pbrDirectLightingSetupFunctions: {
  107659. name: string;
  107660. shader: string;
  107661. };
  107662. }
  107663. declare module BABYLON {
  107664. /** @hidden */
  107665. export var pbrDirectLightingFalloffFunctions: {
  107666. name: string;
  107667. shader: string;
  107668. };
  107669. }
  107670. declare module BABYLON {
  107671. /** @hidden */
  107672. export var pbrBRDFFunctions: {
  107673. name: string;
  107674. shader: string;
  107675. };
  107676. }
  107677. declare module BABYLON {
  107678. /** @hidden */
  107679. export var pbrDirectLightingFunctions: {
  107680. name: string;
  107681. shader: string;
  107682. };
  107683. }
  107684. declare module BABYLON {
  107685. /** @hidden */
  107686. export var pbrIBLFunctions: {
  107687. name: string;
  107688. shader: string;
  107689. };
  107690. }
  107691. declare module BABYLON {
  107692. /** @hidden */
  107693. export var pbrDebug: {
  107694. name: string;
  107695. shader: string;
  107696. };
  107697. }
  107698. declare module BABYLON {
  107699. /** @hidden */
  107700. export var pbrPixelShader: {
  107701. name: string;
  107702. shader: string;
  107703. };
  107704. }
  107705. declare module BABYLON {
  107706. /** @hidden */
  107707. export var pbrVertexDeclaration: {
  107708. name: string;
  107709. shader: string;
  107710. };
  107711. }
  107712. declare module BABYLON {
  107713. /** @hidden */
  107714. export var pbrVertexShader: {
  107715. name: string;
  107716. shader: string;
  107717. };
  107718. }
  107719. declare module BABYLON {
  107720. /**
  107721. * Manages the defines for the PBR Material.
  107722. * @hidden
  107723. */
  107724. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107725. PBR: boolean;
  107726. MAINUV1: boolean;
  107727. MAINUV2: boolean;
  107728. UV1: boolean;
  107729. UV2: boolean;
  107730. ALBEDO: boolean;
  107731. ALBEDODIRECTUV: number;
  107732. VERTEXCOLOR: boolean;
  107733. AMBIENT: boolean;
  107734. AMBIENTDIRECTUV: number;
  107735. AMBIENTINGRAYSCALE: boolean;
  107736. OPACITY: boolean;
  107737. VERTEXALPHA: boolean;
  107738. OPACITYDIRECTUV: number;
  107739. OPACITYRGB: boolean;
  107740. ALPHATEST: boolean;
  107741. DEPTHPREPASS: boolean;
  107742. ALPHABLEND: boolean;
  107743. ALPHAFROMALBEDO: boolean;
  107744. ALPHATESTVALUE: string;
  107745. SPECULAROVERALPHA: boolean;
  107746. RADIANCEOVERALPHA: boolean;
  107747. ALPHAFRESNEL: boolean;
  107748. LINEARALPHAFRESNEL: boolean;
  107749. PREMULTIPLYALPHA: boolean;
  107750. EMISSIVE: boolean;
  107751. EMISSIVEDIRECTUV: number;
  107752. REFLECTIVITY: boolean;
  107753. REFLECTIVITYDIRECTUV: number;
  107754. SPECULARTERM: boolean;
  107755. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107756. MICROSURFACEAUTOMATIC: boolean;
  107757. LODBASEDMICROSFURACE: boolean;
  107758. MICROSURFACEMAP: boolean;
  107759. MICROSURFACEMAPDIRECTUV: number;
  107760. METALLICWORKFLOW: boolean;
  107761. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107762. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107763. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107764. AOSTOREINMETALMAPRED: boolean;
  107765. ENVIRONMENTBRDF: boolean;
  107766. ENVIRONMENTBRDF_RGBD: boolean;
  107767. NORMAL: boolean;
  107768. TANGENT: boolean;
  107769. BUMP: boolean;
  107770. BUMPDIRECTUV: number;
  107771. OBJECTSPACE_NORMALMAP: boolean;
  107772. PARALLAX: boolean;
  107773. PARALLAXOCCLUSION: boolean;
  107774. NORMALXYSCALE: boolean;
  107775. LIGHTMAP: boolean;
  107776. LIGHTMAPDIRECTUV: number;
  107777. USELIGHTMAPASSHADOWMAP: boolean;
  107778. GAMMALIGHTMAP: boolean;
  107779. REFLECTION: boolean;
  107780. REFLECTIONMAP_3D: boolean;
  107781. REFLECTIONMAP_SPHERICAL: boolean;
  107782. REFLECTIONMAP_PLANAR: boolean;
  107783. REFLECTIONMAP_CUBIC: boolean;
  107784. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107785. REFLECTIONMAP_PROJECTION: boolean;
  107786. REFLECTIONMAP_SKYBOX: boolean;
  107787. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107788. REFLECTIONMAP_EXPLICIT: boolean;
  107789. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107790. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107791. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107792. INVERTCUBICMAP: boolean;
  107793. USESPHERICALFROMREFLECTIONMAP: boolean;
  107794. USEIRRADIANCEMAP: boolean;
  107795. SPHERICAL_HARMONICS: boolean;
  107796. USESPHERICALINVERTEX: boolean;
  107797. REFLECTIONMAP_OPPOSITEZ: boolean;
  107798. LODINREFLECTIONALPHA: boolean;
  107799. GAMMAREFLECTION: boolean;
  107800. RGBDREFLECTION: boolean;
  107801. LINEARSPECULARREFLECTION: boolean;
  107802. RADIANCEOCCLUSION: boolean;
  107803. HORIZONOCCLUSION: boolean;
  107804. INSTANCES: boolean;
  107805. NUM_BONE_INFLUENCERS: number;
  107806. BonesPerMesh: number;
  107807. BONETEXTURE: boolean;
  107808. NONUNIFORMSCALING: boolean;
  107809. MORPHTARGETS: boolean;
  107810. MORPHTARGETS_NORMAL: boolean;
  107811. MORPHTARGETS_TANGENT: boolean;
  107812. NUM_MORPH_INFLUENCERS: number;
  107813. IMAGEPROCESSING: boolean;
  107814. VIGNETTE: boolean;
  107815. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107816. VIGNETTEBLENDMODEOPAQUE: boolean;
  107817. TONEMAPPING: boolean;
  107818. TONEMAPPING_ACES: boolean;
  107819. CONTRAST: boolean;
  107820. COLORCURVES: boolean;
  107821. COLORGRADING: boolean;
  107822. COLORGRADING3D: boolean;
  107823. SAMPLER3DGREENDEPTH: boolean;
  107824. SAMPLER3DBGRMAP: boolean;
  107825. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107826. EXPOSURE: boolean;
  107827. MULTIVIEW: boolean;
  107828. USEPHYSICALLIGHTFALLOFF: boolean;
  107829. USEGLTFLIGHTFALLOFF: boolean;
  107830. TWOSIDEDLIGHTING: boolean;
  107831. SHADOWFLOAT: boolean;
  107832. CLIPPLANE: boolean;
  107833. CLIPPLANE2: boolean;
  107834. CLIPPLANE3: boolean;
  107835. CLIPPLANE4: boolean;
  107836. POINTSIZE: boolean;
  107837. FOG: boolean;
  107838. LOGARITHMICDEPTH: boolean;
  107839. FORCENORMALFORWARD: boolean;
  107840. SPECULARAA: boolean;
  107841. CLEARCOAT: boolean;
  107842. CLEARCOAT_DEFAULTIOR: boolean;
  107843. CLEARCOAT_TEXTURE: boolean;
  107844. CLEARCOAT_TEXTUREDIRECTUV: number;
  107845. CLEARCOAT_BUMP: boolean;
  107846. CLEARCOAT_BUMPDIRECTUV: number;
  107847. CLEARCOAT_TINT: boolean;
  107848. CLEARCOAT_TINT_TEXTURE: boolean;
  107849. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107850. ANISOTROPIC: boolean;
  107851. ANISOTROPIC_TEXTURE: boolean;
  107852. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107853. BRDF_V_HEIGHT_CORRELATED: boolean;
  107854. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107855. SHEEN: boolean;
  107856. SHEEN_TEXTURE: boolean;
  107857. SHEEN_TEXTUREDIRECTUV: number;
  107858. SHEEN_LINKWITHALBEDO: boolean;
  107859. SUBSURFACE: boolean;
  107860. SS_REFRACTION: boolean;
  107861. SS_TRANSLUCENCY: boolean;
  107862. SS_SCATERRING: boolean;
  107863. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107864. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107865. SS_REFRACTIONMAP_3D: boolean;
  107866. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107867. SS_LODINREFRACTIONALPHA: boolean;
  107868. SS_GAMMAREFRACTION: boolean;
  107869. SS_RGBDREFRACTION: boolean;
  107870. SS_LINEARSPECULARREFRACTION: boolean;
  107871. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107872. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107873. UNLIT: boolean;
  107874. DEBUGMODE: number;
  107875. /**
  107876. * Initializes the PBR Material defines.
  107877. */
  107878. constructor();
  107879. /**
  107880. * Resets the PBR Material defines.
  107881. */
  107882. reset(): void;
  107883. }
  107884. /**
  107885. * The Physically based material base class of BJS.
  107886. *
  107887. * This offers the main features of a standard PBR material.
  107888. * For more information, please refer to the documentation :
  107889. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107890. */
  107891. export abstract class PBRBaseMaterial extends PushMaterial {
  107892. /**
  107893. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107894. */
  107895. static readonly PBRMATERIAL_OPAQUE: number;
  107896. /**
  107897. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107898. */
  107899. static readonly PBRMATERIAL_ALPHATEST: number;
  107900. /**
  107901. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107902. */
  107903. static readonly PBRMATERIAL_ALPHABLEND: number;
  107904. /**
  107905. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107906. * They are also discarded below the alpha cutoff threshold to improve performances.
  107907. */
  107908. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107909. /**
  107910. * Defines the default value of how much AO map is occluding the analytical lights
  107911. * (point spot...).
  107912. */
  107913. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107914. /**
  107915. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107916. */
  107917. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107918. /**
  107919. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107920. * to enhance interoperability with other engines.
  107921. */
  107922. static readonly LIGHTFALLOFF_GLTF: number;
  107923. /**
  107924. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107925. * to enhance interoperability with other materials.
  107926. */
  107927. static readonly LIGHTFALLOFF_STANDARD: number;
  107928. /**
  107929. * Intensity of the direct lights e.g. the four lights available in your scene.
  107930. * This impacts both the direct diffuse and specular highlights.
  107931. */
  107932. protected _directIntensity: number;
  107933. /**
  107934. * Intensity of the emissive part of the material.
  107935. * This helps controlling the emissive effect without modifying the emissive color.
  107936. */
  107937. protected _emissiveIntensity: number;
  107938. /**
  107939. * Intensity of the environment e.g. how much the environment will light the object
  107940. * either through harmonics for rough material or through the refelction for shiny ones.
  107941. */
  107942. protected _environmentIntensity: number;
  107943. /**
  107944. * This is a special control allowing the reduction of the specular highlights coming from the
  107945. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107946. */
  107947. protected _specularIntensity: number;
  107948. /**
  107949. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107950. */
  107951. private _lightingInfos;
  107952. /**
  107953. * Debug Control allowing disabling the bump map on this material.
  107954. */
  107955. protected _disableBumpMap: boolean;
  107956. /**
  107957. * AKA Diffuse Texture in standard nomenclature.
  107958. */
  107959. protected _albedoTexture: Nullable<BaseTexture>;
  107960. /**
  107961. * AKA Occlusion Texture in other nomenclature.
  107962. */
  107963. protected _ambientTexture: Nullable<BaseTexture>;
  107964. /**
  107965. * AKA Occlusion Texture Intensity in other nomenclature.
  107966. */
  107967. protected _ambientTextureStrength: number;
  107968. /**
  107969. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107970. * 1 means it completely occludes it
  107971. * 0 mean it has no impact
  107972. */
  107973. protected _ambientTextureImpactOnAnalyticalLights: number;
  107974. /**
  107975. * Stores the alpha values in a texture.
  107976. */
  107977. protected _opacityTexture: Nullable<BaseTexture>;
  107978. /**
  107979. * Stores the reflection values in a texture.
  107980. */
  107981. protected _reflectionTexture: Nullable<BaseTexture>;
  107982. /**
  107983. * Stores the emissive values in a texture.
  107984. */
  107985. protected _emissiveTexture: Nullable<BaseTexture>;
  107986. /**
  107987. * AKA Specular texture in other nomenclature.
  107988. */
  107989. protected _reflectivityTexture: Nullable<BaseTexture>;
  107990. /**
  107991. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107992. */
  107993. protected _metallicTexture: Nullable<BaseTexture>;
  107994. /**
  107995. * Specifies the metallic scalar of the metallic/roughness workflow.
  107996. * Can also be used to scale the metalness values of the metallic texture.
  107997. */
  107998. protected _metallic: Nullable<number>;
  107999. /**
  108000. * Specifies the roughness scalar of the metallic/roughness workflow.
  108001. * Can also be used to scale the roughness values of the metallic texture.
  108002. */
  108003. protected _roughness: Nullable<number>;
  108004. /**
  108005. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108006. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108007. */
  108008. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108009. /**
  108010. * Stores surface normal data used to displace a mesh in a texture.
  108011. */
  108012. protected _bumpTexture: Nullable<BaseTexture>;
  108013. /**
  108014. * Stores the pre-calculated light information of a mesh in a texture.
  108015. */
  108016. protected _lightmapTexture: Nullable<BaseTexture>;
  108017. /**
  108018. * The color of a material in ambient lighting.
  108019. */
  108020. protected _ambientColor: Color3;
  108021. /**
  108022. * AKA Diffuse Color in other nomenclature.
  108023. */
  108024. protected _albedoColor: Color3;
  108025. /**
  108026. * AKA Specular Color in other nomenclature.
  108027. */
  108028. protected _reflectivityColor: Color3;
  108029. /**
  108030. * The color applied when light is reflected from a material.
  108031. */
  108032. protected _reflectionColor: Color3;
  108033. /**
  108034. * The color applied when light is emitted from a material.
  108035. */
  108036. protected _emissiveColor: Color3;
  108037. /**
  108038. * AKA Glossiness in other nomenclature.
  108039. */
  108040. protected _microSurface: number;
  108041. /**
  108042. * Specifies that the material will use the light map as a show map.
  108043. */
  108044. protected _useLightmapAsShadowmap: boolean;
  108045. /**
  108046. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108047. * makes the reflect vector face the model (under horizon).
  108048. */
  108049. protected _useHorizonOcclusion: boolean;
  108050. /**
  108051. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108052. * too much the area relying on ambient texture to define their ambient occlusion.
  108053. */
  108054. protected _useRadianceOcclusion: boolean;
  108055. /**
  108056. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108057. */
  108058. protected _useAlphaFromAlbedoTexture: boolean;
  108059. /**
  108060. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108061. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108062. */
  108063. protected _useSpecularOverAlpha: boolean;
  108064. /**
  108065. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108066. */
  108067. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108068. /**
  108069. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108070. */
  108071. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108072. /**
  108073. * Specifies if the metallic texture contains the roughness information in its green channel.
  108074. */
  108075. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108076. /**
  108077. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108078. */
  108079. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108080. /**
  108081. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108082. */
  108083. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108084. /**
  108085. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108086. */
  108087. protected _useAmbientInGrayScale: boolean;
  108088. /**
  108089. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108090. * The material will try to infer what glossiness each pixel should be.
  108091. */
  108092. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108093. /**
  108094. * Defines the falloff type used in this material.
  108095. * It by default is Physical.
  108096. */
  108097. protected _lightFalloff: number;
  108098. /**
  108099. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108100. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108101. */
  108102. protected _useRadianceOverAlpha: boolean;
  108103. /**
  108104. * Allows using an object space normal map (instead of tangent space).
  108105. */
  108106. protected _useObjectSpaceNormalMap: boolean;
  108107. /**
  108108. * Allows using the bump map in parallax mode.
  108109. */
  108110. protected _useParallax: boolean;
  108111. /**
  108112. * Allows using the bump map in parallax occlusion mode.
  108113. */
  108114. protected _useParallaxOcclusion: boolean;
  108115. /**
  108116. * Controls the scale bias of the parallax mode.
  108117. */
  108118. protected _parallaxScaleBias: number;
  108119. /**
  108120. * If sets to true, disables all the lights affecting the material.
  108121. */
  108122. protected _disableLighting: boolean;
  108123. /**
  108124. * Number of Simultaneous lights allowed on the material.
  108125. */
  108126. protected _maxSimultaneousLights: number;
  108127. /**
  108128. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108129. */
  108130. protected _invertNormalMapX: boolean;
  108131. /**
  108132. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108133. */
  108134. protected _invertNormalMapY: boolean;
  108135. /**
  108136. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108137. */
  108138. protected _twoSidedLighting: boolean;
  108139. /**
  108140. * Defines the alpha limits in alpha test mode.
  108141. */
  108142. protected _alphaCutOff: number;
  108143. /**
  108144. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108145. */
  108146. protected _forceAlphaTest: boolean;
  108147. /**
  108148. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108149. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108150. */
  108151. protected _useAlphaFresnel: boolean;
  108152. /**
  108153. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108154. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108155. */
  108156. protected _useLinearAlphaFresnel: boolean;
  108157. /**
  108158. * The transparency mode of the material.
  108159. */
  108160. protected _transparencyMode: Nullable<number>;
  108161. /**
  108162. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108163. * from cos thetav and roughness:
  108164. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108165. */
  108166. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108167. /**
  108168. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108169. */
  108170. protected _forceIrradianceInFragment: boolean;
  108171. /**
  108172. * Force normal to face away from face.
  108173. */
  108174. protected _forceNormalForward: boolean;
  108175. /**
  108176. * Enables specular anti aliasing in the PBR shader.
  108177. * It will both interacts on the Geometry for analytical and IBL lighting.
  108178. * It also prefilter the roughness map based on the bump values.
  108179. */
  108180. protected _enableSpecularAntiAliasing: boolean;
  108181. /**
  108182. * Default configuration related to image processing available in the PBR Material.
  108183. */
  108184. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108185. /**
  108186. * Keep track of the image processing observer to allow dispose and replace.
  108187. */
  108188. private _imageProcessingObserver;
  108189. /**
  108190. * Attaches a new image processing configuration to the PBR Material.
  108191. * @param configuration
  108192. */
  108193. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108194. /**
  108195. * Stores the available render targets.
  108196. */
  108197. private _renderTargets;
  108198. /**
  108199. * Sets the global ambient color for the material used in lighting calculations.
  108200. */
  108201. private _globalAmbientColor;
  108202. /**
  108203. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108204. */
  108205. private _useLogarithmicDepth;
  108206. /**
  108207. * If set to true, no lighting calculations will be applied.
  108208. */
  108209. private _unlit;
  108210. private _debugMode;
  108211. /**
  108212. * @hidden
  108213. * This is reserved for the inspector.
  108214. * Defines the material debug mode.
  108215. * It helps seeing only some components of the material while troubleshooting.
  108216. */
  108217. debugMode: number;
  108218. /**
  108219. * @hidden
  108220. * This is reserved for the inspector.
  108221. * Specify from where on screen the debug mode should start.
  108222. * The value goes from -1 (full screen) to 1 (not visible)
  108223. * It helps with side by side comparison against the final render
  108224. * This defaults to -1
  108225. */
  108226. private debugLimit;
  108227. /**
  108228. * @hidden
  108229. * This is reserved for the inspector.
  108230. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108231. * You can use the factor to better multiply the final value.
  108232. */
  108233. private debugFactor;
  108234. /**
  108235. * Defines the clear coat layer parameters for the material.
  108236. */
  108237. readonly clearCoat: PBRClearCoatConfiguration;
  108238. /**
  108239. * Defines the anisotropic parameters for the material.
  108240. */
  108241. readonly anisotropy: PBRAnisotropicConfiguration;
  108242. /**
  108243. * Defines the BRDF parameters for the material.
  108244. */
  108245. readonly brdf: PBRBRDFConfiguration;
  108246. /**
  108247. * Defines the Sheen parameters for the material.
  108248. */
  108249. readonly sheen: PBRSheenConfiguration;
  108250. /**
  108251. * Defines the SubSurface parameters for the material.
  108252. */
  108253. readonly subSurface: PBRSubSurfaceConfiguration;
  108254. /**
  108255. * Custom callback helping to override the default shader used in the material.
  108256. */
  108257. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108258. /**
  108259. * Instantiates a new PBRMaterial instance.
  108260. *
  108261. * @param name The material name
  108262. * @param scene The scene the material will be use in.
  108263. */
  108264. constructor(name: string, scene: Scene);
  108265. /**
  108266. * Gets a boolean indicating that current material needs to register RTT
  108267. */
  108268. readonly hasRenderTargetTextures: boolean;
  108269. /**
  108270. * Gets the name of the material class.
  108271. */
  108272. getClassName(): string;
  108273. /**
  108274. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108275. */
  108276. /**
  108277. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108278. */
  108279. useLogarithmicDepth: boolean;
  108280. /**
  108281. * Gets the current transparency mode.
  108282. */
  108283. /**
  108284. * Sets the transparency mode of the material.
  108285. *
  108286. * | Value | Type | Description |
  108287. * | ----- | ----------------------------------- | ----------- |
  108288. * | 0 | OPAQUE | |
  108289. * | 1 | ALPHATEST | |
  108290. * | 2 | ALPHABLEND | |
  108291. * | 3 | ALPHATESTANDBLEND | |
  108292. *
  108293. */
  108294. transparencyMode: Nullable<number>;
  108295. /**
  108296. * Returns true if alpha blending should be disabled.
  108297. */
  108298. private readonly _disableAlphaBlending;
  108299. /**
  108300. * Specifies whether or not this material should be rendered in alpha blend mode.
  108301. */
  108302. needAlphaBlending(): boolean;
  108303. /**
  108304. * Specifies if the mesh will require alpha blending.
  108305. * @param mesh - BJS mesh.
  108306. */
  108307. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108308. /**
  108309. * Specifies whether or not this material should be rendered in alpha test mode.
  108310. */
  108311. needAlphaTesting(): boolean;
  108312. /**
  108313. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108314. */
  108315. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108316. /**
  108317. * Gets the texture used for the alpha test.
  108318. */
  108319. getAlphaTestTexture(): Nullable<BaseTexture>;
  108320. /**
  108321. * Specifies that the submesh is ready to be used.
  108322. * @param mesh - BJS mesh.
  108323. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108324. * @param useInstances - Specifies that instances should be used.
  108325. * @returns - boolean indicating that the submesh is ready or not.
  108326. */
  108327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108328. /**
  108329. * Specifies if the material uses metallic roughness workflow.
  108330. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108331. */
  108332. isMetallicWorkflow(): boolean;
  108333. private _prepareEffect;
  108334. private _prepareDefines;
  108335. /**
  108336. * Force shader compilation
  108337. */
  108338. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108339. clipPlane: boolean;
  108340. }>): void;
  108341. /**
  108342. * Initializes the uniform buffer layout for the shader.
  108343. */
  108344. buildUniformLayout(): void;
  108345. /**
  108346. * Unbinds the material from the mesh
  108347. */
  108348. unbind(): void;
  108349. /**
  108350. * Binds the submesh data.
  108351. * @param world - The world matrix.
  108352. * @param mesh - The BJS mesh.
  108353. * @param subMesh - A submesh of the BJS mesh.
  108354. */
  108355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108356. /**
  108357. * Returns the animatable textures.
  108358. * @returns - Array of animatable textures.
  108359. */
  108360. getAnimatables(): IAnimatable[];
  108361. /**
  108362. * Returns the texture used for reflections.
  108363. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108364. */
  108365. private _getReflectionTexture;
  108366. /**
  108367. * Returns an array of the actively used textures.
  108368. * @returns - Array of BaseTextures
  108369. */
  108370. getActiveTextures(): BaseTexture[];
  108371. /**
  108372. * Checks to see if a texture is used in the material.
  108373. * @param texture - Base texture to use.
  108374. * @returns - Boolean specifying if a texture is used in the material.
  108375. */
  108376. hasTexture(texture: BaseTexture): boolean;
  108377. /**
  108378. * Disposes the resources of the material.
  108379. * @param forceDisposeEffect - Forces the disposal of effects.
  108380. * @param forceDisposeTextures - Forces the disposal of all textures.
  108381. */
  108382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108383. }
  108384. }
  108385. declare module BABYLON {
  108386. /**
  108387. * The Physically based material of BJS.
  108388. *
  108389. * This offers the main features of a standard PBR material.
  108390. * For more information, please refer to the documentation :
  108391. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108392. */
  108393. export class PBRMaterial extends PBRBaseMaterial {
  108394. /**
  108395. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108396. */
  108397. static readonly PBRMATERIAL_OPAQUE: number;
  108398. /**
  108399. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108400. */
  108401. static readonly PBRMATERIAL_ALPHATEST: number;
  108402. /**
  108403. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108404. */
  108405. static readonly PBRMATERIAL_ALPHABLEND: number;
  108406. /**
  108407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108408. * They are also discarded below the alpha cutoff threshold to improve performances.
  108409. */
  108410. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108411. /**
  108412. * Defines the default value of how much AO map is occluding the analytical lights
  108413. * (point spot...).
  108414. */
  108415. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108416. /**
  108417. * Intensity of the direct lights e.g. the four lights available in your scene.
  108418. * This impacts both the direct diffuse and specular highlights.
  108419. */
  108420. directIntensity: number;
  108421. /**
  108422. * Intensity of the emissive part of the material.
  108423. * This helps controlling the emissive effect without modifying the emissive color.
  108424. */
  108425. emissiveIntensity: number;
  108426. /**
  108427. * Intensity of the environment e.g. how much the environment will light the object
  108428. * either through harmonics for rough material or through the refelction for shiny ones.
  108429. */
  108430. environmentIntensity: number;
  108431. /**
  108432. * This is a special control allowing the reduction of the specular highlights coming from the
  108433. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108434. */
  108435. specularIntensity: number;
  108436. /**
  108437. * Debug Control allowing disabling the bump map on this material.
  108438. */
  108439. disableBumpMap: boolean;
  108440. /**
  108441. * AKA Diffuse Texture in standard nomenclature.
  108442. */
  108443. albedoTexture: BaseTexture;
  108444. /**
  108445. * AKA Occlusion Texture in other nomenclature.
  108446. */
  108447. ambientTexture: BaseTexture;
  108448. /**
  108449. * AKA Occlusion Texture Intensity in other nomenclature.
  108450. */
  108451. ambientTextureStrength: number;
  108452. /**
  108453. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108454. * 1 means it completely occludes it
  108455. * 0 mean it has no impact
  108456. */
  108457. ambientTextureImpactOnAnalyticalLights: number;
  108458. /**
  108459. * Stores the alpha values in a texture.
  108460. */
  108461. opacityTexture: BaseTexture;
  108462. /**
  108463. * Stores the reflection values in a texture.
  108464. */
  108465. reflectionTexture: Nullable<BaseTexture>;
  108466. /**
  108467. * Stores the emissive values in a texture.
  108468. */
  108469. emissiveTexture: BaseTexture;
  108470. /**
  108471. * AKA Specular texture in other nomenclature.
  108472. */
  108473. reflectivityTexture: BaseTexture;
  108474. /**
  108475. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108476. */
  108477. metallicTexture: BaseTexture;
  108478. /**
  108479. * Specifies the metallic scalar of the metallic/roughness workflow.
  108480. * Can also be used to scale the metalness values of the metallic texture.
  108481. */
  108482. metallic: Nullable<number>;
  108483. /**
  108484. * Specifies the roughness scalar of the metallic/roughness workflow.
  108485. * Can also be used to scale the roughness values of the metallic texture.
  108486. */
  108487. roughness: Nullable<number>;
  108488. /**
  108489. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108490. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108491. */
  108492. microSurfaceTexture: BaseTexture;
  108493. /**
  108494. * Stores surface normal data used to displace a mesh in a texture.
  108495. */
  108496. bumpTexture: BaseTexture;
  108497. /**
  108498. * Stores the pre-calculated light information of a mesh in a texture.
  108499. */
  108500. lightmapTexture: BaseTexture;
  108501. /**
  108502. * Stores the refracted light information in a texture.
  108503. */
  108504. refractionTexture: Nullable<BaseTexture>;
  108505. /**
  108506. * The color of a material in ambient lighting.
  108507. */
  108508. ambientColor: Color3;
  108509. /**
  108510. * AKA Diffuse Color in other nomenclature.
  108511. */
  108512. albedoColor: Color3;
  108513. /**
  108514. * AKA Specular Color in other nomenclature.
  108515. */
  108516. reflectivityColor: Color3;
  108517. /**
  108518. * The color reflected from the material.
  108519. */
  108520. reflectionColor: Color3;
  108521. /**
  108522. * The color emitted from the material.
  108523. */
  108524. emissiveColor: Color3;
  108525. /**
  108526. * AKA Glossiness in other nomenclature.
  108527. */
  108528. microSurface: number;
  108529. /**
  108530. * source material index of refraction (IOR)' / 'destination material IOR.
  108531. */
  108532. indexOfRefraction: number;
  108533. /**
  108534. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108535. */
  108536. invertRefractionY: boolean;
  108537. /**
  108538. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108539. * Materials half opaque for instance using refraction could benefit from this control.
  108540. */
  108541. linkRefractionWithTransparency: boolean;
  108542. /**
  108543. * If true, the light map contains occlusion information instead of lighting info.
  108544. */
  108545. useLightmapAsShadowmap: boolean;
  108546. /**
  108547. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108548. */
  108549. useAlphaFromAlbedoTexture: boolean;
  108550. /**
  108551. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108552. */
  108553. forceAlphaTest: boolean;
  108554. /**
  108555. * Defines the alpha limits in alpha test mode.
  108556. */
  108557. alphaCutOff: number;
  108558. /**
  108559. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108560. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108561. */
  108562. useSpecularOverAlpha: boolean;
  108563. /**
  108564. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108565. */
  108566. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108567. /**
  108568. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108569. */
  108570. useRoughnessFromMetallicTextureAlpha: boolean;
  108571. /**
  108572. * Specifies if the metallic texture contains the roughness information in its green channel.
  108573. */
  108574. useRoughnessFromMetallicTextureGreen: boolean;
  108575. /**
  108576. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108577. */
  108578. useMetallnessFromMetallicTextureBlue: boolean;
  108579. /**
  108580. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108581. */
  108582. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108583. /**
  108584. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108585. */
  108586. useAmbientInGrayScale: boolean;
  108587. /**
  108588. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108589. * The material will try to infer what glossiness each pixel should be.
  108590. */
  108591. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108592. /**
  108593. * BJS is using an harcoded light falloff based on a manually sets up range.
  108594. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108595. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108596. */
  108597. /**
  108598. * BJS is using an harcoded light falloff based on a manually sets up range.
  108599. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108600. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108601. */
  108602. usePhysicalLightFalloff: boolean;
  108603. /**
  108604. * In order to support the falloff compatibility with gltf, a special mode has been added
  108605. * to reproduce the gltf light falloff.
  108606. */
  108607. /**
  108608. * In order to support the falloff compatibility with gltf, a special mode has been added
  108609. * to reproduce the gltf light falloff.
  108610. */
  108611. useGLTFLightFalloff: boolean;
  108612. /**
  108613. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108614. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108615. */
  108616. useRadianceOverAlpha: boolean;
  108617. /**
  108618. * Allows using an object space normal map (instead of tangent space).
  108619. */
  108620. useObjectSpaceNormalMap: boolean;
  108621. /**
  108622. * Allows using the bump map in parallax mode.
  108623. */
  108624. useParallax: boolean;
  108625. /**
  108626. * Allows using the bump map in parallax occlusion mode.
  108627. */
  108628. useParallaxOcclusion: boolean;
  108629. /**
  108630. * Controls the scale bias of the parallax mode.
  108631. */
  108632. parallaxScaleBias: number;
  108633. /**
  108634. * If sets to true, disables all the lights affecting the material.
  108635. */
  108636. disableLighting: boolean;
  108637. /**
  108638. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108639. */
  108640. forceIrradianceInFragment: boolean;
  108641. /**
  108642. * Number of Simultaneous lights allowed on the material.
  108643. */
  108644. maxSimultaneousLights: number;
  108645. /**
  108646. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108647. */
  108648. invertNormalMapX: boolean;
  108649. /**
  108650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108651. */
  108652. invertNormalMapY: boolean;
  108653. /**
  108654. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108655. */
  108656. twoSidedLighting: boolean;
  108657. /**
  108658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108659. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108660. */
  108661. useAlphaFresnel: boolean;
  108662. /**
  108663. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108664. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108665. */
  108666. useLinearAlphaFresnel: boolean;
  108667. /**
  108668. * Let user defines the brdf lookup texture used for IBL.
  108669. * A default 8bit version is embedded but you could point at :
  108670. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108671. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108672. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108673. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108674. */
  108675. environmentBRDFTexture: Nullable<BaseTexture>;
  108676. /**
  108677. * Force normal to face away from face.
  108678. */
  108679. forceNormalForward: boolean;
  108680. /**
  108681. * Enables specular anti aliasing in the PBR shader.
  108682. * It will both interacts on the Geometry for analytical and IBL lighting.
  108683. * It also prefilter the roughness map based on the bump values.
  108684. */
  108685. enableSpecularAntiAliasing: boolean;
  108686. /**
  108687. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108688. * makes the reflect vector face the model (under horizon).
  108689. */
  108690. useHorizonOcclusion: boolean;
  108691. /**
  108692. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108693. * too much the area relying on ambient texture to define their ambient occlusion.
  108694. */
  108695. useRadianceOcclusion: boolean;
  108696. /**
  108697. * If set to true, no lighting calculations will be applied.
  108698. */
  108699. unlit: boolean;
  108700. /**
  108701. * Gets the image processing configuration used either in this material.
  108702. */
  108703. /**
  108704. * Sets the Default image processing configuration used either in the this material.
  108705. *
  108706. * If sets to null, the scene one is in use.
  108707. */
  108708. imageProcessingConfiguration: ImageProcessingConfiguration;
  108709. /**
  108710. * Gets wether the color curves effect is enabled.
  108711. */
  108712. /**
  108713. * Sets wether the color curves effect is enabled.
  108714. */
  108715. cameraColorCurvesEnabled: boolean;
  108716. /**
  108717. * Gets wether the color grading effect is enabled.
  108718. */
  108719. /**
  108720. * Gets wether the color grading effect is enabled.
  108721. */
  108722. cameraColorGradingEnabled: boolean;
  108723. /**
  108724. * Gets wether tonemapping is enabled or not.
  108725. */
  108726. /**
  108727. * Sets wether tonemapping is enabled or not
  108728. */
  108729. cameraToneMappingEnabled: boolean;
  108730. /**
  108731. * The camera exposure used on this material.
  108732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108733. * This corresponds to a photographic exposure.
  108734. */
  108735. /**
  108736. * The camera exposure used on this material.
  108737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108738. * This corresponds to a photographic exposure.
  108739. */
  108740. cameraExposure: number;
  108741. /**
  108742. * Gets The camera contrast used on this material.
  108743. */
  108744. /**
  108745. * Sets The camera contrast used on this material.
  108746. */
  108747. cameraContrast: number;
  108748. /**
  108749. * Gets the Color Grading 2D Lookup Texture.
  108750. */
  108751. /**
  108752. * Sets the Color Grading 2D Lookup Texture.
  108753. */
  108754. cameraColorGradingTexture: Nullable<BaseTexture>;
  108755. /**
  108756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108758. * 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;
  108759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108760. */
  108761. /**
  108762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108764. * 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;
  108765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108766. */
  108767. cameraColorCurves: Nullable<ColorCurves>;
  108768. /**
  108769. * Instantiates a new PBRMaterial instance.
  108770. *
  108771. * @param name The material name
  108772. * @param scene The scene the material will be use in.
  108773. */
  108774. constructor(name: string, scene: Scene);
  108775. /**
  108776. * Returns the name of this material class.
  108777. */
  108778. getClassName(): string;
  108779. /**
  108780. * Makes a duplicate of the current material.
  108781. * @param name - name to use for the new material.
  108782. */
  108783. clone(name: string): PBRMaterial;
  108784. /**
  108785. * Serializes this PBR Material.
  108786. * @returns - An object with the serialized material.
  108787. */
  108788. serialize(): any;
  108789. /**
  108790. * Parses a PBR Material from a serialized object.
  108791. * @param source - Serialized object.
  108792. * @param scene - BJS scene instance.
  108793. * @param rootUrl - url for the scene object
  108794. * @returns - PBRMaterial
  108795. */
  108796. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108797. }
  108798. }
  108799. declare module BABYLON {
  108800. /**
  108801. * Direct draw surface info
  108802. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  108803. */
  108804. export interface DDSInfo {
  108805. /**
  108806. * Width of the texture
  108807. */
  108808. width: number;
  108809. /**
  108810. * Width of the texture
  108811. */
  108812. height: number;
  108813. /**
  108814. * Number of Mipmaps for the texture
  108815. * @see https://en.wikipedia.org/wiki/Mipmap
  108816. */
  108817. mipmapCount: number;
  108818. /**
  108819. * If the textures format is a known fourCC format
  108820. * @see https://www.fourcc.org/
  108821. */
  108822. isFourCC: boolean;
  108823. /**
  108824. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  108825. */
  108826. isRGB: boolean;
  108827. /**
  108828. * If the texture is a lumincance format
  108829. */
  108830. isLuminance: boolean;
  108831. /**
  108832. * If this is a cube texture
  108833. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  108834. */
  108835. isCube: boolean;
  108836. /**
  108837. * If the texture is a compressed format eg. FOURCC_DXT1
  108838. */
  108839. isCompressed: boolean;
  108840. /**
  108841. * The dxgiFormat of the texture
  108842. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  108843. */
  108844. dxgiFormat: number;
  108845. /**
  108846. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  108847. */
  108848. textureType: number;
  108849. /**
  108850. * Sphericle polynomial created for the dds texture
  108851. */
  108852. sphericalPolynomial?: SphericalPolynomial;
  108853. }
  108854. /**
  108855. * Class used to provide DDS decompression tools
  108856. */
  108857. export class DDSTools {
  108858. /**
  108859. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  108860. */
  108861. static StoreLODInAlphaChannel: boolean;
  108862. /**
  108863. * Gets DDS information from an array buffer
  108864. * @param arrayBuffer defines the array buffer to read data from
  108865. * @returns the DDS information
  108866. */
  108867. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  108868. private static _FloatView;
  108869. private static _Int32View;
  108870. private static _ToHalfFloat;
  108871. private static _FromHalfFloat;
  108872. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  108873. private static _GetHalfFloatRGBAArrayBuffer;
  108874. private static _GetFloatRGBAArrayBuffer;
  108875. private static _GetFloatAsUIntRGBAArrayBuffer;
  108876. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  108877. private static _GetRGBAArrayBuffer;
  108878. private static _ExtractLongWordOrder;
  108879. private static _GetRGBArrayBuffer;
  108880. private static _GetLuminanceArrayBuffer;
  108881. /**
  108882. * Uploads DDS Levels to a Babylon Texture
  108883. * @hidden
  108884. */
  108885. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  108886. }
  108887. interface Engine {
  108888. /**
  108889. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  108890. * @param rootUrl defines the url where the file to load is located
  108891. * @param scene defines the current scene
  108892. * @param lodScale defines scale to apply to the mip map selection
  108893. * @param lodOffset defines offset to apply to the mip map selection
  108894. * @param onLoad defines an optional callback raised when the texture is loaded
  108895. * @param onError defines an optional callback raised if there is an issue to load the texture
  108896. * @param format defines the format of the data
  108897. * @param forcedExtension defines the extension to use to pick the right loader
  108898. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  108899. * @returns the cube texture as an InternalTexture
  108900. */
  108901. 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;
  108902. }
  108903. }
  108904. declare module BABYLON {
  108905. /**
  108906. * Implementation of the DDS Texture Loader.
  108907. * @hidden
  108908. */
  108909. export class _DDSTextureLoader implements IInternalTextureLoader {
  108910. /**
  108911. * Defines wether the loader supports cascade loading the different faces.
  108912. */
  108913. readonly supportCascades: boolean;
  108914. /**
  108915. * This returns if the loader support the current file information.
  108916. * @param extension defines the file extension of the file being loaded
  108917. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108918. * @param fallback defines the fallback internal texture if any
  108919. * @param isBase64 defines whether the texture is encoded as a base64
  108920. * @param isBuffer defines whether the texture data are stored as a buffer
  108921. * @returns true if the loader can load the specified file
  108922. */
  108923. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108924. /**
  108925. * Transform the url before loading if required.
  108926. * @param rootUrl the url of the texture
  108927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108928. * @returns the transformed texture
  108929. */
  108930. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108931. /**
  108932. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108933. * @param rootUrl the url of the texture
  108934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108935. * @returns the fallback texture
  108936. */
  108937. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108938. /**
  108939. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108940. * @param data contains the texture data
  108941. * @param texture defines the BabylonJS internal texture
  108942. * @param createPolynomials will be true if polynomials have been requested
  108943. * @param onLoad defines the callback to trigger once the texture is ready
  108944. * @param onError defines the callback to trigger in case of error
  108945. */
  108946. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108947. /**
  108948. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108949. * @param data contains the texture data
  108950. * @param texture defines the BabylonJS internal texture
  108951. * @param callback defines the method to call once ready to upload
  108952. */
  108953. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108954. }
  108955. }
  108956. declare module BABYLON {
  108957. /** @hidden */
  108958. export var rgbdEncodePixelShader: {
  108959. name: string;
  108960. shader: string;
  108961. };
  108962. }
  108963. declare module BABYLON {
  108964. /**
  108965. * Raw texture data and descriptor sufficient for WebGL texture upload
  108966. */
  108967. export interface EnvironmentTextureInfo {
  108968. /**
  108969. * Version of the environment map
  108970. */
  108971. version: number;
  108972. /**
  108973. * Width of image
  108974. */
  108975. width: number;
  108976. /**
  108977. * Irradiance information stored in the file.
  108978. */
  108979. irradiance: any;
  108980. /**
  108981. * Specular information stored in the file.
  108982. */
  108983. specular: any;
  108984. }
  108985. /**
  108986. * Sets of helpers addressing the serialization and deserialization of environment texture
  108987. * stored in a BabylonJS env file.
  108988. * Those files are usually stored as .env files.
  108989. */
  108990. export class EnvironmentTextureTools {
  108991. /**
  108992. * Magic number identifying the env file.
  108993. */
  108994. private static _MagicBytes;
  108995. /**
  108996. * Gets the environment info from an env file.
  108997. * @param data The array buffer containing the .env bytes.
  108998. * @returns the environment file info (the json header) if successfully parsed.
  108999. */
  109000. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109001. /**
  109002. * Creates an environment texture from a loaded cube texture.
  109003. * @param texture defines the cube texture to convert in env file
  109004. * @return a promise containing the environment data if succesfull.
  109005. */
  109006. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109007. /**
  109008. * Creates a JSON representation of the spherical data.
  109009. * @param texture defines the texture containing the polynomials
  109010. * @return the JSON representation of the spherical info
  109011. */
  109012. private static _CreateEnvTextureIrradiance;
  109013. /**
  109014. * Uploads the texture info contained in the env file to the GPU.
  109015. * @param texture defines the internal texture to upload to
  109016. * @param arrayBuffer defines the buffer cotaining the data to load
  109017. * @param info defines the texture info retrieved through the GetEnvInfo method
  109018. * @returns a promise
  109019. */
  109020. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109021. /**
  109022. * Uploads the levels of image data to the GPU.
  109023. * @param texture defines the internal texture to upload to
  109024. * @param imageData defines the array buffer views of image data [mipmap][face]
  109025. * @returns a promise
  109026. */
  109027. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109028. /**
  109029. * Uploads spherical polynomials information to the texture.
  109030. * @param texture defines the texture we are trying to upload the information to
  109031. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109032. */
  109033. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109034. /** @hidden */
  109035. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109036. }
  109037. }
  109038. declare module BABYLON {
  109039. /**
  109040. * Implementation of the ENV Texture Loader.
  109041. * @hidden
  109042. */
  109043. export class _ENVTextureLoader implements IInternalTextureLoader {
  109044. /**
  109045. * Defines wether the loader supports cascade loading the different faces.
  109046. */
  109047. readonly supportCascades: boolean;
  109048. /**
  109049. * This returns if the loader support the current file information.
  109050. * @param extension defines the file extension of the file being loaded
  109051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109052. * @param fallback defines the fallback internal texture if any
  109053. * @param isBase64 defines whether the texture is encoded as a base64
  109054. * @param isBuffer defines whether the texture data are stored as a buffer
  109055. * @returns true if the loader can load the specified file
  109056. */
  109057. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109058. /**
  109059. * Transform the url before loading if required.
  109060. * @param rootUrl the url of the texture
  109061. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109062. * @returns the transformed texture
  109063. */
  109064. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109065. /**
  109066. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109067. * @param rootUrl the url of the texture
  109068. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109069. * @returns the fallback texture
  109070. */
  109071. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109072. /**
  109073. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109074. * @param data contains the texture data
  109075. * @param texture defines the BabylonJS internal texture
  109076. * @param createPolynomials will be true if polynomials have been requested
  109077. * @param onLoad defines the callback to trigger once the texture is ready
  109078. * @param onError defines the callback to trigger in case of error
  109079. */
  109080. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109081. /**
  109082. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109083. * @param data contains the texture data
  109084. * @param texture defines the BabylonJS internal texture
  109085. * @param callback defines the method to call once ready to upload
  109086. */
  109087. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109088. }
  109089. }
  109090. declare module BABYLON {
  109091. /**
  109092. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109093. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109094. */
  109095. export class KhronosTextureContainer {
  109096. /** contents of the KTX container file */
  109097. arrayBuffer: any;
  109098. private static HEADER_LEN;
  109099. private static COMPRESSED_2D;
  109100. private static COMPRESSED_3D;
  109101. private static TEX_2D;
  109102. private static TEX_3D;
  109103. /**
  109104. * Gets the openGL type
  109105. */
  109106. glType: number;
  109107. /**
  109108. * Gets the openGL type size
  109109. */
  109110. glTypeSize: number;
  109111. /**
  109112. * Gets the openGL format
  109113. */
  109114. glFormat: number;
  109115. /**
  109116. * Gets the openGL internal format
  109117. */
  109118. glInternalFormat: number;
  109119. /**
  109120. * Gets the base internal format
  109121. */
  109122. glBaseInternalFormat: number;
  109123. /**
  109124. * Gets image width in pixel
  109125. */
  109126. pixelWidth: number;
  109127. /**
  109128. * Gets image height in pixel
  109129. */
  109130. pixelHeight: number;
  109131. /**
  109132. * Gets image depth in pixels
  109133. */
  109134. pixelDepth: number;
  109135. /**
  109136. * Gets the number of array elements
  109137. */
  109138. numberOfArrayElements: number;
  109139. /**
  109140. * Gets the number of faces
  109141. */
  109142. numberOfFaces: number;
  109143. /**
  109144. * Gets the number of mipmap levels
  109145. */
  109146. numberOfMipmapLevels: number;
  109147. /**
  109148. * Gets the bytes of key value data
  109149. */
  109150. bytesOfKeyValueData: number;
  109151. /**
  109152. * Gets the load type
  109153. */
  109154. loadType: number;
  109155. /**
  109156. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109157. */
  109158. isInvalid: boolean;
  109159. /**
  109160. * Creates a new KhronosTextureContainer
  109161. * @param arrayBuffer contents of the KTX container file
  109162. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109163. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109164. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109165. */
  109166. constructor(
  109167. /** contents of the KTX container file */
  109168. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109169. /**
  109170. * Uploads KTX content to a Babylon Texture.
  109171. * It is assumed that the texture has already been created & is currently bound
  109172. * @hidden
  109173. */
  109174. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109175. private _upload2DCompressedLevels;
  109176. }
  109177. }
  109178. declare module BABYLON {
  109179. /**
  109180. * Implementation of the KTX Texture Loader.
  109181. * @hidden
  109182. */
  109183. export class _KTXTextureLoader implements IInternalTextureLoader {
  109184. /**
  109185. * Defines wether the loader supports cascade loading the different faces.
  109186. */
  109187. readonly supportCascades: boolean;
  109188. /**
  109189. * This returns if the loader support the current file information.
  109190. * @param extension defines the file extension of the file being loaded
  109191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109192. * @param fallback defines the fallback internal texture if any
  109193. * @param isBase64 defines whether the texture is encoded as a base64
  109194. * @param isBuffer defines whether the texture data are stored as a buffer
  109195. * @returns true if the loader can load the specified file
  109196. */
  109197. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109198. /**
  109199. * Transform the url before loading if required.
  109200. * @param rootUrl the url of the texture
  109201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109202. * @returns the transformed texture
  109203. */
  109204. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109205. /**
  109206. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109207. * @param rootUrl the url of the texture
  109208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109209. * @returns the fallback texture
  109210. */
  109211. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109212. /**
  109213. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109214. * @param data contains the texture data
  109215. * @param texture defines the BabylonJS internal texture
  109216. * @param createPolynomials will be true if polynomials have been requested
  109217. * @param onLoad defines the callback to trigger once the texture is ready
  109218. * @param onError defines the callback to trigger in case of error
  109219. */
  109220. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109221. /**
  109222. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109223. * @param data contains the texture data
  109224. * @param texture defines the BabylonJS internal texture
  109225. * @param callback defines the method to call once ready to upload
  109226. */
  109227. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109228. }
  109229. }
  109230. declare module BABYLON {
  109231. /** @hidden */
  109232. export var _forceSceneHelpersToBundle: boolean;
  109233. interface Scene {
  109234. /**
  109235. * Creates a default light for the scene.
  109236. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109237. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109238. */
  109239. createDefaultLight(replace?: boolean): void;
  109240. /**
  109241. * Creates a default camera for the scene.
  109242. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109243. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109244. * @param replace has default false, when true replaces the active camera in the scene
  109245. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109246. */
  109247. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109248. /**
  109249. * Creates a default camera and a default light.
  109250. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109251. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109252. * @param replace has the default false, when true replaces the active camera/light in the scene
  109253. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109254. */
  109255. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109256. /**
  109257. * Creates a new sky box
  109258. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109259. * @param environmentTexture defines the texture to use as environment texture
  109260. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109261. * @param scale defines the overall scale of the skybox
  109262. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109263. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109264. * @returns a new mesh holding the sky box
  109265. */
  109266. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109267. /**
  109268. * Creates a new environment
  109269. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109270. * @param options defines the options you can use to configure the environment
  109271. * @returns the new EnvironmentHelper
  109272. */
  109273. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109274. /**
  109275. * Creates a new VREXperienceHelper
  109276. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109277. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109278. * @returns a new VREXperienceHelper
  109279. */
  109280. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109281. /**
  109282. * Creates a new XREXperienceHelper
  109283. * @see http://doc.babylonjs.com/how_to/webxr
  109284. * @returns a promise for a new XREXperienceHelper
  109285. */
  109286. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109287. }
  109288. }
  109289. declare module BABYLON {
  109290. /**
  109291. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109292. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109293. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109294. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109295. */
  109296. export class VideoDome extends TransformNode {
  109297. /**
  109298. * Define the video source as a Monoscopic panoramic 360 video.
  109299. */
  109300. static readonly MODE_MONOSCOPIC: number;
  109301. /**
  109302. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109303. */
  109304. static readonly MODE_TOPBOTTOM: number;
  109305. /**
  109306. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109307. */
  109308. static readonly MODE_SIDEBYSIDE: number;
  109309. private _useDirectMapping;
  109310. /**
  109311. * The video texture being displayed on the sphere
  109312. */
  109313. protected _videoTexture: VideoTexture;
  109314. /**
  109315. * Gets the video texture being displayed on the sphere
  109316. */
  109317. readonly videoTexture: VideoTexture;
  109318. /**
  109319. * The skybox material
  109320. */
  109321. protected _material: BackgroundMaterial;
  109322. /**
  109323. * The surface used for the skybox
  109324. */
  109325. protected _mesh: Mesh;
  109326. /**
  109327. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109328. * Also see the options.resolution property.
  109329. */
  109330. fovMultiplier: number;
  109331. private _videoMode;
  109332. /**
  109333. * Gets or set the current video mode for the video. It can be:
  109334. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109335. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109336. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109337. */
  109338. videoMode: number;
  109339. /**
  109340. * Oberserver used in Stereoscopic VR Mode.
  109341. */
  109342. private _onBeforeCameraRenderObserver;
  109343. /**
  109344. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109345. * @param name Element's name, child elements will append suffixes for their own names.
  109346. * @param urlsOrVideo defines the url(s) or the video element to use
  109347. * @param options An object containing optional or exposed sub element properties
  109348. */
  109349. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109350. resolution?: number;
  109351. clickToPlay?: boolean;
  109352. autoPlay?: boolean;
  109353. loop?: boolean;
  109354. size?: number;
  109355. poster?: string;
  109356. faceForward?: boolean;
  109357. useDirectMapping?: boolean;
  109358. }, scene: Scene);
  109359. private _changeVideoMode;
  109360. /**
  109361. * Releases resources associated with this node.
  109362. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109363. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109364. */
  109365. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109366. }
  109367. }
  109368. declare module BABYLON {
  109369. /**
  109370. * This class can be used to get instrumentation data from a Babylon engine
  109371. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109372. */
  109373. export class EngineInstrumentation implements IDisposable {
  109374. /**
  109375. * Define the instrumented engine.
  109376. */
  109377. engine: Engine;
  109378. private _captureGPUFrameTime;
  109379. private _gpuFrameTimeToken;
  109380. private _gpuFrameTime;
  109381. private _captureShaderCompilationTime;
  109382. private _shaderCompilationTime;
  109383. private _onBeginFrameObserver;
  109384. private _onEndFrameObserver;
  109385. private _onBeforeShaderCompilationObserver;
  109386. private _onAfterShaderCompilationObserver;
  109387. /**
  109388. * Gets the perf counter used for GPU frame time
  109389. */
  109390. readonly gpuFrameTimeCounter: PerfCounter;
  109391. /**
  109392. * Gets the GPU frame time capture status
  109393. */
  109394. /**
  109395. * Enable or disable the GPU frame time capture
  109396. */
  109397. captureGPUFrameTime: boolean;
  109398. /**
  109399. * Gets the perf counter used for shader compilation time
  109400. */
  109401. readonly shaderCompilationTimeCounter: PerfCounter;
  109402. /**
  109403. * Gets the shader compilation time capture status
  109404. */
  109405. /**
  109406. * Enable or disable the shader compilation time capture
  109407. */
  109408. captureShaderCompilationTime: boolean;
  109409. /**
  109410. * Instantiates a new engine instrumentation.
  109411. * This class can be used to get instrumentation data from a Babylon engine
  109412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109413. * @param engine Defines the engine to instrument
  109414. */
  109415. constructor(
  109416. /**
  109417. * Define the instrumented engine.
  109418. */
  109419. engine: Engine);
  109420. /**
  109421. * Dispose and release associated resources.
  109422. */
  109423. dispose(): void;
  109424. }
  109425. }
  109426. declare module BABYLON {
  109427. /**
  109428. * This class can be used to get instrumentation data from a Babylon engine
  109429. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109430. */
  109431. export class SceneInstrumentation implements IDisposable {
  109432. /**
  109433. * Defines the scene to instrument
  109434. */
  109435. scene: Scene;
  109436. private _captureActiveMeshesEvaluationTime;
  109437. private _activeMeshesEvaluationTime;
  109438. private _captureRenderTargetsRenderTime;
  109439. private _renderTargetsRenderTime;
  109440. private _captureFrameTime;
  109441. private _frameTime;
  109442. private _captureRenderTime;
  109443. private _renderTime;
  109444. private _captureInterFrameTime;
  109445. private _interFrameTime;
  109446. private _captureParticlesRenderTime;
  109447. private _particlesRenderTime;
  109448. private _captureSpritesRenderTime;
  109449. private _spritesRenderTime;
  109450. private _capturePhysicsTime;
  109451. private _physicsTime;
  109452. private _captureAnimationsTime;
  109453. private _animationsTime;
  109454. private _captureCameraRenderTime;
  109455. private _cameraRenderTime;
  109456. private _onBeforeActiveMeshesEvaluationObserver;
  109457. private _onAfterActiveMeshesEvaluationObserver;
  109458. private _onBeforeRenderTargetsRenderObserver;
  109459. private _onAfterRenderTargetsRenderObserver;
  109460. private _onAfterRenderObserver;
  109461. private _onBeforeDrawPhaseObserver;
  109462. private _onAfterDrawPhaseObserver;
  109463. private _onBeforeAnimationsObserver;
  109464. private _onBeforeParticlesRenderingObserver;
  109465. private _onAfterParticlesRenderingObserver;
  109466. private _onBeforeSpritesRenderingObserver;
  109467. private _onAfterSpritesRenderingObserver;
  109468. private _onBeforePhysicsObserver;
  109469. private _onAfterPhysicsObserver;
  109470. private _onAfterAnimationsObserver;
  109471. private _onBeforeCameraRenderObserver;
  109472. private _onAfterCameraRenderObserver;
  109473. /**
  109474. * Gets the perf counter used for active meshes evaluation time
  109475. */
  109476. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109477. /**
  109478. * Gets the active meshes evaluation time capture status
  109479. */
  109480. /**
  109481. * Enable or disable the active meshes evaluation time capture
  109482. */
  109483. captureActiveMeshesEvaluationTime: boolean;
  109484. /**
  109485. * Gets the perf counter used for render targets render time
  109486. */
  109487. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109488. /**
  109489. * Gets the render targets render time capture status
  109490. */
  109491. /**
  109492. * Enable or disable the render targets render time capture
  109493. */
  109494. captureRenderTargetsRenderTime: boolean;
  109495. /**
  109496. * Gets the perf counter used for particles render time
  109497. */
  109498. readonly particlesRenderTimeCounter: PerfCounter;
  109499. /**
  109500. * Gets the particles render time capture status
  109501. */
  109502. /**
  109503. * Enable or disable the particles render time capture
  109504. */
  109505. captureParticlesRenderTime: boolean;
  109506. /**
  109507. * Gets the perf counter used for sprites render time
  109508. */
  109509. readonly spritesRenderTimeCounter: PerfCounter;
  109510. /**
  109511. * Gets the sprites render time capture status
  109512. */
  109513. /**
  109514. * Enable or disable the sprites render time capture
  109515. */
  109516. captureSpritesRenderTime: boolean;
  109517. /**
  109518. * Gets the perf counter used for physics time
  109519. */
  109520. readonly physicsTimeCounter: PerfCounter;
  109521. /**
  109522. * Gets the physics time capture status
  109523. */
  109524. /**
  109525. * Enable or disable the physics time capture
  109526. */
  109527. capturePhysicsTime: boolean;
  109528. /**
  109529. * Gets the perf counter used for animations time
  109530. */
  109531. readonly animationsTimeCounter: PerfCounter;
  109532. /**
  109533. * Gets the animations time capture status
  109534. */
  109535. /**
  109536. * Enable or disable the animations time capture
  109537. */
  109538. captureAnimationsTime: boolean;
  109539. /**
  109540. * Gets the perf counter used for frame time capture
  109541. */
  109542. readonly frameTimeCounter: PerfCounter;
  109543. /**
  109544. * Gets the frame time capture status
  109545. */
  109546. /**
  109547. * Enable or disable the frame time capture
  109548. */
  109549. captureFrameTime: boolean;
  109550. /**
  109551. * Gets the perf counter used for inter-frames time capture
  109552. */
  109553. readonly interFrameTimeCounter: PerfCounter;
  109554. /**
  109555. * Gets the inter-frames time capture status
  109556. */
  109557. /**
  109558. * Enable or disable the inter-frames time capture
  109559. */
  109560. captureInterFrameTime: boolean;
  109561. /**
  109562. * Gets the perf counter used for render time capture
  109563. */
  109564. readonly renderTimeCounter: PerfCounter;
  109565. /**
  109566. * Gets the render time capture status
  109567. */
  109568. /**
  109569. * Enable or disable the render time capture
  109570. */
  109571. captureRenderTime: boolean;
  109572. /**
  109573. * Gets the perf counter used for camera render time capture
  109574. */
  109575. readonly cameraRenderTimeCounter: PerfCounter;
  109576. /**
  109577. * Gets the camera render time capture status
  109578. */
  109579. /**
  109580. * Enable or disable the camera render time capture
  109581. */
  109582. captureCameraRenderTime: boolean;
  109583. /**
  109584. * Gets the perf counter used for draw calls
  109585. */
  109586. readonly drawCallsCounter: PerfCounter;
  109587. /**
  109588. * Instantiates a new scene instrumentation.
  109589. * This class can be used to get instrumentation data from a Babylon engine
  109590. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109591. * @param scene Defines the scene to instrument
  109592. */
  109593. constructor(
  109594. /**
  109595. * Defines the scene to instrument
  109596. */
  109597. scene: Scene);
  109598. /**
  109599. * Dispose and release associated resources.
  109600. */
  109601. dispose(): void;
  109602. }
  109603. }
  109604. declare module BABYLON {
  109605. /** @hidden */
  109606. export var glowMapGenerationPixelShader: {
  109607. name: string;
  109608. shader: string;
  109609. };
  109610. }
  109611. declare module BABYLON {
  109612. /** @hidden */
  109613. export var glowMapGenerationVertexShader: {
  109614. name: string;
  109615. shader: string;
  109616. };
  109617. }
  109618. declare module BABYLON {
  109619. /**
  109620. * Effect layer options. This helps customizing the behaviour
  109621. * of the effect layer.
  109622. */
  109623. export interface IEffectLayerOptions {
  109624. /**
  109625. * Multiplication factor apply to the canvas size to compute the render target size
  109626. * used to generated the objects (the smaller the faster).
  109627. */
  109628. mainTextureRatio: number;
  109629. /**
  109630. * Enforces a fixed size texture to ensure effect stability across devices.
  109631. */
  109632. mainTextureFixedSize?: number;
  109633. /**
  109634. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109635. */
  109636. alphaBlendingMode: number;
  109637. /**
  109638. * The camera attached to the layer.
  109639. */
  109640. camera: Nullable<Camera>;
  109641. /**
  109642. * The rendering group to draw the layer in.
  109643. */
  109644. renderingGroupId: number;
  109645. }
  109646. /**
  109647. * The effect layer Helps adding post process effect blended with the main pass.
  109648. *
  109649. * This can be for instance use to generate glow or higlight effects on the scene.
  109650. *
  109651. * The effect layer class can not be used directly and is intented to inherited from to be
  109652. * customized per effects.
  109653. */
  109654. export abstract class EffectLayer {
  109655. private _vertexBuffers;
  109656. private _indexBuffer;
  109657. private _cachedDefines;
  109658. private _effectLayerMapGenerationEffect;
  109659. private _effectLayerOptions;
  109660. private _mergeEffect;
  109661. protected _scene: Scene;
  109662. protected _engine: Engine;
  109663. protected _maxSize: number;
  109664. protected _mainTextureDesiredSize: ISize;
  109665. protected _mainTexture: RenderTargetTexture;
  109666. protected _shouldRender: boolean;
  109667. protected _postProcesses: PostProcess[];
  109668. protected _textures: BaseTexture[];
  109669. protected _emissiveTextureAndColor: {
  109670. texture: Nullable<BaseTexture>;
  109671. color: Color4;
  109672. };
  109673. /**
  109674. * The name of the layer
  109675. */
  109676. name: string;
  109677. /**
  109678. * The clear color of the texture used to generate the glow map.
  109679. */
  109680. neutralColor: Color4;
  109681. /**
  109682. * Specifies wether the highlight layer is enabled or not.
  109683. */
  109684. isEnabled: boolean;
  109685. /**
  109686. * Gets the camera attached to the layer.
  109687. */
  109688. readonly camera: Nullable<Camera>;
  109689. /**
  109690. * Gets the rendering group id the layer should render in.
  109691. */
  109692. readonly renderingGroupId: number;
  109693. /**
  109694. * An event triggered when the effect layer has been disposed.
  109695. */
  109696. onDisposeObservable: Observable<EffectLayer>;
  109697. /**
  109698. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109699. */
  109700. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109701. /**
  109702. * An event triggered when the generated texture is being merged in the scene.
  109703. */
  109704. onBeforeComposeObservable: Observable<EffectLayer>;
  109705. /**
  109706. * An event triggered when the generated texture has been merged in the scene.
  109707. */
  109708. onAfterComposeObservable: Observable<EffectLayer>;
  109709. /**
  109710. * An event triggered when the efffect layer changes its size.
  109711. */
  109712. onSizeChangedObservable: Observable<EffectLayer>;
  109713. /** @hidden */
  109714. static _SceneComponentInitialization: (scene: Scene) => void;
  109715. /**
  109716. * Instantiates a new effect Layer and references it in the scene.
  109717. * @param name The name of the layer
  109718. * @param scene The scene to use the layer in
  109719. */
  109720. constructor(
  109721. /** The Friendly of the effect in the scene */
  109722. name: string, scene: Scene);
  109723. /**
  109724. * Get the effect name of the layer.
  109725. * @return The effect name
  109726. */
  109727. abstract getEffectName(): string;
  109728. /**
  109729. * Checks for the readiness of the element composing the layer.
  109730. * @param subMesh the mesh to check for
  109731. * @param useInstances specify wether or not to use instances to render the mesh
  109732. * @return true if ready otherwise, false
  109733. */
  109734. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109735. /**
  109736. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109737. * @returns true if the effect requires stencil during the main canvas render pass.
  109738. */
  109739. abstract needStencil(): boolean;
  109740. /**
  109741. * Create the merge effect. This is the shader use to blit the information back
  109742. * to the main canvas at the end of the scene rendering.
  109743. * @returns The effect containing the shader used to merge the effect on the main canvas
  109744. */
  109745. protected abstract _createMergeEffect(): Effect;
  109746. /**
  109747. * Creates the render target textures and post processes used in the effect layer.
  109748. */
  109749. protected abstract _createTextureAndPostProcesses(): void;
  109750. /**
  109751. * Implementation specific of rendering the generating effect on the main canvas.
  109752. * @param effect The effect used to render through
  109753. */
  109754. protected abstract _internalRender(effect: Effect): void;
  109755. /**
  109756. * Sets the required values for both the emissive texture and and the main color.
  109757. */
  109758. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109759. /**
  109760. * Free any resources and references associated to a mesh.
  109761. * Internal use
  109762. * @param mesh The mesh to free.
  109763. */
  109764. abstract _disposeMesh(mesh: Mesh): void;
  109765. /**
  109766. * Serializes this layer (Glow or Highlight for example)
  109767. * @returns a serialized layer object
  109768. */
  109769. abstract serialize?(): any;
  109770. /**
  109771. * Initializes the effect layer with the required options.
  109772. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109773. */
  109774. protected _init(options: Partial<IEffectLayerOptions>): void;
  109775. /**
  109776. * Generates the index buffer of the full screen quad blending to the main canvas.
  109777. */
  109778. private _generateIndexBuffer;
  109779. /**
  109780. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109781. */
  109782. private _generateVertexBuffer;
  109783. /**
  109784. * Sets the main texture desired size which is the closest power of two
  109785. * of the engine canvas size.
  109786. */
  109787. private _setMainTextureSize;
  109788. /**
  109789. * Creates the main texture for the effect layer.
  109790. */
  109791. protected _createMainTexture(): void;
  109792. /**
  109793. * Adds specific effects defines.
  109794. * @param defines The defines to add specifics to.
  109795. */
  109796. protected _addCustomEffectDefines(defines: string[]): void;
  109797. /**
  109798. * Checks for the readiness of the element composing the layer.
  109799. * @param subMesh the mesh to check for
  109800. * @param useInstances specify wether or not to use instances to render the mesh
  109801. * @param emissiveTexture the associated emissive texture used to generate the glow
  109802. * @return true if ready otherwise, false
  109803. */
  109804. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  109805. /**
  109806. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  109807. */
  109808. render(): void;
  109809. /**
  109810. * Determine if a given mesh will be used in the current effect.
  109811. * @param mesh mesh to test
  109812. * @returns true if the mesh will be used
  109813. */
  109814. hasMesh(mesh: AbstractMesh): boolean;
  109815. /**
  109816. * Returns true if the layer contains information to display, otherwise false.
  109817. * @returns true if the glow layer should be rendered
  109818. */
  109819. shouldRender(): boolean;
  109820. /**
  109821. * Returns true if the mesh should render, otherwise false.
  109822. * @param mesh The mesh to render
  109823. * @returns true if it should render otherwise false
  109824. */
  109825. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  109826. /**
  109827. * Returns true if the mesh can be rendered, otherwise false.
  109828. * @param mesh The mesh to render
  109829. * @param material The material used on the mesh
  109830. * @returns true if it can be rendered otherwise false
  109831. */
  109832. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109833. /**
  109834. * Returns true if the mesh should render, otherwise false.
  109835. * @param mesh The mesh to render
  109836. * @returns true if it should render otherwise false
  109837. */
  109838. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  109839. /**
  109840. * Renders the submesh passed in parameter to the generation map.
  109841. */
  109842. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  109843. /**
  109844. * Rebuild the required buffers.
  109845. * @hidden Internal use only.
  109846. */
  109847. _rebuild(): void;
  109848. /**
  109849. * Dispose only the render target textures and post process.
  109850. */
  109851. private _disposeTextureAndPostProcesses;
  109852. /**
  109853. * Dispose the highlight layer and free resources.
  109854. */
  109855. dispose(): void;
  109856. /**
  109857. * Gets the class name of the effect layer
  109858. * @returns the string with the class name of the effect layer
  109859. */
  109860. getClassName(): string;
  109861. /**
  109862. * Creates an effect layer from parsed effect layer data
  109863. * @param parsedEffectLayer defines effect layer data
  109864. * @param scene defines the current scene
  109865. * @param rootUrl defines the root URL containing the effect layer information
  109866. * @returns a parsed effect Layer
  109867. */
  109868. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  109869. }
  109870. }
  109871. declare module BABYLON {
  109872. interface AbstractScene {
  109873. /**
  109874. * The list of effect layers (highlights/glow) added to the scene
  109875. * @see http://doc.babylonjs.com/how_to/highlight_layer
  109876. * @see http://doc.babylonjs.com/how_to/glow_layer
  109877. */
  109878. effectLayers: Array<EffectLayer>;
  109879. /**
  109880. * Removes the given effect layer from this scene.
  109881. * @param toRemove defines the effect layer to remove
  109882. * @returns the index of the removed effect layer
  109883. */
  109884. removeEffectLayer(toRemove: EffectLayer): number;
  109885. /**
  109886. * Adds the given effect layer to this scene
  109887. * @param newEffectLayer defines the effect layer to add
  109888. */
  109889. addEffectLayer(newEffectLayer: EffectLayer): void;
  109890. }
  109891. /**
  109892. * Defines the layer scene component responsible to manage any effect layers
  109893. * in a given scene.
  109894. */
  109895. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  109896. /**
  109897. * The component name helpfull to identify the component in the list of scene components.
  109898. */
  109899. readonly name: string;
  109900. /**
  109901. * The scene the component belongs to.
  109902. */
  109903. scene: Scene;
  109904. private _engine;
  109905. private _renderEffects;
  109906. private _needStencil;
  109907. private _previousStencilState;
  109908. /**
  109909. * Creates a new instance of the component for the given scene
  109910. * @param scene Defines the scene to register the component in
  109911. */
  109912. constructor(scene: Scene);
  109913. /**
  109914. * Registers the component in a given scene
  109915. */
  109916. register(): void;
  109917. /**
  109918. * Rebuilds the elements related to this component in case of
  109919. * context lost for instance.
  109920. */
  109921. rebuild(): void;
  109922. /**
  109923. * Serializes the component data to the specified json object
  109924. * @param serializationObject The object to serialize to
  109925. */
  109926. serialize(serializationObject: any): void;
  109927. /**
  109928. * Adds all the elements from the container to the scene
  109929. * @param container the container holding the elements
  109930. */
  109931. addFromContainer(container: AbstractScene): void;
  109932. /**
  109933. * Removes all the elements in the container from the scene
  109934. * @param container contains the elements to remove
  109935. * @param dispose if the removed element should be disposed (default: false)
  109936. */
  109937. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109938. /**
  109939. * Disposes the component and the associated ressources.
  109940. */
  109941. dispose(): void;
  109942. private _isReadyForMesh;
  109943. private _renderMainTexture;
  109944. private _setStencil;
  109945. private _setStencilBack;
  109946. private _draw;
  109947. private _drawCamera;
  109948. private _drawRenderingGroup;
  109949. }
  109950. }
  109951. declare module BABYLON {
  109952. /** @hidden */
  109953. export var glowMapMergePixelShader: {
  109954. name: string;
  109955. shader: string;
  109956. };
  109957. }
  109958. declare module BABYLON {
  109959. /** @hidden */
  109960. export var glowMapMergeVertexShader: {
  109961. name: string;
  109962. shader: string;
  109963. };
  109964. }
  109965. declare module BABYLON {
  109966. interface AbstractScene {
  109967. /**
  109968. * Return a the first highlight layer of the scene with a given name.
  109969. * @param name The name of the highlight layer to look for.
  109970. * @return The highlight layer if found otherwise null.
  109971. */
  109972. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  109973. }
  109974. /**
  109975. * Glow layer options. This helps customizing the behaviour
  109976. * of the glow layer.
  109977. */
  109978. export interface IGlowLayerOptions {
  109979. /**
  109980. * Multiplication factor apply to the canvas size to compute the render target size
  109981. * used to generated the glowing objects (the smaller the faster).
  109982. */
  109983. mainTextureRatio: number;
  109984. /**
  109985. * Enforces a fixed size texture to ensure resize independant blur.
  109986. */
  109987. mainTextureFixedSize?: number;
  109988. /**
  109989. * How big is the kernel of the blur texture.
  109990. */
  109991. blurKernelSize: number;
  109992. /**
  109993. * The camera attached to the layer.
  109994. */
  109995. camera: Nullable<Camera>;
  109996. /**
  109997. * Enable MSAA by chosing the number of samples.
  109998. */
  109999. mainTextureSamples?: number;
  110000. /**
  110001. * The rendering group to draw the layer in.
  110002. */
  110003. renderingGroupId: number;
  110004. }
  110005. /**
  110006. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110007. *
  110008. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110009. * glowy meshes to your scene.
  110010. *
  110011. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110012. */
  110013. export class GlowLayer extends EffectLayer {
  110014. /**
  110015. * Effect Name of the layer.
  110016. */
  110017. static readonly EffectName: string;
  110018. /**
  110019. * The default blur kernel size used for the glow.
  110020. */
  110021. static DefaultBlurKernelSize: number;
  110022. /**
  110023. * The default texture size ratio used for the glow.
  110024. */
  110025. static DefaultTextureRatio: number;
  110026. /**
  110027. * Sets the kernel size of the blur.
  110028. */
  110029. /**
  110030. * Gets the kernel size of the blur.
  110031. */
  110032. blurKernelSize: number;
  110033. /**
  110034. * Sets the glow intensity.
  110035. */
  110036. /**
  110037. * Gets the glow intensity.
  110038. */
  110039. intensity: number;
  110040. private _options;
  110041. private _intensity;
  110042. private _horizontalBlurPostprocess1;
  110043. private _verticalBlurPostprocess1;
  110044. private _horizontalBlurPostprocess2;
  110045. private _verticalBlurPostprocess2;
  110046. private _blurTexture1;
  110047. private _blurTexture2;
  110048. private _postProcesses1;
  110049. private _postProcesses2;
  110050. private _includedOnlyMeshes;
  110051. private _excludedMeshes;
  110052. /**
  110053. * Callback used to let the user override the color selection on a per mesh basis
  110054. */
  110055. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110056. /**
  110057. * Callback used to let the user override the texture selection on a per mesh basis
  110058. */
  110059. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110060. /**
  110061. * Instantiates a new glow Layer and references it to the scene.
  110062. * @param name The name of the layer
  110063. * @param scene The scene to use the layer in
  110064. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110065. */
  110066. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110067. /**
  110068. * Get the effect name of the layer.
  110069. * @return The effect name
  110070. */
  110071. getEffectName(): string;
  110072. /**
  110073. * Create the merge effect. This is the shader use to blit the information back
  110074. * to the main canvas at the end of the scene rendering.
  110075. */
  110076. protected _createMergeEffect(): Effect;
  110077. /**
  110078. * Creates the render target textures and post processes used in the glow layer.
  110079. */
  110080. protected _createTextureAndPostProcesses(): void;
  110081. /**
  110082. * Checks for the readiness of the element composing the layer.
  110083. * @param subMesh the mesh to check for
  110084. * @param useInstances specify wether or not to use instances to render the mesh
  110085. * @param emissiveTexture the associated emissive texture used to generate the glow
  110086. * @return true if ready otherwise, false
  110087. */
  110088. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110089. /**
  110090. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110091. */
  110092. needStencil(): boolean;
  110093. /**
  110094. * Returns true if the mesh can be rendered, otherwise false.
  110095. * @param mesh The mesh to render
  110096. * @param material The material used on the mesh
  110097. * @returns true if it can be rendered otherwise false
  110098. */
  110099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110100. /**
  110101. * Implementation specific of rendering the generating effect on the main canvas.
  110102. * @param effect The effect used to render through
  110103. */
  110104. protected _internalRender(effect: Effect): void;
  110105. /**
  110106. * Sets the required values for both the emissive texture and and the main color.
  110107. */
  110108. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110109. /**
  110110. * Returns true if the mesh should render, otherwise false.
  110111. * @param mesh The mesh to render
  110112. * @returns true if it should render otherwise false
  110113. */
  110114. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110115. /**
  110116. * Adds specific effects defines.
  110117. * @param defines The defines to add specifics to.
  110118. */
  110119. protected _addCustomEffectDefines(defines: string[]): void;
  110120. /**
  110121. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110122. * @param mesh The mesh to exclude from the glow layer
  110123. */
  110124. addExcludedMesh(mesh: Mesh): void;
  110125. /**
  110126. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110127. * @param mesh The mesh to remove
  110128. */
  110129. removeExcludedMesh(mesh: Mesh): void;
  110130. /**
  110131. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110132. * @param mesh The mesh to include in the glow layer
  110133. */
  110134. addIncludedOnlyMesh(mesh: Mesh): void;
  110135. /**
  110136. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110137. * @param mesh The mesh to remove
  110138. */
  110139. removeIncludedOnlyMesh(mesh: Mesh): void;
  110140. /**
  110141. * Determine if a given mesh will be used in the glow layer
  110142. * @param mesh The mesh to test
  110143. * @returns true if the mesh will be highlighted by the current glow layer
  110144. */
  110145. hasMesh(mesh: AbstractMesh): boolean;
  110146. /**
  110147. * Free any resources and references associated to a mesh.
  110148. * Internal use
  110149. * @param mesh The mesh to free.
  110150. * @hidden
  110151. */
  110152. _disposeMesh(mesh: Mesh): void;
  110153. /**
  110154. * Gets the class name of the effect layer
  110155. * @returns the string with the class name of the effect layer
  110156. */
  110157. getClassName(): string;
  110158. /**
  110159. * Serializes this glow layer
  110160. * @returns a serialized glow layer object
  110161. */
  110162. serialize(): any;
  110163. /**
  110164. * Creates a Glow Layer from parsed glow layer data
  110165. * @param parsedGlowLayer defines glow layer data
  110166. * @param scene defines the current scene
  110167. * @param rootUrl defines the root URL containing the glow layer information
  110168. * @returns a parsed Glow Layer
  110169. */
  110170. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110171. }
  110172. }
  110173. declare module BABYLON {
  110174. /** @hidden */
  110175. export var glowBlurPostProcessPixelShader: {
  110176. name: string;
  110177. shader: string;
  110178. };
  110179. }
  110180. declare module BABYLON {
  110181. interface AbstractScene {
  110182. /**
  110183. * Return a the first highlight layer of the scene with a given name.
  110184. * @param name The name of the highlight layer to look for.
  110185. * @return The highlight layer if found otherwise null.
  110186. */
  110187. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110188. }
  110189. /**
  110190. * Highlight layer options. This helps customizing the behaviour
  110191. * of the highlight layer.
  110192. */
  110193. export interface IHighlightLayerOptions {
  110194. /**
  110195. * Multiplication factor apply to the canvas size to compute the render target size
  110196. * used to generated the glowing objects (the smaller the faster).
  110197. */
  110198. mainTextureRatio: number;
  110199. /**
  110200. * Enforces a fixed size texture to ensure resize independant blur.
  110201. */
  110202. mainTextureFixedSize?: number;
  110203. /**
  110204. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110205. * of the picture to blur (the smaller the faster).
  110206. */
  110207. blurTextureSizeRatio: number;
  110208. /**
  110209. * How big in texel of the blur texture is the vertical blur.
  110210. */
  110211. blurVerticalSize: number;
  110212. /**
  110213. * How big in texel of the blur texture is the horizontal blur.
  110214. */
  110215. blurHorizontalSize: number;
  110216. /**
  110217. * Alpha blending mode used to apply the blur. Default is combine.
  110218. */
  110219. alphaBlendingMode: number;
  110220. /**
  110221. * The camera attached to the layer.
  110222. */
  110223. camera: Nullable<Camera>;
  110224. /**
  110225. * Should we display highlight as a solid stroke?
  110226. */
  110227. isStroke?: boolean;
  110228. /**
  110229. * The rendering group to draw the layer in.
  110230. */
  110231. renderingGroupId: number;
  110232. }
  110233. /**
  110234. * The highlight layer Helps adding a glow effect around a mesh.
  110235. *
  110236. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110237. * glowy meshes to your scene.
  110238. *
  110239. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110240. */
  110241. export class HighlightLayer extends EffectLayer {
  110242. name: string;
  110243. /**
  110244. * Effect Name of the highlight layer.
  110245. */
  110246. static readonly EffectName: string;
  110247. /**
  110248. * The neutral color used during the preparation of the glow effect.
  110249. * This is black by default as the blend operation is a blend operation.
  110250. */
  110251. static NeutralColor: Color4;
  110252. /**
  110253. * Stencil value used for glowing meshes.
  110254. */
  110255. static GlowingMeshStencilReference: number;
  110256. /**
  110257. * Stencil value used for the other meshes in the scene.
  110258. */
  110259. static NormalMeshStencilReference: number;
  110260. /**
  110261. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110262. */
  110263. innerGlow: boolean;
  110264. /**
  110265. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110266. */
  110267. outerGlow: boolean;
  110268. /**
  110269. * Specifies the horizontal size of the blur.
  110270. */
  110271. /**
  110272. * Gets the horizontal size of the blur.
  110273. */
  110274. blurHorizontalSize: number;
  110275. /**
  110276. * Specifies the vertical size of the blur.
  110277. */
  110278. /**
  110279. * Gets the vertical size of the blur.
  110280. */
  110281. blurVerticalSize: number;
  110282. /**
  110283. * An event triggered when the highlight layer is being blurred.
  110284. */
  110285. onBeforeBlurObservable: Observable<HighlightLayer>;
  110286. /**
  110287. * An event triggered when the highlight layer has been blurred.
  110288. */
  110289. onAfterBlurObservable: Observable<HighlightLayer>;
  110290. private _instanceGlowingMeshStencilReference;
  110291. private _options;
  110292. private _downSamplePostprocess;
  110293. private _horizontalBlurPostprocess;
  110294. private _verticalBlurPostprocess;
  110295. private _blurTexture;
  110296. private _meshes;
  110297. private _excludedMeshes;
  110298. /**
  110299. * Instantiates a new highlight Layer and references it to the scene..
  110300. * @param name The name of the layer
  110301. * @param scene The scene to use the layer in
  110302. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110303. */
  110304. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110305. /**
  110306. * Get the effect name of the layer.
  110307. * @return The effect name
  110308. */
  110309. getEffectName(): string;
  110310. /**
  110311. * Create the merge effect. This is the shader use to blit the information back
  110312. * to the main canvas at the end of the scene rendering.
  110313. */
  110314. protected _createMergeEffect(): Effect;
  110315. /**
  110316. * Creates the render target textures and post processes used in the highlight layer.
  110317. */
  110318. protected _createTextureAndPostProcesses(): void;
  110319. /**
  110320. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110321. */
  110322. needStencil(): boolean;
  110323. /**
  110324. * Checks for the readiness of the element composing the layer.
  110325. * @param subMesh the mesh to check for
  110326. * @param useInstances specify wether or not to use instances to render the mesh
  110327. * @param emissiveTexture the associated emissive texture used to generate the glow
  110328. * @return true if ready otherwise, false
  110329. */
  110330. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110331. /**
  110332. * Implementation specific of rendering the generating effect on the main canvas.
  110333. * @param effect The effect used to render through
  110334. */
  110335. protected _internalRender(effect: Effect): void;
  110336. /**
  110337. * Returns true if the layer contains information to display, otherwise false.
  110338. */
  110339. shouldRender(): boolean;
  110340. /**
  110341. * Returns true if the mesh should render, otherwise false.
  110342. * @param mesh The mesh to render
  110343. * @returns true if it should render otherwise false
  110344. */
  110345. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110346. /**
  110347. * Sets the required values for both the emissive texture and and the main color.
  110348. */
  110349. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110350. /**
  110351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110352. * @param mesh The mesh to exclude from the highlight layer
  110353. */
  110354. addExcludedMesh(mesh: Mesh): void;
  110355. /**
  110356. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110357. * @param mesh The mesh to highlight
  110358. */
  110359. removeExcludedMesh(mesh: Mesh): void;
  110360. /**
  110361. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110362. * @param mesh mesh to test
  110363. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110364. */
  110365. hasMesh(mesh: AbstractMesh): boolean;
  110366. /**
  110367. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110368. * @param mesh The mesh to highlight
  110369. * @param color The color of the highlight
  110370. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110371. */
  110372. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110373. /**
  110374. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110375. * @param mesh The mesh to highlight
  110376. */
  110377. removeMesh(mesh: Mesh): void;
  110378. /**
  110379. * Force the stencil to the normal expected value for none glowing parts
  110380. */
  110381. private _defaultStencilReference;
  110382. /**
  110383. * Free any resources and references associated to a mesh.
  110384. * Internal use
  110385. * @param mesh The mesh to free.
  110386. * @hidden
  110387. */
  110388. _disposeMesh(mesh: Mesh): void;
  110389. /**
  110390. * Dispose the highlight layer and free resources.
  110391. */
  110392. dispose(): void;
  110393. /**
  110394. * Gets the class name of the effect layer
  110395. * @returns the string with the class name of the effect layer
  110396. */
  110397. getClassName(): string;
  110398. /**
  110399. * Serializes this Highlight layer
  110400. * @returns a serialized Highlight layer object
  110401. */
  110402. serialize(): any;
  110403. /**
  110404. * Creates a Highlight layer from parsed Highlight layer data
  110405. * @param parsedHightlightLayer defines the Highlight layer data
  110406. * @param scene defines the current scene
  110407. * @param rootUrl defines the root URL containing the Highlight layer information
  110408. * @returns a parsed Highlight layer
  110409. */
  110410. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110411. }
  110412. }
  110413. declare module BABYLON {
  110414. interface AbstractScene {
  110415. /**
  110416. * The list of layers (background and foreground) of the scene
  110417. */
  110418. layers: Array<Layer>;
  110419. }
  110420. /**
  110421. * Defines the layer scene component responsible to manage any layers
  110422. * in a given scene.
  110423. */
  110424. export class LayerSceneComponent implements ISceneComponent {
  110425. /**
  110426. * The component name helpfull to identify the component in the list of scene components.
  110427. */
  110428. readonly name: string;
  110429. /**
  110430. * The scene the component belongs to.
  110431. */
  110432. scene: Scene;
  110433. private _engine;
  110434. /**
  110435. * Creates a new instance of the component for the given scene
  110436. * @param scene Defines the scene to register the component in
  110437. */
  110438. constructor(scene: Scene);
  110439. /**
  110440. * Registers the component in a given scene
  110441. */
  110442. register(): void;
  110443. /**
  110444. * Rebuilds the elements related to this component in case of
  110445. * context lost for instance.
  110446. */
  110447. rebuild(): void;
  110448. /**
  110449. * Disposes the component and the associated ressources.
  110450. */
  110451. dispose(): void;
  110452. private _draw;
  110453. private _drawCameraPredicate;
  110454. private _drawCameraBackground;
  110455. private _drawCameraForeground;
  110456. private _drawRenderTargetPredicate;
  110457. private _drawRenderTargetBackground;
  110458. private _drawRenderTargetForeground;
  110459. /**
  110460. * Adds all the elements from the container to the scene
  110461. * @param container the container holding the elements
  110462. */
  110463. addFromContainer(container: AbstractScene): void;
  110464. /**
  110465. * Removes all the elements in the container from the scene
  110466. * @param container contains the elements to remove
  110467. * @param dispose if the removed element should be disposed (default: false)
  110468. */
  110469. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110470. }
  110471. }
  110472. declare module BABYLON {
  110473. /** @hidden */
  110474. export var layerPixelShader: {
  110475. name: string;
  110476. shader: string;
  110477. };
  110478. }
  110479. declare module BABYLON {
  110480. /** @hidden */
  110481. export var layerVertexShader: {
  110482. name: string;
  110483. shader: string;
  110484. };
  110485. }
  110486. declare module BABYLON {
  110487. /**
  110488. * This represents a full screen 2d layer.
  110489. * This can be useful to display a picture in the background of your scene for instance.
  110490. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110491. */
  110492. export class Layer {
  110493. /**
  110494. * Define the name of the layer.
  110495. */
  110496. name: string;
  110497. /**
  110498. * Define the texture the layer should display.
  110499. */
  110500. texture: Nullable<Texture>;
  110501. /**
  110502. * Is the layer in background or foreground.
  110503. */
  110504. isBackground: boolean;
  110505. /**
  110506. * Define the color of the layer (instead of texture).
  110507. */
  110508. color: Color4;
  110509. /**
  110510. * Define the scale of the layer in order to zoom in out of the texture.
  110511. */
  110512. scale: Vector2;
  110513. /**
  110514. * Define an offset for the layer in order to shift the texture.
  110515. */
  110516. offset: Vector2;
  110517. /**
  110518. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110519. */
  110520. alphaBlendingMode: number;
  110521. /**
  110522. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110523. * Alpha test will not mix with the background color in case of transparency.
  110524. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110525. */
  110526. alphaTest: boolean;
  110527. /**
  110528. * Define a mask to restrict the layer to only some of the scene cameras.
  110529. */
  110530. layerMask: number;
  110531. /**
  110532. * Define the list of render target the layer is visible into.
  110533. */
  110534. renderTargetTextures: RenderTargetTexture[];
  110535. /**
  110536. * Define if the layer is only used in renderTarget or if it also
  110537. * renders in the main frame buffer of the canvas.
  110538. */
  110539. renderOnlyInRenderTargetTextures: boolean;
  110540. private _scene;
  110541. private _vertexBuffers;
  110542. private _indexBuffer;
  110543. private _effect;
  110544. private _alphaTestEffect;
  110545. /**
  110546. * An event triggered when the layer is disposed.
  110547. */
  110548. onDisposeObservable: Observable<Layer>;
  110549. private _onDisposeObserver;
  110550. /**
  110551. * Back compatibility with callback before the onDisposeObservable existed.
  110552. * The set callback will be triggered when the layer has been disposed.
  110553. */
  110554. onDispose: () => void;
  110555. /**
  110556. * An event triggered before rendering the scene
  110557. */
  110558. onBeforeRenderObservable: Observable<Layer>;
  110559. private _onBeforeRenderObserver;
  110560. /**
  110561. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110562. * The set callback will be triggered just before rendering the layer.
  110563. */
  110564. onBeforeRender: () => void;
  110565. /**
  110566. * An event triggered after rendering the scene
  110567. */
  110568. onAfterRenderObservable: Observable<Layer>;
  110569. private _onAfterRenderObserver;
  110570. /**
  110571. * Back compatibility with callback before the onAfterRenderObservable existed.
  110572. * The set callback will be triggered just after rendering the layer.
  110573. */
  110574. onAfterRender: () => void;
  110575. /**
  110576. * Instantiates a new layer.
  110577. * This represents a full screen 2d layer.
  110578. * This can be useful to display a picture in the background of your scene for instance.
  110579. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110580. * @param name Define the name of the layer in the scene
  110581. * @param imgUrl Define the url of the texture to display in the layer
  110582. * @param scene Define the scene the layer belongs to
  110583. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110584. * @param color Defines a color for the layer
  110585. */
  110586. constructor(
  110587. /**
  110588. * Define the name of the layer.
  110589. */
  110590. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110591. private _createIndexBuffer;
  110592. /** @hidden */
  110593. _rebuild(): void;
  110594. /**
  110595. * Renders the layer in the scene.
  110596. */
  110597. render(): void;
  110598. /**
  110599. * Disposes and releases the associated ressources.
  110600. */
  110601. dispose(): void;
  110602. }
  110603. }
  110604. declare module BABYLON {
  110605. /** @hidden */
  110606. export var lensFlarePixelShader: {
  110607. name: string;
  110608. shader: string;
  110609. };
  110610. }
  110611. declare module BABYLON {
  110612. /** @hidden */
  110613. export var lensFlareVertexShader: {
  110614. name: string;
  110615. shader: string;
  110616. };
  110617. }
  110618. declare module BABYLON {
  110619. /**
  110620. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110621. * It is usually composed of several `lensFlare`.
  110622. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110623. */
  110624. export class LensFlareSystem {
  110625. /**
  110626. * Define the name of the lens flare system
  110627. */
  110628. name: string;
  110629. /**
  110630. * List of lens flares used in this system.
  110631. */
  110632. lensFlares: LensFlare[];
  110633. /**
  110634. * Define a limit from the border the lens flare can be visible.
  110635. */
  110636. borderLimit: number;
  110637. /**
  110638. * Define a viewport border we do not want to see the lens flare in.
  110639. */
  110640. viewportBorder: number;
  110641. /**
  110642. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110643. */
  110644. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110645. /**
  110646. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110647. */
  110648. layerMask: number;
  110649. /**
  110650. * Define the id of the lens flare system in the scene.
  110651. * (equal to name by default)
  110652. */
  110653. id: string;
  110654. private _scene;
  110655. private _emitter;
  110656. private _vertexBuffers;
  110657. private _indexBuffer;
  110658. private _effect;
  110659. private _positionX;
  110660. private _positionY;
  110661. private _isEnabled;
  110662. /** @hidden */
  110663. static _SceneComponentInitialization: (scene: Scene) => void;
  110664. /**
  110665. * Instantiates a lens flare system.
  110666. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110667. * It is usually composed of several `lensFlare`.
  110668. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110669. * @param name Define the name of the lens flare system in the scene
  110670. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110671. * @param scene Define the scene the lens flare system belongs to
  110672. */
  110673. constructor(
  110674. /**
  110675. * Define the name of the lens flare system
  110676. */
  110677. name: string, emitter: any, scene: Scene);
  110678. /**
  110679. * Define if the lens flare system is enabled.
  110680. */
  110681. isEnabled: boolean;
  110682. /**
  110683. * Get the scene the effects belongs to.
  110684. * @returns the scene holding the lens flare system
  110685. */
  110686. getScene(): Scene;
  110687. /**
  110688. * Get the emitter of the lens flare system.
  110689. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110690. * @returns the emitter of the lens flare system
  110691. */
  110692. getEmitter(): any;
  110693. /**
  110694. * Set the emitter of the lens flare system.
  110695. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110696. * @param newEmitter Define the new emitter of the system
  110697. */
  110698. setEmitter(newEmitter: any): void;
  110699. /**
  110700. * Get the lens flare system emitter position.
  110701. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110702. * @returns the position
  110703. */
  110704. getEmitterPosition(): Vector3;
  110705. /**
  110706. * @hidden
  110707. */
  110708. computeEffectivePosition(globalViewport: Viewport): boolean;
  110709. /** @hidden */
  110710. _isVisible(): boolean;
  110711. /**
  110712. * @hidden
  110713. */
  110714. render(): boolean;
  110715. /**
  110716. * Dispose and release the lens flare with its associated resources.
  110717. */
  110718. dispose(): void;
  110719. /**
  110720. * Parse a lens flare system from a JSON repressentation
  110721. * @param parsedLensFlareSystem Define the JSON to parse
  110722. * @param scene Define the scene the parsed system should be instantiated in
  110723. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110724. * @returns the parsed system
  110725. */
  110726. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110727. /**
  110728. * Serialize the current Lens Flare System into a JSON representation.
  110729. * @returns the serialized JSON
  110730. */
  110731. serialize(): any;
  110732. }
  110733. }
  110734. declare module BABYLON {
  110735. /**
  110736. * This represents one of the lens effect in a `lensFlareSystem`.
  110737. * It controls one of the indiviual texture used in the effect.
  110738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110739. */
  110740. export class LensFlare {
  110741. /**
  110742. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110743. */
  110744. size: number;
  110745. /**
  110746. * 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.
  110747. */
  110748. position: number;
  110749. /**
  110750. * Define the lens color.
  110751. */
  110752. color: Color3;
  110753. /**
  110754. * Define the lens texture.
  110755. */
  110756. texture: Nullable<Texture>;
  110757. /**
  110758. * Define the alpha mode to render this particular lens.
  110759. */
  110760. alphaMode: number;
  110761. private _system;
  110762. /**
  110763. * Creates a new Lens Flare.
  110764. * This represents one of the lens effect in a `lensFlareSystem`.
  110765. * It controls one of the indiviual texture used in the effect.
  110766. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110767. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110768. * @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.
  110769. * @param color Define the lens color
  110770. * @param imgUrl Define the lens texture url
  110771. * @param system Define the `lensFlareSystem` this flare is part of
  110772. * @returns The newly created Lens Flare
  110773. */
  110774. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110775. /**
  110776. * Instantiates a new Lens Flare.
  110777. * This represents one of the lens effect in a `lensFlareSystem`.
  110778. * It controls one of the indiviual texture used in the effect.
  110779. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110780. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110781. * @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.
  110782. * @param color Define the lens color
  110783. * @param imgUrl Define the lens texture url
  110784. * @param system Define the `lensFlareSystem` this flare is part of
  110785. */
  110786. constructor(
  110787. /**
  110788. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110789. */
  110790. size: number,
  110791. /**
  110792. * 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.
  110793. */
  110794. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  110795. /**
  110796. * Dispose and release the lens flare with its associated resources.
  110797. */
  110798. dispose(): void;
  110799. }
  110800. }
  110801. declare module BABYLON {
  110802. interface AbstractScene {
  110803. /**
  110804. * The list of lens flare system added to the scene
  110805. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110806. */
  110807. lensFlareSystems: Array<LensFlareSystem>;
  110808. /**
  110809. * Removes the given lens flare system from this scene.
  110810. * @param toRemove The lens flare system to remove
  110811. * @returns The index of the removed lens flare system
  110812. */
  110813. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  110814. /**
  110815. * Adds the given lens flare system to this scene
  110816. * @param newLensFlareSystem The lens flare system to add
  110817. */
  110818. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  110819. /**
  110820. * Gets a lens flare system using its name
  110821. * @param name defines the name to look for
  110822. * @returns the lens flare system or null if not found
  110823. */
  110824. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  110825. /**
  110826. * Gets a lens flare system using its id
  110827. * @param id defines the id to look for
  110828. * @returns the lens flare system or null if not found
  110829. */
  110830. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  110831. }
  110832. /**
  110833. * Defines the lens flare scene component responsible to manage any lens flares
  110834. * in a given scene.
  110835. */
  110836. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  110837. /**
  110838. * The component name helpfull to identify the component in the list of scene components.
  110839. */
  110840. readonly name: string;
  110841. /**
  110842. * The scene the component belongs to.
  110843. */
  110844. scene: Scene;
  110845. /**
  110846. * Creates a new instance of the component for the given scene
  110847. * @param scene Defines the scene to register the component in
  110848. */
  110849. constructor(scene: Scene);
  110850. /**
  110851. * Registers the component in a given scene
  110852. */
  110853. register(): void;
  110854. /**
  110855. * Rebuilds the elements related to this component in case of
  110856. * context lost for instance.
  110857. */
  110858. rebuild(): void;
  110859. /**
  110860. * Adds all the elements from the container to the scene
  110861. * @param container the container holding the elements
  110862. */
  110863. addFromContainer(container: AbstractScene): void;
  110864. /**
  110865. * Removes all the elements in the container from the scene
  110866. * @param container contains the elements to remove
  110867. * @param dispose if the removed element should be disposed (default: false)
  110868. */
  110869. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110870. /**
  110871. * Serializes the component data to the specified json object
  110872. * @param serializationObject The object to serialize to
  110873. */
  110874. serialize(serializationObject: any): void;
  110875. /**
  110876. * Disposes the component and the associated ressources.
  110877. */
  110878. dispose(): void;
  110879. private _draw;
  110880. }
  110881. }
  110882. declare module BABYLON {
  110883. /**
  110884. * Defines the shadow generator component responsible to manage any shadow generators
  110885. * in a given scene.
  110886. */
  110887. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  110888. /**
  110889. * The component name helpfull to identify the component in the list of scene components.
  110890. */
  110891. readonly name: string;
  110892. /**
  110893. * The scene the component belongs to.
  110894. */
  110895. scene: Scene;
  110896. /**
  110897. * Creates a new instance of the component for the given scene
  110898. * @param scene Defines the scene to register the component in
  110899. */
  110900. constructor(scene: Scene);
  110901. /**
  110902. * Registers the component in a given scene
  110903. */
  110904. register(): void;
  110905. /**
  110906. * Rebuilds the elements related to this component in case of
  110907. * context lost for instance.
  110908. */
  110909. rebuild(): void;
  110910. /**
  110911. * Serializes the component data to the specified json object
  110912. * @param serializationObject The object to serialize to
  110913. */
  110914. serialize(serializationObject: any): void;
  110915. /**
  110916. * Adds all the elements from the container to the scene
  110917. * @param container the container holding the elements
  110918. */
  110919. addFromContainer(container: AbstractScene): void;
  110920. /**
  110921. * Removes all the elements in the container from the scene
  110922. * @param container contains the elements to remove
  110923. * @param dispose if the removed element should be disposed (default: false)
  110924. */
  110925. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110926. /**
  110927. * Rebuilds the elements related to this component in case of
  110928. * context lost for instance.
  110929. */
  110930. dispose(): void;
  110931. private _gatherRenderTargets;
  110932. }
  110933. }
  110934. declare module BABYLON {
  110935. /**
  110936. * A point light is a light defined by an unique point in world space.
  110937. * The light is emitted in every direction from this point.
  110938. * A good example of a point light is a standard light bulb.
  110939. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110940. */
  110941. export class PointLight extends ShadowLight {
  110942. private _shadowAngle;
  110943. /**
  110944. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110945. * This specifies what angle the shadow will use to be created.
  110946. *
  110947. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110948. */
  110949. /**
  110950. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110951. * This specifies what angle the shadow will use to be created.
  110952. *
  110953. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110954. */
  110955. shadowAngle: number;
  110956. /**
  110957. * Gets the direction if it has been set.
  110958. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110959. */
  110960. /**
  110961. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110962. */
  110963. direction: Vector3;
  110964. /**
  110965. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  110966. * A PointLight emits the light in every direction.
  110967. * It can cast shadows.
  110968. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  110969. * ```javascript
  110970. * var pointLight = new PointLight("pl", camera.position, scene);
  110971. * ```
  110972. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110973. * @param name The light friendly name
  110974. * @param position The position of the point light in the scene
  110975. * @param scene The scene the lights belongs to
  110976. */
  110977. constructor(name: string, position: Vector3, scene: Scene);
  110978. /**
  110979. * Returns the string "PointLight"
  110980. * @returns the class name
  110981. */
  110982. getClassName(): string;
  110983. /**
  110984. * Returns the integer 0.
  110985. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110986. */
  110987. getTypeID(): number;
  110988. /**
  110989. * Specifies wether or not the shadowmap should be a cube texture.
  110990. * @returns true if the shadowmap needs to be a cube texture.
  110991. */
  110992. needCube(): boolean;
  110993. /**
  110994. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  110995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  110996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  110997. */
  110998. getShadowDirection(faceIndex?: number): Vector3;
  110999. /**
  111000. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111001. * - fov = PI / 2
  111002. * - aspect ratio : 1.0
  111003. * - z-near and far equal to the active camera minZ and maxZ.
  111004. * Returns the PointLight.
  111005. */
  111006. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111007. protected _buildUniformLayout(): void;
  111008. /**
  111009. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111010. * @param effect The effect to update
  111011. * @param lightIndex The index of the light in the effect to update
  111012. * @returns The point light
  111013. */
  111014. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111015. /**
  111016. * Prepares the list of defines specific to the light type.
  111017. * @param defines the list of defines
  111018. * @param lightIndex defines the index of the light for the effect
  111019. */
  111020. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111021. }
  111022. }
  111023. declare module BABYLON {
  111024. /**
  111025. * Header information of HDR texture files.
  111026. */
  111027. export interface HDRInfo {
  111028. /**
  111029. * The height of the texture in pixels.
  111030. */
  111031. height: number;
  111032. /**
  111033. * The width of the texture in pixels.
  111034. */
  111035. width: number;
  111036. /**
  111037. * The index of the beginning of the data in the binary file.
  111038. */
  111039. dataPosition: number;
  111040. }
  111041. /**
  111042. * This groups tools to convert HDR texture to native colors array.
  111043. */
  111044. export class HDRTools {
  111045. private static Ldexp;
  111046. private static Rgbe2float;
  111047. private static readStringLine;
  111048. /**
  111049. * Reads header information from an RGBE texture stored in a native array.
  111050. * More information on this format are available here:
  111051. * https://en.wikipedia.org/wiki/RGBE_image_format
  111052. *
  111053. * @param uint8array The binary file stored in native array.
  111054. * @return The header information.
  111055. */
  111056. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111057. /**
  111058. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111059. * This RGBE texture needs to store the information as a panorama.
  111060. *
  111061. * More information on this format are available here:
  111062. * https://en.wikipedia.org/wiki/RGBE_image_format
  111063. *
  111064. * @param buffer The binary file stored in an array buffer.
  111065. * @param size The expected size of the extracted cubemap.
  111066. * @return The Cube Map information.
  111067. */
  111068. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111069. /**
  111070. * Returns the pixels data extracted from an RGBE texture.
  111071. * This pixels will be stored left to right up to down in the R G B order in one array.
  111072. *
  111073. * More information on this format are available here:
  111074. * https://en.wikipedia.org/wiki/RGBE_image_format
  111075. *
  111076. * @param uint8array The binary file stored in an array buffer.
  111077. * @param hdrInfo The header information of the file.
  111078. * @return The pixels data in RGB right to left up to down order.
  111079. */
  111080. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111081. private static RGBE_ReadPixels_RLE;
  111082. }
  111083. }
  111084. declare module BABYLON {
  111085. /**
  111086. * This represents a texture coming from an HDR input.
  111087. *
  111088. * The only supported format is currently panorama picture stored in RGBE format.
  111089. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111090. */
  111091. export class HDRCubeTexture extends BaseTexture {
  111092. private static _facesMapping;
  111093. private _generateHarmonics;
  111094. private _noMipmap;
  111095. private _textureMatrix;
  111096. private _size;
  111097. private _onLoad;
  111098. private _onError;
  111099. /**
  111100. * The texture URL.
  111101. */
  111102. url: string;
  111103. /**
  111104. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111105. */
  111106. coordinatesMode: number;
  111107. protected _isBlocking: boolean;
  111108. /**
  111109. * Sets wether or not the texture is blocking during loading.
  111110. */
  111111. /**
  111112. * Gets wether or not the texture is blocking during loading.
  111113. */
  111114. isBlocking: boolean;
  111115. protected _rotationY: number;
  111116. /**
  111117. * Sets texture matrix rotation angle around Y axis in radians.
  111118. */
  111119. /**
  111120. * Gets texture matrix rotation angle around Y axis radians.
  111121. */
  111122. rotationY: number;
  111123. /**
  111124. * Gets or sets the center of the bounding box associated with the cube texture
  111125. * It must define where the camera used to render the texture was set
  111126. */
  111127. boundingBoxPosition: Vector3;
  111128. private _boundingBoxSize;
  111129. /**
  111130. * Gets or sets the size of the bounding box associated with the cube texture
  111131. * When defined, the cubemap will switch to local mode
  111132. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111133. * @example https://www.babylonjs-playground.com/#RNASML
  111134. */
  111135. boundingBoxSize: Vector3;
  111136. /**
  111137. * Instantiates an HDRTexture from the following parameters.
  111138. *
  111139. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111140. * @param scene The scene the texture will be used in
  111141. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111142. * @param noMipmap Forces to not generate the mipmap if true
  111143. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111144. * @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)
  111145. * @param reserved Reserved flag for internal use.
  111146. */
  111147. 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>);
  111148. /**
  111149. * Get the current class name of the texture useful for serialization or dynamic coding.
  111150. * @returns "HDRCubeTexture"
  111151. */
  111152. getClassName(): string;
  111153. /**
  111154. * Occurs when the file is raw .hdr file.
  111155. */
  111156. private loadTexture;
  111157. clone(): HDRCubeTexture;
  111158. delayLoad(): void;
  111159. /**
  111160. * Get the texture reflection matrix used to rotate/transform the reflection.
  111161. * @returns the reflection matrix
  111162. */
  111163. getReflectionTextureMatrix(): Matrix;
  111164. /**
  111165. * Set the texture reflection matrix used to rotate/transform the reflection.
  111166. * @param value Define the reflection matrix to set
  111167. */
  111168. setReflectionTextureMatrix(value: Matrix): void;
  111169. /**
  111170. * Parses a JSON representation of an HDR Texture in order to create the texture
  111171. * @param parsedTexture Define the JSON representation
  111172. * @param scene Define the scene the texture should be created in
  111173. * @param rootUrl Define the root url in case we need to load relative dependencies
  111174. * @returns the newly created texture after parsing
  111175. */
  111176. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111177. serialize(): any;
  111178. }
  111179. }
  111180. declare module BABYLON {
  111181. /**
  111182. * Class used to control physics engine
  111183. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111184. */
  111185. export class PhysicsEngine implements IPhysicsEngine {
  111186. private _physicsPlugin;
  111187. /**
  111188. * Global value used to control the smallest number supported by the simulation
  111189. */
  111190. static Epsilon: number;
  111191. private _impostors;
  111192. private _joints;
  111193. /**
  111194. * Gets the gravity vector used by the simulation
  111195. */
  111196. gravity: Vector3;
  111197. /**
  111198. * Factory used to create the default physics plugin.
  111199. * @returns The default physics plugin
  111200. */
  111201. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111202. /**
  111203. * Creates a new Physics Engine
  111204. * @param gravity defines the gravity vector used by the simulation
  111205. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111206. */
  111207. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111208. /**
  111209. * Sets the gravity vector used by the simulation
  111210. * @param gravity defines the gravity vector to use
  111211. */
  111212. setGravity(gravity: Vector3): void;
  111213. /**
  111214. * Set the time step of the physics engine.
  111215. * Default is 1/60.
  111216. * To slow it down, enter 1/600 for example.
  111217. * To speed it up, 1/30
  111218. * @param newTimeStep defines the new timestep to apply to this world.
  111219. */
  111220. setTimeStep(newTimeStep?: number): void;
  111221. /**
  111222. * Get the time step of the physics engine.
  111223. * @returns the current time step
  111224. */
  111225. getTimeStep(): number;
  111226. /**
  111227. * Release all resources
  111228. */
  111229. dispose(): void;
  111230. /**
  111231. * Gets the name of the current physics plugin
  111232. * @returns the name of the plugin
  111233. */
  111234. getPhysicsPluginName(): string;
  111235. /**
  111236. * Adding a new impostor for the impostor tracking.
  111237. * This will be done by the impostor itself.
  111238. * @param impostor the impostor to add
  111239. */
  111240. addImpostor(impostor: PhysicsImpostor): void;
  111241. /**
  111242. * Remove an impostor from the engine.
  111243. * This impostor and its mesh will not longer be updated by the physics engine.
  111244. * @param impostor the impostor to remove
  111245. */
  111246. removeImpostor(impostor: PhysicsImpostor): void;
  111247. /**
  111248. * Add a joint to the physics engine
  111249. * @param mainImpostor defines the main impostor to which the joint is added.
  111250. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111251. * @param joint defines the joint that will connect both impostors.
  111252. */
  111253. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111254. /**
  111255. * Removes a joint from the simulation
  111256. * @param mainImpostor defines the impostor used with the joint
  111257. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111258. * @param joint defines the joint to remove
  111259. */
  111260. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111261. /**
  111262. * Called by the scene. No need to call it.
  111263. * @param delta defines the timespam between frames
  111264. */
  111265. _step(delta: number): void;
  111266. /**
  111267. * Gets the current plugin used to run the simulation
  111268. * @returns current plugin
  111269. */
  111270. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111271. /**
  111272. * Gets the list of physic impostors
  111273. * @returns an array of PhysicsImpostor
  111274. */
  111275. getImpostors(): Array<PhysicsImpostor>;
  111276. /**
  111277. * Gets the impostor for a physics enabled object
  111278. * @param object defines the object impersonated by the impostor
  111279. * @returns the PhysicsImpostor or null if not found
  111280. */
  111281. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111282. /**
  111283. * Gets the impostor for a physics body object
  111284. * @param body defines physics body used by the impostor
  111285. * @returns the PhysicsImpostor or null if not found
  111286. */
  111287. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111288. /**
  111289. * Does a raycast in the physics world
  111290. * @param from when should the ray start?
  111291. * @param to when should the ray end?
  111292. * @returns PhysicsRaycastResult
  111293. */
  111294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111295. }
  111296. }
  111297. declare module BABYLON {
  111298. /** @hidden */
  111299. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111300. private _useDeltaForWorldStep;
  111301. world: any;
  111302. name: string;
  111303. private _physicsMaterials;
  111304. private _fixedTimeStep;
  111305. private _cannonRaycastResult;
  111306. private _raycastResult;
  111307. private _removeAfterStep;
  111308. BJSCANNON: any;
  111309. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111310. setGravity(gravity: Vector3): void;
  111311. setTimeStep(timeStep: number): void;
  111312. getTimeStep(): number;
  111313. executeStep(delta: number): void;
  111314. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111315. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111316. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111317. private _processChildMeshes;
  111318. removePhysicsBody(impostor: PhysicsImpostor): void;
  111319. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111320. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111321. private _addMaterial;
  111322. private _checkWithEpsilon;
  111323. private _createShape;
  111324. private _createHeightmap;
  111325. private _minus90X;
  111326. private _plus90X;
  111327. private _tmpPosition;
  111328. private _tmpDeltaPosition;
  111329. private _tmpUnityRotation;
  111330. private _updatePhysicsBodyTransformation;
  111331. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111332. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111333. isSupported(): boolean;
  111334. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111335. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111336. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111337. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111338. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111339. getBodyMass(impostor: PhysicsImpostor): number;
  111340. getBodyFriction(impostor: PhysicsImpostor): number;
  111341. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111342. getBodyRestitution(impostor: PhysicsImpostor): number;
  111343. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111344. sleepBody(impostor: PhysicsImpostor): void;
  111345. wakeUpBody(impostor: PhysicsImpostor): void;
  111346. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111347. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111348. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111349. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111350. getRadius(impostor: PhysicsImpostor): number;
  111351. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111352. dispose(): void;
  111353. private _extendNamespace;
  111354. /**
  111355. * Does a raycast in the physics world
  111356. * @param from when should the ray start?
  111357. * @param to when should the ray end?
  111358. * @returns PhysicsRaycastResult
  111359. */
  111360. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111361. }
  111362. }
  111363. declare module BABYLON {
  111364. /** @hidden */
  111365. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111366. world: any;
  111367. name: string;
  111368. BJSOIMO: any;
  111369. private _raycastResult;
  111370. constructor(iterations?: number, oimoInjection?: any);
  111371. setGravity(gravity: Vector3): void;
  111372. setTimeStep(timeStep: number): void;
  111373. getTimeStep(): number;
  111374. private _tmpImpostorsArray;
  111375. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111376. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111377. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111378. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111379. private _tmpPositionVector;
  111380. removePhysicsBody(impostor: PhysicsImpostor): void;
  111381. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111382. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111383. isSupported(): boolean;
  111384. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111385. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111386. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111387. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111388. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111389. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111390. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111391. getBodyMass(impostor: PhysicsImpostor): number;
  111392. getBodyFriction(impostor: PhysicsImpostor): number;
  111393. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111394. getBodyRestitution(impostor: PhysicsImpostor): number;
  111395. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111396. sleepBody(impostor: PhysicsImpostor): void;
  111397. wakeUpBody(impostor: PhysicsImpostor): void;
  111398. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111399. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111400. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111401. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111402. getRadius(impostor: PhysicsImpostor): number;
  111403. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111404. dispose(): void;
  111405. /**
  111406. * Does a raycast in the physics world
  111407. * @param from when should the ray start?
  111408. * @param to when should the ray end?
  111409. * @returns PhysicsRaycastResult
  111410. */
  111411. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111412. }
  111413. }
  111414. declare module BABYLON {
  111415. /**
  111416. * Class containing static functions to help procedurally build meshes
  111417. */
  111418. export class RibbonBuilder {
  111419. /**
  111420. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111421. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111422. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111423. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111424. * * 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
  111425. * * 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
  111426. * * 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
  111427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111429. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111430. * * 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
  111431. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111432. * * 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
  111433. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111435. * @param name defines the name of the mesh
  111436. * @param options defines the options used to create the mesh
  111437. * @param scene defines the hosting scene
  111438. * @returns the ribbon mesh
  111439. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111440. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111441. */
  111442. static CreateRibbon(name: string, options: {
  111443. pathArray: Vector3[][];
  111444. closeArray?: boolean;
  111445. closePath?: boolean;
  111446. offset?: number;
  111447. updatable?: boolean;
  111448. sideOrientation?: number;
  111449. frontUVs?: Vector4;
  111450. backUVs?: Vector4;
  111451. instance?: Mesh;
  111452. invertUV?: boolean;
  111453. uvs?: Vector2[];
  111454. colors?: Color4[];
  111455. }, scene?: Nullable<Scene>): Mesh;
  111456. }
  111457. }
  111458. declare module BABYLON {
  111459. /**
  111460. * Class containing static functions to help procedurally build meshes
  111461. */
  111462. export class ShapeBuilder {
  111463. /**
  111464. * 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.
  111465. * * 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.
  111466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111467. * * 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.
  111468. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111469. * * 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
  111470. * * 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
  111471. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111476. * @param name defines the name of the mesh
  111477. * @param options defines the options used to create the mesh
  111478. * @param scene defines the hosting scene
  111479. * @returns the extruded shape mesh
  111480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111482. */
  111483. static ExtrudeShape(name: string, options: {
  111484. shape: Vector3[];
  111485. path: Vector3[];
  111486. scale?: number;
  111487. rotation?: number;
  111488. cap?: number;
  111489. updatable?: boolean;
  111490. sideOrientation?: number;
  111491. frontUVs?: Vector4;
  111492. backUVs?: Vector4;
  111493. instance?: Mesh;
  111494. invertUV?: boolean;
  111495. }, scene?: Nullable<Scene>): Mesh;
  111496. /**
  111497. * Creates an custom extruded shape mesh.
  111498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111499. * * 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.
  111500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111501. * * 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
  111502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111503. * * 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
  111504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111507. * * 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
  111508. * * 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
  111509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111514. * @param name defines the name of the mesh
  111515. * @param options defines the options used to create the mesh
  111516. * @param scene defines the hosting scene
  111517. * @returns the custom extruded shape mesh
  111518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111521. */
  111522. static ExtrudeShapeCustom(name: string, options: {
  111523. shape: Vector3[];
  111524. path: Vector3[];
  111525. scaleFunction?: any;
  111526. rotationFunction?: any;
  111527. ribbonCloseArray?: boolean;
  111528. ribbonClosePath?: boolean;
  111529. cap?: number;
  111530. updatable?: boolean;
  111531. sideOrientation?: number;
  111532. frontUVs?: Vector4;
  111533. backUVs?: Vector4;
  111534. instance?: Mesh;
  111535. invertUV?: boolean;
  111536. }, scene?: Nullable<Scene>): Mesh;
  111537. private static _ExtrudeShapeGeneric;
  111538. }
  111539. }
  111540. declare module BABYLON {
  111541. /**
  111542. * AmmoJS Physics plugin
  111543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111544. * @see https://github.com/kripken/ammo.js/
  111545. */
  111546. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111547. private _useDeltaForWorldStep;
  111548. /**
  111549. * Reference to the Ammo library
  111550. */
  111551. bjsAMMO: any;
  111552. /**
  111553. * Created ammoJS world which physics bodies are added to
  111554. */
  111555. world: any;
  111556. /**
  111557. * Name of the plugin
  111558. */
  111559. name: string;
  111560. private _timeStep;
  111561. private _fixedTimeStep;
  111562. private _maxSteps;
  111563. private _tmpQuaternion;
  111564. private _tmpAmmoTransform;
  111565. private _tmpAmmoQuaternion;
  111566. private _tmpAmmoConcreteContactResultCallback;
  111567. private _collisionConfiguration;
  111568. private _dispatcher;
  111569. private _overlappingPairCache;
  111570. private _solver;
  111571. private _softBodySolver;
  111572. private _tmpAmmoVectorA;
  111573. private _tmpAmmoVectorB;
  111574. private _tmpAmmoVectorC;
  111575. private _tmpAmmoVectorD;
  111576. private _tmpContactCallbackResult;
  111577. private _tmpAmmoVectorRCA;
  111578. private _tmpAmmoVectorRCB;
  111579. private _raycastResult;
  111580. private static readonly DISABLE_COLLISION_FLAG;
  111581. private static readonly KINEMATIC_FLAG;
  111582. private static readonly DISABLE_DEACTIVATION_FLAG;
  111583. /**
  111584. * Initializes the ammoJS plugin
  111585. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111586. * @param ammoInjection can be used to inject your own ammo reference
  111587. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  111588. */
  111589. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  111590. /**
  111591. * Sets the gravity of the physics world (m/(s^2))
  111592. * @param gravity Gravity to set
  111593. */
  111594. setGravity(gravity: Vector3): void;
  111595. /**
  111596. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111597. * @param timeStep timestep to use in seconds
  111598. */
  111599. setTimeStep(timeStep: number): void;
  111600. /**
  111601. * 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)
  111602. * @param fixedTimeStep fixedTimeStep to use in seconds
  111603. */
  111604. setFixedTimeStep(fixedTimeStep: number): void;
  111605. /**
  111606. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111607. * @param maxSteps the maximum number of steps by the physics engine per frame
  111608. */
  111609. setMaxSteps(maxSteps: number): void;
  111610. /**
  111611. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111612. * @returns the current timestep in seconds
  111613. */
  111614. getTimeStep(): number;
  111615. private _isImpostorInContact;
  111616. private _isImpostorPairInContact;
  111617. private _stepSimulation;
  111618. /**
  111619. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111620. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111621. * After the step the babylon meshes are set to the position of the physics imposters
  111622. * @param delta amount of time to step forward
  111623. * @param impostors array of imposters to update before/after the step
  111624. */
  111625. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111626. /**
  111627. * Update babylon mesh to match physics world object
  111628. * @param impostor imposter to match
  111629. */
  111630. private _afterSoftStep;
  111631. /**
  111632. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111633. * @param impostor imposter to match
  111634. */
  111635. private _ropeStep;
  111636. /**
  111637. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111638. * @param impostor imposter to match
  111639. */
  111640. private _softbodyOrClothStep;
  111641. private _tmpVector;
  111642. private _tmpMatrix;
  111643. /**
  111644. * Applies an impulse on the imposter
  111645. * @param impostor imposter to apply impulse to
  111646. * @param force amount of force to be applied to the imposter
  111647. * @param contactPoint the location to apply the impulse on the imposter
  111648. */
  111649. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111650. /**
  111651. * Applies a force on the imposter
  111652. * @param impostor imposter to apply force
  111653. * @param force amount of force to be applied to the imposter
  111654. * @param contactPoint the location to apply the force on the imposter
  111655. */
  111656. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111657. /**
  111658. * Creates a physics body using the plugin
  111659. * @param impostor the imposter to create the physics body on
  111660. */
  111661. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111662. /**
  111663. * Removes the physics body from the imposter and disposes of the body's memory
  111664. * @param impostor imposter to remove the physics body from
  111665. */
  111666. removePhysicsBody(impostor: PhysicsImpostor): void;
  111667. /**
  111668. * Generates a joint
  111669. * @param impostorJoint the imposter joint to create the joint with
  111670. */
  111671. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111672. /**
  111673. * Removes a joint
  111674. * @param impostorJoint the imposter joint to remove the joint from
  111675. */
  111676. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111677. private _addMeshVerts;
  111678. /**
  111679. * Initialise the soft body vertices to match its object's (mesh) vertices
  111680. * Softbody vertices (nodes) are in world space and to match this
  111681. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111682. * @param impostor to create the softbody for
  111683. */
  111684. private _softVertexData;
  111685. /**
  111686. * Create an impostor's soft body
  111687. * @param impostor to create the softbody for
  111688. */
  111689. private _createSoftbody;
  111690. /**
  111691. * Create cloth for an impostor
  111692. * @param impostor to create the softbody for
  111693. */
  111694. private _createCloth;
  111695. /**
  111696. * Create rope for an impostor
  111697. * @param impostor to create the softbody for
  111698. */
  111699. private _createRope;
  111700. private _addHullVerts;
  111701. private _createShape;
  111702. /**
  111703. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111704. * @param impostor imposter containing the physics body and babylon object
  111705. */
  111706. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111707. /**
  111708. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111709. * @param impostor imposter containing the physics body and babylon object
  111710. * @param newPosition new position
  111711. * @param newRotation new rotation
  111712. */
  111713. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111714. /**
  111715. * If this plugin is supported
  111716. * @returns true if its supported
  111717. */
  111718. isSupported(): boolean;
  111719. /**
  111720. * Sets the linear velocity of the physics body
  111721. * @param impostor imposter to set the velocity on
  111722. * @param velocity velocity to set
  111723. */
  111724. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111725. /**
  111726. * Sets the angular velocity of the physics body
  111727. * @param impostor imposter to set the velocity on
  111728. * @param velocity velocity to set
  111729. */
  111730. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111731. /**
  111732. * gets the linear velocity
  111733. * @param impostor imposter to get linear velocity from
  111734. * @returns linear velocity
  111735. */
  111736. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111737. /**
  111738. * gets the angular velocity
  111739. * @param impostor imposter to get angular velocity from
  111740. * @returns angular velocity
  111741. */
  111742. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111743. /**
  111744. * Sets the mass of physics body
  111745. * @param impostor imposter to set the mass on
  111746. * @param mass mass to set
  111747. */
  111748. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111749. /**
  111750. * Gets the mass of the physics body
  111751. * @param impostor imposter to get the mass from
  111752. * @returns mass
  111753. */
  111754. getBodyMass(impostor: PhysicsImpostor): number;
  111755. /**
  111756. * Gets friction of the impostor
  111757. * @param impostor impostor to get friction from
  111758. * @returns friction value
  111759. */
  111760. getBodyFriction(impostor: PhysicsImpostor): number;
  111761. /**
  111762. * Sets friction of the impostor
  111763. * @param impostor impostor to set friction on
  111764. * @param friction friction value
  111765. */
  111766. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111767. /**
  111768. * Gets restitution of the impostor
  111769. * @param impostor impostor to get restitution from
  111770. * @returns restitution value
  111771. */
  111772. getBodyRestitution(impostor: PhysicsImpostor): number;
  111773. /**
  111774. * Sets resitution of the impostor
  111775. * @param impostor impostor to set resitution on
  111776. * @param restitution resitution value
  111777. */
  111778. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111779. /**
  111780. * Gets pressure inside the impostor
  111781. * @param impostor impostor to get pressure from
  111782. * @returns pressure value
  111783. */
  111784. getBodyPressure(impostor: PhysicsImpostor): number;
  111785. /**
  111786. * Sets pressure inside a soft body impostor
  111787. * Cloth and rope must remain 0 pressure
  111788. * @param impostor impostor to set pressure on
  111789. * @param pressure pressure value
  111790. */
  111791. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  111792. /**
  111793. * Gets stiffness of the impostor
  111794. * @param impostor impostor to get stiffness from
  111795. * @returns pressure value
  111796. */
  111797. getBodyStiffness(impostor: PhysicsImpostor): number;
  111798. /**
  111799. * Sets stiffness of the impostor
  111800. * @param impostor impostor to set stiffness on
  111801. * @param stiffness stiffness value from 0 to 1
  111802. */
  111803. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  111804. /**
  111805. * Gets velocityIterations of the impostor
  111806. * @param impostor impostor to get velocity iterations from
  111807. * @returns velocityIterations value
  111808. */
  111809. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  111810. /**
  111811. * Sets velocityIterations of the impostor
  111812. * @param impostor impostor to set velocity iterations on
  111813. * @param velocityIterations velocityIterations value
  111814. */
  111815. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  111816. /**
  111817. * Gets positionIterations of the impostor
  111818. * @param impostor impostor to get position iterations from
  111819. * @returns positionIterations value
  111820. */
  111821. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  111822. /**
  111823. * Sets positionIterations of the impostor
  111824. * @param impostor impostor to set position on
  111825. * @param positionIterations positionIterations value
  111826. */
  111827. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  111828. /**
  111829. * Append an anchor to a cloth object
  111830. * @param impostor is the cloth impostor to add anchor to
  111831. * @param otherImpostor is the rigid impostor to anchor to
  111832. * @param width ratio across width from 0 to 1
  111833. * @param height ratio up height from 0 to 1
  111834. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  111835. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111836. */
  111837. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111838. /**
  111839. * Append an hook to a rope object
  111840. * @param impostor is the rope impostor to add hook to
  111841. * @param otherImpostor is the rigid impostor to hook to
  111842. * @param length ratio along the rope from 0 to 1
  111843. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  111844. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111845. */
  111846. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111847. /**
  111848. * Sleeps the physics body and stops it from being active
  111849. * @param impostor impostor to sleep
  111850. */
  111851. sleepBody(impostor: PhysicsImpostor): void;
  111852. /**
  111853. * Activates the physics body
  111854. * @param impostor impostor to activate
  111855. */
  111856. wakeUpBody(impostor: PhysicsImpostor): void;
  111857. /**
  111858. * Updates the distance parameters of the joint
  111859. * @param joint joint to update
  111860. * @param maxDistance maximum distance of the joint
  111861. * @param minDistance minimum distance of the joint
  111862. */
  111863. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111864. /**
  111865. * Sets a motor on the joint
  111866. * @param joint joint to set motor on
  111867. * @param speed speed of the motor
  111868. * @param maxForce maximum force of the motor
  111869. * @param motorIndex index of the motor
  111870. */
  111871. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111872. /**
  111873. * Sets the motors limit
  111874. * @param joint joint to set limit on
  111875. * @param upperLimit upper limit
  111876. * @param lowerLimit lower limit
  111877. */
  111878. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111879. /**
  111880. * Syncs the position and rotation of a mesh with the impostor
  111881. * @param mesh mesh to sync
  111882. * @param impostor impostor to update the mesh with
  111883. */
  111884. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111885. /**
  111886. * Gets the radius of the impostor
  111887. * @param impostor impostor to get radius from
  111888. * @returns the radius
  111889. */
  111890. getRadius(impostor: PhysicsImpostor): number;
  111891. /**
  111892. * Gets the box size of the impostor
  111893. * @param impostor impostor to get box size from
  111894. * @param result the resulting box size
  111895. */
  111896. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111897. /**
  111898. * Disposes of the impostor
  111899. */
  111900. dispose(): void;
  111901. /**
  111902. * Does a raycast in the physics world
  111903. * @param from when should the ray start?
  111904. * @param to when should the ray end?
  111905. * @returns PhysicsRaycastResult
  111906. */
  111907. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111908. }
  111909. }
  111910. declare module BABYLON {
  111911. interface AbstractScene {
  111912. /**
  111913. * The list of reflection probes added to the scene
  111914. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111915. */
  111916. reflectionProbes: Array<ReflectionProbe>;
  111917. /**
  111918. * Removes the given reflection probe from this scene.
  111919. * @param toRemove The reflection probe to remove
  111920. * @returns The index of the removed reflection probe
  111921. */
  111922. removeReflectionProbe(toRemove: ReflectionProbe): number;
  111923. /**
  111924. * Adds the given reflection probe to this scene.
  111925. * @param newReflectionProbe The reflection probe to add
  111926. */
  111927. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  111928. }
  111929. /**
  111930. * Class used to generate realtime reflection / refraction cube textures
  111931. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111932. */
  111933. export class ReflectionProbe {
  111934. /** defines the name of the probe */
  111935. name: string;
  111936. private _scene;
  111937. private _renderTargetTexture;
  111938. private _projectionMatrix;
  111939. private _viewMatrix;
  111940. private _target;
  111941. private _add;
  111942. private _attachedMesh;
  111943. private _invertYAxis;
  111944. /** Gets or sets probe position (center of the cube map) */
  111945. position: Vector3;
  111946. /**
  111947. * Creates a new reflection probe
  111948. * @param name defines the name of the probe
  111949. * @param size defines the texture resolution (for each face)
  111950. * @param scene defines the hosting scene
  111951. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  111952. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  111953. */
  111954. constructor(
  111955. /** defines the name of the probe */
  111956. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  111957. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  111958. samples: number;
  111959. /** Gets or sets the refresh rate to use (on every frame by default) */
  111960. refreshRate: number;
  111961. /**
  111962. * Gets the hosting scene
  111963. * @returns a Scene
  111964. */
  111965. getScene(): Scene;
  111966. /** Gets the internal CubeTexture used to render to */
  111967. readonly cubeTexture: RenderTargetTexture;
  111968. /** Gets the list of meshes to render */
  111969. readonly renderList: Nullable<AbstractMesh[]>;
  111970. /**
  111971. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  111972. * @param mesh defines the mesh to attach to
  111973. */
  111974. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111975. /**
  111976. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  111977. * @param renderingGroupId The rendering group id corresponding to its index
  111978. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111979. */
  111980. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  111981. /**
  111982. * Clean all associated resources
  111983. */
  111984. dispose(): void;
  111985. /**
  111986. * Converts the reflection probe information to a readable string for debug purpose.
  111987. * @param fullDetails Supports for multiple levels of logging within scene loading
  111988. * @returns the human readable reflection probe info
  111989. */
  111990. toString(fullDetails?: boolean): string;
  111991. /**
  111992. * Get the class name of the relfection probe.
  111993. * @returns "ReflectionProbe"
  111994. */
  111995. getClassName(): string;
  111996. /**
  111997. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  111998. * @returns The JSON representation of the texture
  111999. */
  112000. serialize(): any;
  112001. /**
  112002. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112003. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112004. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112005. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112006. * @returns The parsed reflection probe if successful
  112007. */
  112008. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112009. }
  112010. }
  112011. declare module BABYLON {
  112012. /** @hidden */
  112013. export var _BabylonLoaderRegistered: boolean;
  112014. }
  112015. declare module BABYLON {
  112016. /**
  112017. * The Physically based simple base material of BJS.
  112018. *
  112019. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112020. * It is used as the base class for both the specGloss and metalRough conventions.
  112021. */
  112022. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112023. /**
  112024. * Number of Simultaneous lights allowed on the material.
  112025. */
  112026. maxSimultaneousLights: number;
  112027. /**
  112028. * If sets to true, disables all the lights affecting the material.
  112029. */
  112030. disableLighting: boolean;
  112031. /**
  112032. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112033. */
  112034. environmentTexture: BaseTexture;
  112035. /**
  112036. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112037. */
  112038. invertNormalMapX: boolean;
  112039. /**
  112040. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112041. */
  112042. invertNormalMapY: boolean;
  112043. /**
  112044. * Normal map used in the model.
  112045. */
  112046. normalTexture: BaseTexture;
  112047. /**
  112048. * Emissivie color used to self-illuminate the model.
  112049. */
  112050. emissiveColor: Color3;
  112051. /**
  112052. * Emissivie texture used to self-illuminate the model.
  112053. */
  112054. emissiveTexture: BaseTexture;
  112055. /**
  112056. * Occlusion Channel Strenght.
  112057. */
  112058. occlusionStrength: number;
  112059. /**
  112060. * Occlusion Texture of the material (adding extra occlusion effects).
  112061. */
  112062. occlusionTexture: BaseTexture;
  112063. /**
  112064. * Defines the alpha limits in alpha test mode.
  112065. */
  112066. alphaCutOff: number;
  112067. /**
  112068. * Gets the current double sided mode.
  112069. */
  112070. /**
  112071. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112072. */
  112073. doubleSided: boolean;
  112074. /**
  112075. * Stores the pre-calculated light information of a mesh in a texture.
  112076. */
  112077. lightmapTexture: BaseTexture;
  112078. /**
  112079. * If true, the light map contains occlusion information instead of lighting info.
  112080. */
  112081. useLightmapAsShadowmap: boolean;
  112082. /**
  112083. * Instantiates a new PBRMaterial instance.
  112084. *
  112085. * @param name The material name
  112086. * @param scene The scene the material will be use in.
  112087. */
  112088. constructor(name: string, scene: Scene);
  112089. getClassName(): string;
  112090. }
  112091. }
  112092. declare module BABYLON {
  112093. /**
  112094. * The PBR material of BJS following the metal roughness convention.
  112095. *
  112096. * This fits to the PBR convention in the GLTF definition:
  112097. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112098. */
  112099. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112100. /**
  112101. * The base color has two different interpretations depending on the value of metalness.
  112102. * When the material is a metal, the base color is the specific measured reflectance value
  112103. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112104. * of the material.
  112105. */
  112106. baseColor: Color3;
  112107. /**
  112108. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112109. * well as opacity information in the alpha channel.
  112110. */
  112111. baseTexture: BaseTexture;
  112112. /**
  112113. * Specifies the metallic scalar value of the material.
  112114. * Can also be used to scale the metalness values of the metallic texture.
  112115. */
  112116. metallic: number;
  112117. /**
  112118. * Specifies the roughness scalar value of the material.
  112119. * Can also be used to scale the roughness values of the metallic texture.
  112120. */
  112121. roughness: number;
  112122. /**
  112123. * Texture containing both the metallic value in the B channel and the
  112124. * roughness value in the G channel to keep better precision.
  112125. */
  112126. metallicRoughnessTexture: BaseTexture;
  112127. /**
  112128. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112129. *
  112130. * @param name The material name
  112131. * @param scene The scene the material will be use in.
  112132. */
  112133. constructor(name: string, scene: Scene);
  112134. /**
  112135. * Return the currrent class name of the material.
  112136. */
  112137. getClassName(): string;
  112138. /**
  112139. * Makes a duplicate of the current material.
  112140. * @param name - name to use for the new material.
  112141. */
  112142. clone(name: string): PBRMetallicRoughnessMaterial;
  112143. /**
  112144. * Serialize the material to a parsable JSON object.
  112145. */
  112146. serialize(): any;
  112147. /**
  112148. * Parses a JSON object correponding to the serialize function.
  112149. */
  112150. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112151. }
  112152. }
  112153. declare module BABYLON {
  112154. /**
  112155. * The PBR material of BJS following the specular glossiness convention.
  112156. *
  112157. * This fits to the PBR convention in the GLTF definition:
  112158. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112159. */
  112160. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112161. /**
  112162. * Specifies the diffuse color of the material.
  112163. */
  112164. diffuseColor: Color3;
  112165. /**
  112166. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112167. * channel.
  112168. */
  112169. diffuseTexture: BaseTexture;
  112170. /**
  112171. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112172. */
  112173. specularColor: Color3;
  112174. /**
  112175. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112176. */
  112177. glossiness: number;
  112178. /**
  112179. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112180. */
  112181. specularGlossinessTexture: BaseTexture;
  112182. /**
  112183. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112184. *
  112185. * @param name The material name
  112186. * @param scene The scene the material will be use in.
  112187. */
  112188. constructor(name: string, scene: Scene);
  112189. /**
  112190. * Return the currrent class name of the material.
  112191. */
  112192. getClassName(): string;
  112193. /**
  112194. * Makes a duplicate of the current material.
  112195. * @param name - name to use for the new material.
  112196. */
  112197. clone(name: string): PBRSpecularGlossinessMaterial;
  112198. /**
  112199. * Serialize the material to a parsable JSON object.
  112200. */
  112201. serialize(): any;
  112202. /**
  112203. * Parses a JSON object correponding to the serialize function.
  112204. */
  112205. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /**
  112210. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112211. * It can help converting any input color in a desired output one. This can then be used to create effects
  112212. * from sepia, black and white to sixties or futuristic rendering...
  112213. *
  112214. * The only supported format is currently 3dl.
  112215. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112216. */
  112217. export class ColorGradingTexture extends BaseTexture {
  112218. /**
  112219. * The current texture matrix. (will always be identity in color grading texture)
  112220. */
  112221. private _textureMatrix;
  112222. /**
  112223. * The texture URL.
  112224. */
  112225. url: string;
  112226. /**
  112227. * Empty line regex stored for GC.
  112228. */
  112229. private static _noneEmptyLineRegex;
  112230. private _engine;
  112231. /**
  112232. * Instantiates a ColorGradingTexture from the following parameters.
  112233. *
  112234. * @param url The location of the color gradind data (currently only supporting 3dl)
  112235. * @param scene The scene the texture will be used in
  112236. */
  112237. constructor(url: string, scene: Scene);
  112238. /**
  112239. * Returns the texture matrix used in most of the material.
  112240. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112241. */
  112242. getTextureMatrix(): Matrix;
  112243. /**
  112244. * Occurs when the file being loaded is a .3dl LUT file.
  112245. */
  112246. private load3dlTexture;
  112247. /**
  112248. * Starts the loading process of the texture.
  112249. */
  112250. private loadTexture;
  112251. /**
  112252. * Clones the color gradind texture.
  112253. */
  112254. clone(): ColorGradingTexture;
  112255. /**
  112256. * Called during delayed load for textures.
  112257. */
  112258. delayLoad(): void;
  112259. /**
  112260. * Parses a color grading texture serialized by Babylon.
  112261. * @param parsedTexture The texture information being parsedTexture
  112262. * @param scene The scene to load the texture in
  112263. * @param rootUrl The root url of the data assets to load
  112264. * @return A color gradind texture
  112265. */
  112266. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112267. /**
  112268. * Serializes the LUT texture to json format.
  112269. */
  112270. serialize(): any;
  112271. }
  112272. }
  112273. declare module BABYLON {
  112274. /**
  112275. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112276. */
  112277. export class EquiRectangularCubeTexture extends BaseTexture {
  112278. /** The six faces of the cube. */
  112279. private static _FacesMapping;
  112280. private _noMipmap;
  112281. private _onLoad;
  112282. private _onError;
  112283. /** The size of the cubemap. */
  112284. private _size;
  112285. /** The buffer of the image. */
  112286. private _buffer;
  112287. /** The width of the input image. */
  112288. private _width;
  112289. /** The height of the input image. */
  112290. private _height;
  112291. /** The URL to the image. */
  112292. url: string;
  112293. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112294. coordinatesMode: number;
  112295. /**
  112296. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112297. * @param url The location of the image
  112298. * @param scene The scene the texture will be used in
  112299. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112300. * @param noMipmap Forces to not generate the mipmap if true
  112301. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112302. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112303. * @param onLoad — defines a callback called when texture is loaded
  112304. * @param onError — defines a callback called if there is an error
  112305. */
  112306. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112307. /**
  112308. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112309. */
  112310. private loadImage;
  112311. /**
  112312. * Convert the image buffer into a cubemap and create a CubeTexture.
  112313. */
  112314. private loadTexture;
  112315. /**
  112316. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112317. * @param buffer The ArrayBuffer that should be converted.
  112318. * @returns The buffer as Float32Array.
  112319. */
  112320. private getFloat32ArrayFromArrayBuffer;
  112321. /**
  112322. * Get the current class name of the texture useful for serialization or dynamic coding.
  112323. * @returns "EquiRectangularCubeTexture"
  112324. */
  112325. getClassName(): string;
  112326. /**
  112327. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112328. * @returns A clone of the current EquiRectangularCubeTexture.
  112329. */
  112330. clone(): EquiRectangularCubeTexture;
  112331. }
  112332. }
  112333. declare module BABYLON {
  112334. /**
  112335. * Based on jsTGALoader - Javascript loader for TGA file
  112336. * By Vincent Thibault
  112337. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112338. */
  112339. export class TGATools {
  112340. private static _TYPE_INDEXED;
  112341. private static _TYPE_RGB;
  112342. private static _TYPE_GREY;
  112343. private static _TYPE_RLE_INDEXED;
  112344. private static _TYPE_RLE_RGB;
  112345. private static _TYPE_RLE_GREY;
  112346. private static _ORIGIN_MASK;
  112347. private static _ORIGIN_SHIFT;
  112348. private static _ORIGIN_BL;
  112349. private static _ORIGIN_BR;
  112350. private static _ORIGIN_UL;
  112351. private static _ORIGIN_UR;
  112352. /**
  112353. * Gets the header of a TGA file
  112354. * @param data defines the TGA data
  112355. * @returns the header
  112356. */
  112357. static GetTGAHeader(data: Uint8Array): any;
  112358. /**
  112359. * Uploads TGA content to a Babylon Texture
  112360. * @hidden
  112361. */
  112362. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112363. /** @hidden */
  112364. 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;
  112365. /** @hidden */
  112366. 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;
  112367. /** @hidden */
  112368. 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;
  112369. /** @hidden */
  112370. 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;
  112371. /** @hidden */
  112372. 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;
  112373. /** @hidden */
  112374. 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;
  112375. }
  112376. }
  112377. declare module BABYLON {
  112378. /**
  112379. * Implementation of the TGA Texture Loader.
  112380. * @hidden
  112381. */
  112382. export class _TGATextureLoader implements IInternalTextureLoader {
  112383. /**
  112384. * Defines wether the loader supports cascade loading the different faces.
  112385. */
  112386. readonly supportCascades: boolean;
  112387. /**
  112388. * This returns if the loader support the current file information.
  112389. * @param extension defines the file extension of the file being loaded
  112390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112391. * @param fallback defines the fallback internal texture if any
  112392. * @param isBase64 defines whether the texture is encoded as a base64
  112393. * @param isBuffer defines whether the texture data are stored as a buffer
  112394. * @returns true if the loader can load the specified file
  112395. */
  112396. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112397. /**
  112398. * Transform the url before loading if required.
  112399. * @param rootUrl the url of the texture
  112400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112401. * @returns the transformed texture
  112402. */
  112403. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112404. /**
  112405. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112406. * @param rootUrl the url of the texture
  112407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112408. * @returns the fallback texture
  112409. */
  112410. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112411. /**
  112412. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112413. * @param data contains the texture data
  112414. * @param texture defines the BabylonJS internal texture
  112415. * @param createPolynomials will be true if polynomials have been requested
  112416. * @param onLoad defines the callback to trigger once the texture is ready
  112417. * @param onError defines the callback to trigger in case of error
  112418. */
  112419. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112420. /**
  112421. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112422. * @param data contains the texture data
  112423. * @param texture defines the BabylonJS internal texture
  112424. * @param callback defines the method to call once ready to upload
  112425. */
  112426. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112427. }
  112428. }
  112429. declare module BABYLON {
  112430. /**
  112431. * 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.
  112432. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112433. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112434. */
  112435. export class CustomProceduralTexture extends ProceduralTexture {
  112436. private _animate;
  112437. private _time;
  112438. private _config;
  112439. private _texturePath;
  112440. /**
  112441. * Instantiates a new Custom Procedural Texture.
  112442. * 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.
  112443. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112444. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112445. * @param name Define the name of the texture
  112446. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112447. * @param size Define the size of the texture to create
  112448. * @param scene Define the scene the texture belongs to
  112449. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112450. * @param generateMipMaps Define if the texture should creates mip maps or not
  112451. */
  112452. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112453. private _loadJson;
  112454. /**
  112455. * Is the texture ready to be used ? (rendered at least once)
  112456. * @returns true if ready, otherwise, false.
  112457. */
  112458. isReady(): boolean;
  112459. /**
  112460. * Render the texture to its associated render target.
  112461. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  112462. */
  112463. render(useCameraPostProcess?: boolean): void;
  112464. /**
  112465. * Update the list of dependant textures samplers in the shader.
  112466. */
  112467. updateTextures(): void;
  112468. /**
  112469. * Update the uniform values of the procedural texture in the shader.
  112470. */
  112471. updateShaderUniforms(): void;
  112472. /**
  112473. * Define if the texture animates or not.
  112474. */
  112475. animate: boolean;
  112476. }
  112477. }
  112478. declare module BABYLON {
  112479. /** @hidden */
  112480. export var noisePixelShader: {
  112481. name: string;
  112482. shader: string;
  112483. };
  112484. }
  112485. declare module BABYLON {
  112486. /**
  112487. * Class used to generate noise procedural textures
  112488. */
  112489. export class NoiseProceduralTexture extends ProceduralTexture {
  112490. private _time;
  112491. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  112492. brightness: number;
  112493. /** Defines the number of octaves to process */
  112494. octaves: number;
  112495. /** Defines the level of persistence (0.8 by default) */
  112496. persistence: number;
  112497. /** Gets or sets animation speed factor (default is 1) */
  112498. animationSpeedFactor: number;
  112499. /**
  112500. * Creates a new NoiseProceduralTexture
  112501. * @param name defines the name fo the texture
  112502. * @param size defines the size of the texture (default is 256)
  112503. * @param scene defines the hosting scene
  112504. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  112505. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  112506. */
  112507. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112508. private _updateShaderUniforms;
  112509. protected _getDefines(): string;
  112510. /** Generate the current state of the procedural texture */
  112511. render(useCameraPostProcess?: boolean): void;
  112512. /**
  112513. * Serializes this noise procedural texture
  112514. * @returns a serialized noise procedural texture object
  112515. */
  112516. serialize(): any;
  112517. /**
  112518. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  112519. * @param parsedTexture defines parsed texture data
  112520. * @param scene defines the current scene
  112521. * @param rootUrl defines the root URL containing noise procedural texture information
  112522. * @returns a parsed NoiseProceduralTexture
  112523. */
  112524. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  112525. }
  112526. }
  112527. declare module BABYLON {
  112528. /**
  112529. * Raw cube texture where the raw buffers are passed in
  112530. */
  112531. export class RawCubeTexture extends CubeTexture {
  112532. /**
  112533. * Creates a cube texture where the raw buffers are passed in.
  112534. * @param scene defines the scene the texture is attached to
  112535. * @param data defines the array of data to use to create each face
  112536. * @param size defines the size of the textures
  112537. * @param format defines the format of the data
  112538. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112539. * @param generateMipMaps defines if the engine should generate the mip levels
  112540. * @param invertY defines if data must be stored with Y axis inverted
  112541. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112542. * @param compression defines the compression used (null by default)
  112543. */
  112544. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112545. /**
  112546. * Updates the raw cube texture.
  112547. * @param data defines the data to store
  112548. * @param format defines the data format
  112549. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112550. * @param invertY defines if data must be stored with Y axis inverted
  112551. * @param compression defines the compression used (null by default)
  112552. * @param level defines which level of the texture to update
  112553. */
  112554. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112555. /**
  112556. * Updates a raw cube texture with RGBD encoded data.
  112557. * @param data defines the array of data [mipmap][face] to use to create each face
  112558. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112559. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112560. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112561. * @returns a promsie that resolves when the operation is complete
  112562. */
  112563. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112564. /**
  112565. * Clones the raw cube texture.
  112566. * @return a new cube texture
  112567. */
  112568. clone(): CubeTexture;
  112569. /** @hidden */
  112570. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112571. }
  112572. }
  112573. declare module BABYLON {
  112574. /**
  112575. * Class used to store 3D textures containing user data
  112576. */
  112577. export class RawTexture3D extends Texture {
  112578. /** Gets or sets the texture format to use */
  112579. format: number;
  112580. private _engine;
  112581. /**
  112582. * Create a new RawTexture3D
  112583. * @param data defines the data of the texture
  112584. * @param width defines the width of the texture
  112585. * @param height defines the height of the texture
  112586. * @param depth defines the depth of the texture
  112587. * @param format defines the texture format to use
  112588. * @param scene defines the hosting scene
  112589. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112590. * @param invertY defines if texture must be stored with Y axis inverted
  112591. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112592. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112593. */
  112594. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112595. /** Gets or sets the texture format to use */
  112596. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112597. /**
  112598. * Update the texture with new data
  112599. * @param data defines the data to store in the texture
  112600. */
  112601. update(data: ArrayBufferView): void;
  112602. }
  112603. }
  112604. declare module BABYLON {
  112605. /**
  112606. * Creates a refraction texture used by refraction channel of the standard material.
  112607. * It is like a mirror but to see through a material.
  112608. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112609. */
  112610. export class RefractionTexture extends RenderTargetTexture {
  112611. /**
  112612. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  112613. * 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.
  112614. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112615. */
  112616. refractionPlane: Plane;
  112617. /**
  112618. * Define how deep under the surface we should see.
  112619. */
  112620. depth: number;
  112621. /**
  112622. * Creates a refraction texture used by refraction channel of the standard material.
  112623. * It is like a mirror but to see through a material.
  112624. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112625. * @param name Define the texture name
  112626. * @param size Define the size of the underlying texture
  112627. * @param scene Define the scene the refraction belongs to
  112628. * @param generateMipMaps Define if we need to generate mips level for the refraction
  112629. */
  112630. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  112631. /**
  112632. * Clone the refraction texture.
  112633. * @returns the cloned texture
  112634. */
  112635. clone(): RefractionTexture;
  112636. /**
  112637. * Serialize the texture to a JSON representation you could use in Parse later on
  112638. * @returns the serialized JSON representation
  112639. */
  112640. serialize(): any;
  112641. }
  112642. }
  112643. declare module BABYLON {
  112644. /**
  112645. * Defines the options related to the creation of an HtmlElementTexture
  112646. */
  112647. export interface IHtmlElementTextureOptions {
  112648. /**
  112649. * Defines wether mip maps should be created or not.
  112650. */
  112651. generateMipMaps?: boolean;
  112652. /**
  112653. * Defines the sampling mode of the texture.
  112654. */
  112655. samplingMode?: number;
  112656. /**
  112657. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  112658. */
  112659. engine: Nullable<Engine>;
  112660. /**
  112661. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  112662. */
  112663. scene: Nullable<Scene>;
  112664. }
  112665. /**
  112666. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  112667. * To be as efficient as possible depending on your constraints nothing aside the first upload
  112668. * is automatically managed.
  112669. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  112670. * in your application.
  112671. *
  112672. * As the update is not automatic, you need to call them manually.
  112673. */
  112674. export class HtmlElementTexture extends BaseTexture {
  112675. /**
  112676. * The texture URL.
  112677. */
  112678. element: HTMLVideoElement | HTMLCanvasElement;
  112679. private static readonly DefaultOptions;
  112680. private _textureMatrix;
  112681. private _engine;
  112682. private _isVideo;
  112683. private _generateMipMaps;
  112684. private _samplingMode;
  112685. /**
  112686. * Instantiates a HtmlElementTexture from the following parameters.
  112687. *
  112688. * @param name Defines the name of the texture
  112689. * @param element Defines the video or canvas the texture is filled with
  112690. * @param options Defines the other none mandatory texture creation options
  112691. */
  112692. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  112693. private _createInternalTexture;
  112694. /**
  112695. * Returns the texture matrix used in most of the material.
  112696. */
  112697. getTextureMatrix(): Matrix;
  112698. /**
  112699. * Updates the content of the texture.
  112700. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  112701. */
  112702. update(invertY?: Nullable<boolean>): void;
  112703. }
  112704. }
  112705. declare module BABYLON {
  112706. /**
  112707. * Enum used to define the target of a block
  112708. */
  112709. export enum NodeMaterialBlockTargets {
  112710. /** Vertex shader */
  112711. Vertex = 1,
  112712. /** Fragment shader */
  112713. Fragment = 2,
  112714. /** Vertex and Fragment */
  112715. VertexAndFragment = 3
  112716. }
  112717. }
  112718. declare module BABYLON {
  112719. /**
  112720. * Defines the kind of connection point for node based material
  112721. */
  112722. export enum NodeMaterialBlockConnectionPointTypes {
  112723. /** Float */
  112724. Float = 1,
  112725. /** Int */
  112726. Int = 2,
  112727. /** Vector2 */
  112728. Vector2 = 4,
  112729. /** Vector3 */
  112730. Vector3 = 8,
  112731. /** Vector4 */
  112732. Vector4 = 16,
  112733. /** Color3 */
  112734. Color3 = 32,
  112735. /** Color4 */
  112736. Color4 = 64,
  112737. /** Matrix */
  112738. Matrix = 128,
  112739. /** Texture */
  112740. Texture = 256,
  112741. /** Texture3D */
  112742. Texture3D = 512,
  112743. /** Vector3 or Color3 */
  112744. Vector3OrColor3 = 40,
  112745. /** Vector3 or Vector4 */
  112746. Vector3OrVector4 = 24,
  112747. /** Vector4 or Color4 */
  112748. Vector4OrColor4 = 80,
  112749. /** Color3 or Color4 */
  112750. Color3OrColor4 = 96,
  112751. /** Vector3 or Color3 */
  112752. Vector3OrColor3OrVector4OrColor4 = 120
  112753. }
  112754. }
  112755. declare module BABYLON {
  112756. /**
  112757. * Enum used to define well known values e.g. values automatically provided by the system
  112758. */
  112759. export enum NodeMaterialWellKnownValues {
  112760. /** World */
  112761. World = 1,
  112762. /** View */
  112763. View = 2,
  112764. /** Projection */
  112765. Projection = 3,
  112766. /** ViewProjection */
  112767. ViewProjection = 4,
  112768. /** WorldView */
  112769. WorldView = 5,
  112770. /** WorldViewProjection */
  112771. WorldViewProjection = 6,
  112772. /** Will be filled by the block itself */
  112773. Automatic = 7
  112774. }
  112775. }
  112776. declare module BABYLON {
  112777. /**
  112778. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  112779. */
  112780. export enum NodeMaterialBlockConnectionPointMode {
  112781. /** Value is an uniform */
  112782. Uniform = 0,
  112783. /** Value is a mesh attribute */
  112784. Attribute = 1,
  112785. /** Value is a varying between vertex and fragment shaders */
  112786. Varying = 2,
  112787. /** Mode is undefined */
  112788. Undefined = 3
  112789. }
  112790. }
  112791. declare module BABYLON {
  112792. /**
  112793. * Class used to store shared data between 2 NodeMaterialBuildState
  112794. */
  112795. export class NodeMaterialBuildStateSharedData {
  112796. /**
  112797. * Gets the list of emitted varyings
  112798. */
  112799. varyings: string[];
  112800. /**
  112801. * Gets the varying declaration string
  112802. */
  112803. varyingDeclaration: string;
  112804. /**
  112805. * Uniform connection points
  112806. */
  112807. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  112808. /**
  112809. * Bindable blocks (Blocks that need to set data to the effect)
  112810. */
  112811. bindableBlocks: NodeMaterialBlock[];
  112812. /**
  112813. * List of blocks that can provide a compilation fallback
  112814. */
  112815. blocksWithFallbacks: NodeMaterialBlock[];
  112816. /**
  112817. * List of blocks that can provide a define update
  112818. */
  112819. blocksWithDefines: NodeMaterialBlock[];
  112820. /**
  112821. * List of blocks that can provide a repeatable content
  112822. */
  112823. repeatableContentBlocks: NodeMaterialBlock[];
  112824. /**
  112825. * List of blocks that can block the isReady function for the material
  112826. */
  112827. blockingBlocks: NodeMaterialBlock[];
  112828. /**
  112829. * Build Id used to avoid multiple recompilations
  112830. */
  112831. buildId: number;
  112832. /** List of emitted variables */
  112833. variableNames: {
  112834. [key: string]: number;
  112835. };
  112836. /** List of emitted defines */
  112837. defineNames: {
  112838. [key: string]: number;
  112839. };
  112840. /** Should emit comments? */
  112841. emitComments: boolean;
  112842. /** Emit build activity */
  112843. verbose: boolean;
  112844. /**
  112845. * Gets the compilation hints emitted at compilation time
  112846. */
  112847. hints: {
  112848. needWorldViewMatrix: boolean;
  112849. needWorldViewProjectionMatrix: boolean;
  112850. needAlphaBlending: boolean;
  112851. needAlphaTesting: boolean;
  112852. };
  112853. /**
  112854. * List of compilation checks
  112855. */
  112856. checks: {
  112857. emitVertex: boolean;
  112858. emitFragment: boolean;
  112859. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  112860. };
  112861. /** Creates a new shared data */
  112862. constructor();
  112863. /**
  112864. * Emits console errors and exceptions if there is a failing check
  112865. */
  112866. emitErrors(): void;
  112867. }
  112868. }
  112869. declare module BABYLON {
  112870. /**
  112871. * Class used to store node based material build state
  112872. */
  112873. export class NodeMaterialBuildState {
  112874. /**
  112875. * Gets the list of emitted attributes
  112876. */
  112877. attributes: string[];
  112878. /**
  112879. * Gets the list of emitted uniforms
  112880. */
  112881. uniforms: string[];
  112882. /**
  112883. * Gets the list of emitted samplers
  112884. */
  112885. samplers: string[];
  112886. /**
  112887. * Gets the list of emitted functions
  112888. */
  112889. functions: {
  112890. [key: string]: string;
  112891. };
  112892. /**
  112893. * Gets the target of the compilation state
  112894. */
  112895. target: NodeMaterialBlockTargets;
  112896. /**
  112897. * Shared data between multiple NodeMaterialBuildState instances
  112898. */
  112899. sharedData: NodeMaterialBuildStateSharedData;
  112900. /** @hidden */
  112901. _vertexState: NodeMaterialBuildState;
  112902. private _attributeDeclaration;
  112903. private _uniformDeclaration;
  112904. private _samplerDeclaration;
  112905. private _varyingTransfer;
  112906. private _repeatableContentAnchorIndex;
  112907. /** @hidden */
  112908. _builtCompilationString: string;
  112909. /**
  112910. * Gets the emitted compilation strings
  112911. */
  112912. compilationString: string;
  112913. /**
  112914. * Finalize the compilation strings
  112915. * @param state defines the current compilation state
  112916. */
  112917. finalize(state: NodeMaterialBuildState): void;
  112918. /** @hidden */
  112919. readonly _repeatableContentAnchor: string;
  112920. /** @hidden */
  112921. _getFreeVariableName(prefix: string): string;
  112922. /** @hidden */
  112923. _getFreeDefineName(prefix: string): string;
  112924. /** @hidden */
  112925. _excludeVariableName(name: string): void;
  112926. /** @hidden */
  112927. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  112928. /** @hidden */
  112929. _emitFunction(name: string, code: string, comments: string): void;
  112930. /** @hidden */
  112931. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  112932. replaceStrings?: {
  112933. search: RegExp;
  112934. replace: string;
  112935. }[];
  112936. }): string;
  112937. /** @hidden */
  112938. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  112939. repeatKey?: string;
  112940. removeAttributes?: boolean;
  112941. removeUniforms?: boolean;
  112942. removeVaryings?: boolean;
  112943. removeIfDef?: boolean;
  112944. replaceStrings?: {
  112945. search: RegExp;
  112946. replace: string;
  112947. }[];
  112948. }): void;
  112949. /** @hidden */
  112950. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  112951. private _emitDefine;
  112952. /** @hidden */
  112953. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  112954. }
  112955. }
  112956. declare module BABYLON {
  112957. /**
  112958. * Root class for all node material optimizers
  112959. */
  112960. export class NodeMaterialOptimizer {
  112961. /**
  112962. * Function used to optimize a NodeMaterial graph
  112963. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  112964. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  112965. */
  112966. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  112967. }
  112968. }
  112969. declare module BABYLON {
  112970. /**
  112971. * Block used to transform a vector4 with a matrix
  112972. */
  112973. export class Vector4TransformBlock extends NodeMaterialBlock {
  112974. /**
  112975. * Defines the value to use to complement Vector3 to transform it to a Vector4
  112976. */
  112977. complementW: number;
  112978. /**
  112979. * Creates a new Vector4TransformBlock
  112980. * @param name defines the block name
  112981. */
  112982. constructor(name: string);
  112983. /**
  112984. * Gets the current class name
  112985. * @returns the class name
  112986. */
  112987. getClassName(): string;
  112988. /**
  112989. * Gets the vector input
  112990. */
  112991. readonly vector: NodeMaterialConnectionPoint;
  112992. /**
  112993. * Gets the matrix transform input
  112994. */
  112995. readonly transform: NodeMaterialConnectionPoint;
  112996. protected _buildBlock(state: NodeMaterialBuildState): this;
  112997. }
  112998. }
  112999. declare module BABYLON {
  113000. /**
  113001. * Block used to output the vertex position
  113002. */
  113003. export class VertexOutputBlock extends NodeMaterialBlock {
  113004. /**
  113005. * Creates a new VertexOutputBlock
  113006. * @param name defines the block name
  113007. */
  113008. constructor(name: string);
  113009. /**
  113010. * Gets the current class name
  113011. * @returns the class name
  113012. */
  113013. getClassName(): string;
  113014. /**
  113015. * Gets the vector input component
  113016. */
  113017. readonly vector: NodeMaterialConnectionPoint;
  113018. protected _buildBlock(state: NodeMaterialBuildState): this;
  113019. }
  113020. }
  113021. declare module BABYLON {
  113022. /**
  113023. * Block used to output the final color
  113024. */
  113025. export class FragmentOutputBlock extends NodeMaterialBlock {
  113026. /**
  113027. * Gets or sets a boolean indicating if this block will output an alpha value
  113028. */
  113029. alphaBlendingEnabled: boolean;
  113030. /**
  113031. * Create a new FragmentOutputBlock
  113032. * @param name defines the block name
  113033. */
  113034. constructor(name: string);
  113035. /**
  113036. * Gets the current class name
  113037. * @returns the class name
  113038. */
  113039. getClassName(): string;
  113040. /**
  113041. * Gets the color input component
  113042. */
  113043. readonly color: NodeMaterialConnectionPoint;
  113044. protected _buildBlock(state: NodeMaterialBuildState): this;
  113045. }
  113046. }
  113047. declare module BABYLON {
  113048. /**
  113049. * Interface used to configure the node material editor
  113050. */
  113051. export interface INodeMaterialEditorOptions {
  113052. /** Define the URl to load node editor script */
  113053. editorURL?: string;
  113054. }
  113055. /** @hidden */
  113056. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113057. /** BONES */
  113058. NUM_BONE_INFLUENCERS: number;
  113059. BonesPerMesh: number;
  113060. BONETEXTURE: boolean;
  113061. /** MORPH TARGETS */
  113062. MORPHTARGETS: boolean;
  113063. MORPHTARGETS_NORMAL: boolean;
  113064. MORPHTARGETS_TANGENT: boolean;
  113065. NUM_MORPH_INFLUENCERS: number;
  113066. /** IMAGE PROCESSING */
  113067. IMAGEPROCESSING: boolean;
  113068. VIGNETTE: boolean;
  113069. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113070. VIGNETTEBLENDMODEOPAQUE: boolean;
  113071. TONEMAPPING: boolean;
  113072. TONEMAPPING_ACES: boolean;
  113073. CONTRAST: boolean;
  113074. EXPOSURE: boolean;
  113075. COLORCURVES: boolean;
  113076. COLORGRADING: boolean;
  113077. COLORGRADING3D: boolean;
  113078. SAMPLER3DGREENDEPTH: boolean;
  113079. SAMPLER3DBGRMAP: boolean;
  113080. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113081. constructor();
  113082. setValue(name: string, value: boolean): void;
  113083. }
  113084. /**
  113085. * Class used to configure NodeMaterial
  113086. */
  113087. export interface INodeMaterialOptions {
  113088. /**
  113089. * Defines if blocks should emit comments
  113090. */
  113091. emitComments: boolean;
  113092. }
  113093. /**
  113094. * Class used to create a node based material built by assembling shader blocks
  113095. */
  113096. export class NodeMaterial extends PushMaterial {
  113097. private _options;
  113098. private _vertexCompilationState;
  113099. private _fragmentCompilationState;
  113100. private _sharedData;
  113101. private _buildId;
  113102. private _buildWasSuccessful;
  113103. private _cachedWorldViewMatrix;
  113104. private _cachedWorldViewProjectionMatrix;
  113105. private _textureConnectionPoints;
  113106. private _optimizers;
  113107. /** Define the URl to load node editor script */
  113108. static EditorURL: string;
  113109. private BJSNODEMATERIALEDITOR;
  113110. /** Get the inspector from bundle or global */
  113111. private _getGlobalNodeMaterialEditor;
  113112. /**
  113113. * Defines the maximum number of lights that can be used in the material
  113114. */
  113115. maxSimultaneousLights: number;
  113116. /**
  113117. * Observable raised when the material is built
  113118. */
  113119. onBuildObservable: Observable<NodeMaterial>;
  113120. /**
  113121. * Gets or sets the root nodes of the material vertex shader
  113122. */
  113123. _vertexOutputNodes: NodeMaterialBlock[];
  113124. /**
  113125. * Gets or sets the root nodes of the material fragment (pixel) shader
  113126. */
  113127. _fragmentOutputNodes: NodeMaterialBlock[];
  113128. /** Gets or sets options to control the node material overall behavior */
  113129. options: INodeMaterialOptions;
  113130. /**
  113131. * Default configuration related to image processing available in the standard Material.
  113132. */
  113133. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113134. /**
  113135. * Gets the image processing configuration used either in this material.
  113136. */
  113137. /**
  113138. * Sets the Default image processing configuration used either in the this material.
  113139. *
  113140. * If sets to null, the scene one is in use.
  113141. */
  113142. imageProcessingConfiguration: ImageProcessingConfiguration;
  113143. /**
  113144. * Create a new node based material
  113145. * @param name defines the material name
  113146. * @param scene defines the hosting scene
  113147. * @param options defines creation option
  113148. */
  113149. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113150. /**
  113151. * Gets the current class name of the material e.g. "NodeMaterial"
  113152. * @returns the class name
  113153. */
  113154. getClassName(): string;
  113155. /**
  113156. * Keep track of the image processing observer to allow dispose and replace.
  113157. */
  113158. private _imageProcessingObserver;
  113159. /**
  113160. * Attaches a new image processing configuration to the Standard Material.
  113161. * @param configuration
  113162. */
  113163. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113164. /**
  113165. * Adds a new optimizer to the list of optimizers
  113166. * @param optimizer defines the optimizers to add
  113167. * @returns the current material
  113168. */
  113169. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113170. /**
  113171. * Remove an optimizer from the list of optimizers
  113172. * @param optimizer defines the optimizers to remove
  113173. * @returns the current material
  113174. */
  113175. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113176. /**
  113177. * Add a new block to the list of output nodes
  113178. * @param node defines the node to add
  113179. * @returns the current material
  113180. */
  113181. addOutputNode(node: NodeMaterialBlock): this;
  113182. /**
  113183. * Remove a block from the list of root nodes
  113184. * @param node defines the node to remove
  113185. * @returns the current material
  113186. */
  113187. removeOutputNode(node: NodeMaterialBlock): this;
  113188. private _addVertexOutputNode;
  113189. private _removeVertexOutputNode;
  113190. private _addFragmentOutputNode;
  113191. private _removeFragmentOutputNode;
  113192. /**
  113193. * Specifies if the material will require alpha blending
  113194. * @returns a boolean specifying if alpha blending is needed
  113195. */
  113196. needAlphaBlending(): boolean;
  113197. /**
  113198. * Specifies if this material should be rendered in alpha test mode
  113199. * @returns a boolean specifying if an alpha test is needed.
  113200. */
  113201. needAlphaTesting(): boolean;
  113202. private _initializeBlock;
  113203. private _resetDualBlocks;
  113204. /**
  113205. * Build the material and generates the inner effect
  113206. * @param verbose defines if the build should log activity
  113207. */
  113208. build(verbose?: boolean): void;
  113209. /**
  113210. * Runs an otpimization phase to try to improve the shader code
  113211. */
  113212. optimize(): void;
  113213. private _prepareDefinesForAttributes;
  113214. /**
  113215. * Get if the submesh is ready to be used and all its information available.
  113216. * Child classes can use it to update shaders
  113217. * @param mesh defines the mesh to check
  113218. * @param subMesh defines which submesh to check
  113219. * @param useInstances specifies that instances should be used
  113220. * @returns a boolean indicating that the submesh is ready or not
  113221. */
  113222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113223. /**
  113224. * Binds the world matrix to the material
  113225. * @param world defines the world transformation matrix
  113226. */
  113227. bindOnlyWorldMatrix(world: Matrix): void;
  113228. /**
  113229. * Binds the submesh to this material by preparing the effect and shader to draw
  113230. * @param world defines the world transformation matrix
  113231. * @param mesh defines the mesh containing the submesh
  113232. * @param subMesh defines the submesh to bind the material to
  113233. */
  113234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113235. /**
  113236. * Gets the active textures from the material
  113237. * @returns an array of textures
  113238. */
  113239. getActiveTextures(): BaseTexture[];
  113240. /**
  113241. * Specifies if the material uses a texture
  113242. * @param texture defines the texture to check against the material
  113243. * @returns a boolean specifying if the material uses the texture
  113244. */
  113245. hasTexture(texture: BaseTexture): boolean;
  113246. /**
  113247. * Disposes the material
  113248. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113249. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113250. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113251. */
  113252. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113253. /** Creates the node editor window. */
  113254. private _createNodeEditor;
  113255. /**
  113256. * Launch the node material editor
  113257. * @param config Define the configuration of the editor
  113258. * @return a promise fulfilled when the node editor is visible
  113259. */
  113260. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113261. /**
  113262. * Clear the current material
  113263. */
  113264. clear(): void;
  113265. /**
  113266. * Clear the current material and set it to a default state
  113267. */
  113268. setToDefault(): void;
  113269. }
  113270. }
  113271. declare module BABYLON {
  113272. /**
  113273. * Defines a block that can be used inside a node based material
  113274. */
  113275. export class NodeMaterialBlock {
  113276. private _buildId;
  113277. private _target;
  113278. private _isFinalMerger;
  113279. /** @hidden */
  113280. _inputs: NodeMaterialConnectionPoint[];
  113281. /** @hidden */
  113282. _outputs: NodeMaterialConnectionPoint[];
  113283. /**
  113284. * Gets or sets the name of the block
  113285. */
  113286. name: string;
  113287. /**
  113288. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113289. */
  113290. readonly isFinalMerger: boolean;
  113291. /**
  113292. * Gets or sets the build Id
  113293. */
  113294. buildId: number;
  113295. /**
  113296. * Gets or sets the target of the block
  113297. */
  113298. target: NodeMaterialBlockTargets;
  113299. /**
  113300. * Gets the list of input points
  113301. */
  113302. readonly inputs: NodeMaterialConnectionPoint[];
  113303. /** Gets the list of output points */
  113304. readonly outputs: NodeMaterialConnectionPoint[];
  113305. /**
  113306. * Find an input by its name
  113307. * @param name defines the name of the input to look for
  113308. * @returns the input or null if not found
  113309. */
  113310. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113311. /**
  113312. * Find an output by its name
  113313. * @param name defines the name of the outputto look for
  113314. * @returns the output or null if not found
  113315. */
  113316. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113317. /**
  113318. * Creates a new NodeMaterialBlock
  113319. * @param name defines the block name
  113320. * @param target defines the target of that block (Vertex by default)
  113321. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113322. */
  113323. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113324. /**
  113325. * Initialize the block and prepare the context for build
  113326. * @param state defines the state that will be used for the build
  113327. */
  113328. initialize(state: NodeMaterialBuildState): void;
  113329. /**
  113330. * Bind data to effect. Will only be called for blocks with isBindable === true
  113331. * @param effect defines the effect to bind data to
  113332. * @param nodeMaterial defines the hosting NodeMaterial
  113333. * @param mesh defines the mesh that will be rendered
  113334. */
  113335. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113336. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113337. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113338. protected _writeFloat(value: number): string;
  113339. /**
  113340. * Gets the current class name e.g. "NodeMaterialBlock"
  113341. * @returns the class name
  113342. */
  113343. getClassName(): string;
  113344. /**
  113345. * Register a new input. Must be called inside a block constructor
  113346. * @param name defines the connection point name
  113347. * @param type defines the connection point type
  113348. * @param isOptional defines a boolean indicating that this input can be omitted
  113349. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113350. * @returns the current block
  113351. */
  113352. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113353. /**
  113354. * Register a new output. Must be called inside a block constructor
  113355. * @param name defines the connection point name
  113356. * @param type defines the connection point type
  113357. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113358. * @returns the current block
  113359. */
  113360. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113361. /**
  113362. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113363. * @param forOutput defines an optional connection point to check compatibility with
  113364. * @returns the first available input or null
  113365. */
  113366. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113367. /**
  113368. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113369. * @param forBlock defines an optional block to check compatibility with
  113370. * @returns the first available input or null
  113371. */
  113372. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113373. /**
  113374. * Connect current block with another block
  113375. * @param other defines the block to connect with
  113376. * @param options define the various options to help pick the right connections
  113377. * @returns the current block
  113378. */
  113379. connectTo(other: NodeMaterialBlock, options?: {
  113380. input?: string;
  113381. output?: string;
  113382. outputSwizzle?: string;
  113383. }): this | undefined;
  113384. protected _buildBlock(state: NodeMaterialBuildState): void;
  113385. /**
  113386. * Add potential fallbacks if shader compilation fails
  113387. * @param mesh defines the mesh to be rendered
  113388. * @param fallbacks defines the current prioritized list of fallbacks
  113389. */
  113390. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113391. /**
  113392. * Update defines for shader compilation
  113393. * @param mesh defines the mesh to be rendered
  113394. * @param nodeMaterial defines the node material requesting the update
  113395. * @param defines defines the material defines to update
  113396. * @param useInstances specifies that instances should be used
  113397. */
  113398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113399. /**
  113400. * Lets the block try to connect some inputs automatically
  113401. */
  113402. autoConfigure(): void;
  113403. /**
  113404. * Function called when a block is declared as repeatable content generator
  113405. * @param vertexShaderState defines the current compilation state for the vertex shader
  113406. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113407. * @param mesh defines the mesh to be rendered
  113408. * @param defines defines the material defines to update
  113409. */
  113410. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113411. /**
  113412. * Checks if the block is ready
  113413. * @param mesh defines the mesh to be rendered
  113414. * @param nodeMaterial defines the node material requesting the update
  113415. * @param defines defines the material defines to update
  113416. * @param useInstances specifies that instances should be used
  113417. * @returns true if the block is ready
  113418. */
  113419. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  113420. /**
  113421. * Compile the current node and generate the shader code
  113422. * @param state defines the current compilation state (uniforms, samplers, current string)
  113423. * @returns the current block
  113424. */
  113425. build(state: NodeMaterialBuildState): this | undefined;
  113426. }
  113427. }
  113428. declare module BABYLON {
  113429. /**
  113430. * Defines a connection point for a block
  113431. */
  113432. export class NodeMaterialConnectionPoint {
  113433. /** @hidden */
  113434. _ownerBlock: NodeMaterialBlock;
  113435. /** @hidden */
  113436. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113437. private _associatedVariableName;
  113438. private _endpoints;
  113439. private _storedValue;
  113440. private _valueCallback;
  113441. private _mode;
  113442. /** @hidden */
  113443. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113444. /** @hidden */
  113445. _needToEmitVarying: boolean;
  113446. /**
  113447. * Gets or sets the connection point type (default is float)
  113448. */
  113449. type: NodeMaterialBlockConnectionPointTypes;
  113450. /**
  113451. * Gets or sets the connection point name
  113452. */
  113453. name: string;
  113454. /**
  113455. * Gets or sets the swizzle to apply to this connection point when reading or writing
  113456. */
  113457. swizzle: string;
  113458. /**
  113459. * Gets or sets a boolean indicating that this connection point can be omitted
  113460. */
  113461. isOptional: boolean;
  113462. /**
  113463. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  113464. */
  113465. define: string;
  113466. /** Gets or sets the target of that connection point */
  113467. target: NodeMaterialBlockTargets;
  113468. /**
  113469. * Gets or sets the value of that point.
  113470. * Please note that this value will be ignored if valueCallback is defined
  113471. */
  113472. value: any;
  113473. /**
  113474. * Gets or sets a callback used to get the value of that point.
  113475. * Please note that setting this value will force the connection point to ignore the value property
  113476. */
  113477. valueCallback: () => any;
  113478. /**
  113479. * Gets or sets the associated variable name in the shader
  113480. */
  113481. associatedVariableName: string;
  113482. /**
  113483. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  113484. * In this case the connection point name must be the name of the uniform to use.
  113485. * Can only be set on inputs
  113486. */
  113487. isUniform: boolean;
  113488. /**
  113489. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  113490. * In this case the connection point name must be the name of the attribute to use
  113491. * Can only be set on inputs
  113492. */
  113493. isAttribute: boolean;
  113494. /**
  113495. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  113496. * Can only be set on exit points
  113497. */
  113498. isVarying: boolean;
  113499. /** Get the other side of the connection (if any) */
  113500. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  113501. /** Get the block that owns this connection point */
  113502. readonly ownerBlock: NodeMaterialBlock;
  113503. /** Get the block connected on the other side of this connection (if any) */
  113504. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  113505. /** Get the block connected on the endpoints of this connection (if any) */
  113506. readonly connectedBlocks: Array<NodeMaterialBlock>;
  113507. /**
  113508. * Creates a new connection point
  113509. * @param name defines the connection point name
  113510. * @param ownerBlock defines the block hosting this connection point
  113511. */
  113512. constructor(name: string, ownerBlock: NodeMaterialBlock);
  113513. /**
  113514. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  113515. * @returns the class name
  113516. */
  113517. getClassName(): string;
  113518. /**
  113519. * Set the source of this connection point to a vertex attribute
  113520. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  113521. * @returns the current connection point
  113522. */
  113523. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  113524. /**
  113525. * Set the source of this connection point to a well known value
  113526. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  113527. * @returns the current connection point
  113528. */
  113529. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  113530. /**
  113531. * Gets a boolean indicating that the current connection point is a well known value
  113532. */
  113533. readonly isWellKnownValue: boolean;
  113534. /**
  113535. * Gets or sets the current well known value or null if not defined as well know value
  113536. */
  113537. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  113538. private _getTypeLength;
  113539. /**
  113540. * Connect this point to another connection point
  113541. * @param connectionPoint defines the other connection point
  113542. * @returns the current connection point
  113543. */
  113544. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113545. /**
  113546. * Disconnect this point from one of his endpoint
  113547. * @param endpoint defines the other connection point
  113548. * @returns the current connection point
  113549. */
  113550. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  113551. /**
  113552. * When connection point is an uniform, this function will send its value to the effect
  113553. * @param effect defines the effect to transmit value to
  113554. * @param world defines the world matrix
  113555. * @param worldView defines the worldxview matrix
  113556. * @param worldViewProjection defines the worldxviewxprojection matrix
  113557. */
  113558. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  113559. /**
  113560. * When connection point is an uniform, this function will send its value to the effect
  113561. * @param effect defines the effect to transmit value to
  113562. * @param scene defines the hosting scene
  113563. */
  113564. transmit(effect: Effect, scene: Scene): void;
  113565. }
  113566. }
  113567. declare module BABYLON {
  113568. /**
  113569. * Block used to add support for vertex skinning (bones)
  113570. */
  113571. export class BonesBlock extends NodeMaterialBlock {
  113572. /**
  113573. * Creates a new BonesBlock
  113574. * @param name defines the block name
  113575. */
  113576. constructor(name: string);
  113577. /**
  113578. * Initialize the block and prepare the context for build
  113579. * @param state defines the state that will be used for the build
  113580. */
  113581. initialize(state: NodeMaterialBuildState): void;
  113582. /**
  113583. * Gets the current class name
  113584. * @returns the class name
  113585. */
  113586. getClassName(): string;
  113587. /**
  113588. * Gets the matrix indices input component
  113589. */
  113590. readonly matricesIndices: NodeMaterialConnectionPoint;
  113591. /**
  113592. * Gets the matrix weights input component
  113593. */
  113594. readonly matricesWeights: NodeMaterialConnectionPoint;
  113595. /**
  113596. * Gets the extra matrix indices input component
  113597. */
  113598. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  113599. /**
  113600. * Gets the extra matrix weights input component
  113601. */
  113602. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  113603. /**
  113604. * Gets the world input component
  113605. */
  113606. readonly world: NodeMaterialConnectionPoint;
  113607. autoConfigure(): void;
  113608. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113609. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113610. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113611. protected _buildBlock(state: NodeMaterialBuildState): this;
  113612. }
  113613. }
  113614. declare module BABYLON {
  113615. /**
  113616. * Block used to add support for instances
  113617. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113618. */
  113619. export class InstancesBlock extends NodeMaterialBlock {
  113620. /**
  113621. * Creates a new InstancesBlock
  113622. * @param name defines the block name
  113623. */
  113624. constructor(name: string);
  113625. /**
  113626. * Gets the current class name
  113627. * @returns the class name
  113628. */
  113629. getClassName(): string;
  113630. /**
  113631. * Gets the first world row input component
  113632. */
  113633. readonly world0: NodeMaterialConnectionPoint;
  113634. /**
  113635. * Gets the second world row input component
  113636. */
  113637. readonly world1: NodeMaterialConnectionPoint;
  113638. /**
  113639. * Gets the third world row input component
  113640. */
  113641. readonly world2: NodeMaterialConnectionPoint;
  113642. /**
  113643. * Gets the forth world row input component
  113644. */
  113645. readonly world3: NodeMaterialConnectionPoint;
  113646. /**
  113647. * Gets the world input component
  113648. */
  113649. readonly world: NodeMaterialConnectionPoint;
  113650. /**
  113651. * Gets the output component
  113652. */
  113653. readonly output: NodeMaterialConnectionPoint;
  113654. autoConfigure(): void;
  113655. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113656. protected _buildBlock(state: NodeMaterialBuildState): this;
  113657. }
  113658. }
  113659. declare module BABYLON {
  113660. /**
  113661. * Block used to add morph targets support to vertex shader
  113662. */
  113663. export class MorphTargetsBlock extends NodeMaterialBlock {
  113664. private _repeatableContentAnchor;
  113665. private _repeatebleContentGenerated;
  113666. /**
  113667. * Create a new MorphTargetsBlock
  113668. * @param name defines the block name
  113669. */
  113670. constructor(name: string);
  113671. /**
  113672. * Gets the current class name
  113673. * @returns the class name
  113674. */
  113675. getClassName(): string;
  113676. /**
  113677. * Gets the position input component
  113678. */
  113679. readonly position: NodeMaterialConnectionPoint;
  113680. /**
  113681. * Gets the normal input component
  113682. */
  113683. readonly normal: NodeMaterialConnectionPoint;
  113684. /**
  113685. * Gets the tangent input component
  113686. */
  113687. readonly tangent: NodeMaterialConnectionPoint;
  113688. /**
  113689. * Gets the position output component
  113690. */
  113691. readonly positionOutput: NodeMaterialConnectionPoint;
  113692. /**
  113693. * Gets the normal output component
  113694. */
  113695. readonly normalOutput: NodeMaterialConnectionPoint;
  113696. /**
  113697. * Gets the tangent output component
  113698. */
  113699. readonly tangentOutput: NodeMaterialConnectionPoint;
  113700. initialize(state: NodeMaterialBuildState): void;
  113701. autoConfigure(): void;
  113702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113704. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113705. protected _buildBlock(state: NodeMaterialBuildState): this;
  113706. }
  113707. }
  113708. declare module BABYLON {
  113709. /**
  113710. * Block used to add an alpha test in the fragment shader
  113711. */
  113712. export class AlphaTestBlock extends NodeMaterialBlock {
  113713. /**
  113714. * Gets or sets the alpha value where alpha testing happens
  113715. */
  113716. alphaCutOff: number;
  113717. /**
  113718. * Create a new AlphaTestBlock
  113719. * @param name defines the block name
  113720. */
  113721. constructor(name: string);
  113722. /**
  113723. * Gets the current class name
  113724. * @returns the class name
  113725. */
  113726. getClassName(): string;
  113727. /**
  113728. * Gets the color input component
  113729. */
  113730. readonly color: NodeMaterialConnectionPoint;
  113731. protected _buildBlock(state: NodeMaterialBuildState): this;
  113732. }
  113733. }
  113734. declare module BABYLON {
  113735. /**
  113736. * Block used to create a Color4 out of 4 inputs (one for each component)
  113737. */
  113738. export class RGBAMergerBlock extends NodeMaterialBlock {
  113739. /**
  113740. * Create a new RGBAMergerBlock
  113741. * @param name defines the block name
  113742. */
  113743. constructor(name: string);
  113744. /**
  113745. * Gets the current class name
  113746. * @returns the class name
  113747. */
  113748. getClassName(): string;
  113749. /**
  113750. * Gets the R input component
  113751. */
  113752. readonly r: NodeMaterialConnectionPoint;
  113753. /**
  113754. * Gets the G input component
  113755. */
  113756. readonly g: NodeMaterialConnectionPoint;
  113757. /**
  113758. * Gets the B input component
  113759. */
  113760. readonly b: NodeMaterialConnectionPoint;
  113761. /**
  113762. * Gets the RGB input component
  113763. */
  113764. readonly rgb: NodeMaterialConnectionPoint;
  113765. /**
  113766. * Gets the R input component
  113767. */
  113768. readonly a: NodeMaterialConnectionPoint;
  113769. protected _buildBlock(state: NodeMaterialBuildState): this;
  113770. }
  113771. }
  113772. declare module BABYLON {
  113773. /**
  113774. * Block used to create a Color3 out of 3 inputs (one for each component)
  113775. */
  113776. export class RGBMergerBlock extends NodeMaterialBlock {
  113777. /**
  113778. * Create a new RGBMergerBlock
  113779. * @param name defines the block name
  113780. */
  113781. constructor(name: string);
  113782. /**
  113783. * Gets the current class name
  113784. * @returns the class name
  113785. */
  113786. getClassName(): string;
  113787. /**
  113788. * Gets the R component input
  113789. */
  113790. readonly r: NodeMaterialConnectionPoint;
  113791. /**
  113792. * Gets the G component input
  113793. */
  113794. readonly g: NodeMaterialConnectionPoint;
  113795. /**
  113796. * Gets the B component input
  113797. */
  113798. readonly b: NodeMaterialConnectionPoint;
  113799. protected _buildBlock(state: NodeMaterialBuildState): this;
  113800. }
  113801. }
  113802. declare module BABYLON {
  113803. /**
  113804. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  113805. */
  113806. export class RGBASplitterBlock extends NodeMaterialBlock {
  113807. /**
  113808. * Create a new RGBASplitterBlock
  113809. * @param name defines the block name
  113810. */
  113811. constructor(name: string);
  113812. /**
  113813. * Gets the current class name
  113814. * @returns the class name
  113815. */
  113816. getClassName(): string;
  113817. /**
  113818. * Gets the input component
  113819. */
  113820. readonly input: NodeMaterialConnectionPoint;
  113821. protected _buildBlock(state: NodeMaterialBuildState): this;
  113822. }
  113823. }
  113824. declare module BABYLON {
  113825. /**
  113826. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  113827. */
  113828. export class RGBSplitterBlock extends NodeMaterialBlock {
  113829. /**
  113830. * Create a new RGBSplitterBlock
  113831. * @param name defines the block name
  113832. */
  113833. constructor(name: string);
  113834. /**
  113835. * Gets the current class name
  113836. * @returns the class name
  113837. */
  113838. getClassName(): string;
  113839. /**
  113840. * Gets the input component
  113841. */
  113842. readonly input: NodeMaterialConnectionPoint;
  113843. protected _buildBlock(state: NodeMaterialBuildState): this;
  113844. }
  113845. }
  113846. declare module BABYLON {
  113847. /**
  113848. * Block used to read a texture from a sampler
  113849. */
  113850. export class TextureBlock extends NodeMaterialBlock {
  113851. private _defineName;
  113852. /**
  113853. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  113854. */
  113855. autoConnectTextureMatrix: boolean;
  113856. /**
  113857. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  113858. */
  113859. autoSelectUV: boolean;
  113860. /**
  113861. * Create a new TextureBlock
  113862. * @param name defines the block name
  113863. */
  113864. constructor(name: string);
  113865. /**
  113866. * Gets the current class name
  113867. * @returns the class name
  113868. */
  113869. getClassName(): string;
  113870. /**
  113871. * Gets the uv input component
  113872. */
  113873. readonly uv: NodeMaterialConnectionPoint;
  113874. /**
  113875. * Gets the texture information input component
  113876. */
  113877. readonly textureInfo: NodeMaterialConnectionPoint;
  113878. /**
  113879. * Gets the transformed uv input component
  113880. */
  113881. readonly transformedUV: NodeMaterialConnectionPoint;
  113882. /**
  113883. * Gets the texture input component
  113884. */
  113885. readonly texture: NodeMaterialConnectionPoint;
  113886. /**
  113887. * Gets the texture transform input component
  113888. */
  113889. readonly textureTransform: NodeMaterialConnectionPoint;
  113890. autoConfigure(): void;
  113891. initialize(state: NodeMaterialBuildState): void;
  113892. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113893. isReady(): boolean;
  113894. private _injectVertexCode;
  113895. protected _buildBlock(state: NodeMaterialBuildState): this;
  113896. }
  113897. }
  113898. declare module BABYLON {
  113899. /**
  113900. * Block used to add image processing support to fragment shader
  113901. */
  113902. export class ImageProcessingBlock extends NodeMaterialBlock {
  113903. /**
  113904. * Create a new ImageProcessingBlock
  113905. * @param name defines the block name
  113906. */
  113907. constructor(name: string);
  113908. /**
  113909. * Gets the current class name
  113910. * @returns the class name
  113911. */
  113912. getClassName(): string;
  113913. /**
  113914. * Gets the color input component
  113915. */
  113916. readonly color: NodeMaterialConnectionPoint;
  113917. /**
  113918. * Initialize the block and prepare the context for build
  113919. * @param state defines the state that will be used for the build
  113920. */
  113921. initialize(state: NodeMaterialBuildState): void;
  113922. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  113923. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113925. protected _buildBlock(state: NodeMaterialBuildState): this;
  113926. }
  113927. }
  113928. declare module BABYLON {
  113929. /**
  113930. * Block used to add support for scene fog
  113931. */
  113932. export class FogBlock extends NodeMaterialBlock {
  113933. /**
  113934. * Create a new FogBlock
  113935. * @param name defines the block name
  113936. */
  113937. constructor(name: string);
  113938. /**
  113939. * Gets the current class name
  113940. * @returns the class name
  113941. */
  113942. getClassName(): string;
  113943. /**
  113944. * Gets the world position input component
  113945. */
  113946. readonly worldPosition: NodeMaterialConnectionPoint;
  113947. /**
  113948. * Gets the view input component
  113949. */
  113950. readonly view: NodeMaterialConnectionPoint;
  113951. /**
  113952. * Gets the color input component
  113953. */
  113954. readonly color: NodeMaterialConnectionPoint;
  113955. /**
  113956. * Gets the fog color input component
  113957. */
  113958. readonly fogColor: NodeMaterialConnectionPoint;
  113959. /**
  113960. * Gets the for parameter input component
  113961. */
  113962. readonly fogParameters: NodeMaterialConnectionPoint;
  113963. autoConfigure(): void;
  113964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113966. protected _buildBlock(state: NodeMaterialBuildState): this;
  113967. }
  113968. }
  113969. declare module BABYLON {
  113970. /**
  113971. * Block used to multiply 2 vector4
  113972. */
  113973. export class MultiplyBlock extends NodeMaterialBlock {
  113974. /**
  113975. * Creates a new MultiplyBlock
  113976. * @param name defines the block name
  113977. */
  113978. constructor(name: string);
  113979. /**
  113980. * Gets the current class name
  113981. * @returns the class name
  113982. */
  113983. getClassName(): string;
  113984. /**
  113985. * Gets the left operand input component
  113986. */
  113987. readonly left: NodeMaterialConnectionPoint;
  113988. /**
  113989. * Gets the right operand input component
  113990. */
  113991. readonly right: NodeMaterialConnectionPoint;
  113992. protected _buildBlock(state: NodeMaterialBuildState): this;
  113993. }
  113994. }
  113995. declare module BABYLON {
  113996. /**
  113997. * Block used to add 2 vector4
  113998. */
  113999. export class AddBlock extends NodeMaterialBlock {
  114000. /**
  114001. * Creates a new AddBlock
  114002. * @param name defines the block name
  114003. */
  114004. constructor(name: string);
  114005. /**
  114006. * Gets the current class name
  114007. * @returns the class name
  114008. */
  114009. getClassName(): string;
  114010. /**
  114011. * Gets the left operand input component
  114012. */
  114013. readonly left: NodeMaterialConnectionPoint;
  114014. /**
  114015. * Gets the right operand input component
  114016. */
  114017. readonly right: NodeMaterialConnectionPoint;
  114018. protected _buildBlock(state: NodeMaterialBuildState): this;
  114019. }
  114020. }
  114021. declare module BABYLON {
  114022. /**
  114023. * Block used to clamp a float
  114024. */
  114025. export class ClampBlock extends NodeMaterialBlock {
  114026. /** Gets or sets the minimum range */
  114027. minimum: number;
  114028. /** Gets or sets the maximum range */
  114029. maximum: number;
  114030. /**
  114031. * Creates a new ClampBlock
  114032. * @param name defines the block name
  114033. */
  114034. constructor(name: string);
  114035. /**
  114036. * Gets the current class name
  114037. * @returns the class name
  114038. */
  114039. getClassName(): string;
  114040. /**
  114041. * Gets the value input component
  114042. */
  114043. readonly value: NodeMaterialConnectionPoint;
  114044. protected _buildBlock(state: NodeMaterialBuildState): this;
  114045. }
  114046. }
  114047. declare module BABYLON {
  114048. /**
  114049. * Block used to transform a vector2 with a matrix
  114050. */
  114051. export class Vector2TransformBlock extends NodeMaterialBlock {
  114052. /**
  114053. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114054. */
  114055. complementZ: number;
  114056. /**
  114057. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114058. */
  114059. complementW: number;
  114060. /**
  114061. * Creates a new Vector2TransformBlock
  114062. * @param name defines the block name
  114063. */
  114064. constructor(name: string);
  114065. /**
  114066. * Gets the vector input
  114067. */
  114068. readonly vector: NodeMaterialConnectionPoint;
  114069. /**
  114070. * Gets the matrix transform input
  114071. */
  114072. readonly transform: NodeMaterialConnectionPoint;
  114073. /**
  114074. * Gets the current class name
  114075. * @returns the class name
  114076. */
  114077. getClassName(): string;
  114078. protected _buildBlock(state: NodeMaterialBuildState): this;
  114079. }
  114080. }
  114081. declare module BABYLON {
  114082. /**
  114083. * Block used to transform a vector3 with a matrix
  114084. */
  114085. export class Vector3TransformBlock extends NodeMaterialBlock {
  114086. /**
  114087. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114088. */
  114089. complement: number;
  114090. /**
  114091. * Creates a new Vector3TransformBlock
  114092. * @param name defines the block name
  114093. */
  114094. constructor(name: string);
  114095. /**
  114096. * Gets the vector input
  114097. */
  114098. readonly vector: NodeMaterialConnectionPoint;
  114099. /**
  114100. * Gets the matrix transform input
  114101. */
  114102. readonly transform: NodeMaterialConnectionPoint;
  114103. /**
  114104. * Gets the current class name
  114105. * @returns the class name
  114106. */
  114107. getClassName(): string;
  114108. protected _buildBlock(state: NodeMaterialBuildState): this;
  114109. }
  114110. }
  114111. declare module BABYLON {
  114112. /**
  114113. * Block used to multiply two matrices
  114114. */
  114115. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  114116. /**
  114117. * Creates a new MatrixMultiplicationBlock
  114118. * @param name defines the block name
  114119. */
  114120. constructor(name: string);
  114121. /**
  114122. * Gets the left operand
  114123. */
  114124. readonly left: NodeMaterialConnectionPoint;
  114125. /**
  114126. * Gets the right operand
  114127. */
  114128. readonly right: NodeMaterialConnectionPoint;
  114129. /**
  114130. * Gets the current class name
  114131. * @returns the class name
  114132. */
  114133. getClassName(): string;
  114134. protected _buildBlock(state: NodeMaterialBuildState): this;
  114135. }
  114136. }
  114137. declare module BABYLON {
  114138. /**
  114139. * Helper class to push actions to a pool of workers.
  114140. */
  114141. export class WorkerPool implements IDisposable {
  114142. private _workerInfos;
  114143. private _pendingActions;
  114144. /**
  114145. * Constructor
  114146. * @param workers Array of workers to use for actions
  114147. */
  114148. constructor(workers: Array<Worker>);
  114149. /**
  114150. * Terminates all workers and clears any pending actions.
  114151. */
  114152. dispose(): void;
  114153. /**
  114154. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114155. * pended until a worker has completed its action.
  114156. * @param action The action to perform. Call onComplete when the action is complete.
  114157. */
  114158. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114159. private _execute;
  114160. }
  114161. }
  114162. declare module BABYLON {
  114163. /**
  114164. * Configuration for Draco compression
  114165. */
  114166. export interface IDracoCompressionConfiguration {
  114167. /**
  114168. * Configuration for the decoder.
  114169. */
  114170. decoder: {
  114171. /**
  114172. * The url to the WebAssembly module.
  114173. */
  114174. wasmUrl?: string;
  114175. /**
  114176. * The url to the WebAssembly binary.
  114177. */
  114178. wasmBinaryUrl?: string;
  114179. /**
  114180. * The url to the fallback JavaScript module.
  114181. */
  114182. fallbackUrl?: string;
  114183. };
  114184. }
  114185. /**
  114186. * Draco compression (https://google.github.io/draco/)
  114187. *
  114188. * This class wraps the Draco module.
  114189. *
  114190. * **Encoder**
  114191. *
  114192. * The encoder is not currently implemented.
  114193. *
  114194. * **Decoder**
  114195. *
  114196. * 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.
  114197. *
  114198. * To update the configuration, use the following code:
  114199. * ```javascript
  114200. * DracoCompression.Configuration = {
  114201. * decoder: {
  114202. * wasmUrl: "<url to the WebAssembly library>",
  114203. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114204. * fallbackUrl: "<url to the fallback JavaScript library>",
  114205. * }
  114206. * };
  114207. * ```
  114208. *
  114209. * 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.
  114210. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114211. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114212. *
  114213. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114214. * ```javascript
  114215. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114216. * ```
  114217. *
  114218. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114219. */
  114220. export class DracoCompression implements IDisposable {
  114221. private _workerPoolPromise?;
  114222. private _decoderModulePromise?;
  114223. /**
  114224. * The configuration. Defaults to the following urls:
  114225. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114226. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114227. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114228. */
  114229. static Configuration: IDracoCompressionConfiguration;
  114230. /**
  114231. * Returns true if the decoder configuration is available.
  114232. */
  114233. static readonly DecoderAvailable: boolean;
  114234. /**
  114235. * Default number of workers to create when creating the draco compression object.
  114236. */
  114237. static DefaultNumWorkers: number;
  114238. private static GetDefaultNumWorkers;
  114239. private static _Default;
  114240. /**
  114241. * Default instance for the draco compression object.
  114242. */
  114243. static readonly Default: DracoCompression;
  114244. /**
  114245. * Constructor
  114246. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114247. */
  114248. constructor(numWorkers?: number);
  114249. /**
  114250. * Stop all async operations and release resources.
  114251. */
  114252. dispose(): void;
  114253. /**
  114254. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  114255. * @returns a promise that resolves when ready
  114256. */
  114257. whenReadyAsync(): Promise<void>;
  114258. /**
  114259. * Decode Draco compressed mesh data to vertex data.
  114260. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  114261. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  114262. * @returns A promise that resolves with the decoded vertex data
  114263. */
  114264. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  114265. [kind: string]: number;
  114266. }): Promise<VertexData>;
  114267. }
  114268. }
  114269. declare module BABYLON {
  114270. /**
  114271. * Class for building Constructive Solid Geometry
  114272. */
  114273. export class CSG {
  114274. private polygons;
  114275. /**
  114276. * The world matrix
  114277. */
  114278. matrix: Matrix;
  114279. /**
  114280. * Stores the position
  114281. */
  114282. position: Vector3;
  114283. /**
  114284. * Stores the rotation
  114285. */
  114286. rotation: Vector3;
  114287. /**
  114288. * Stores the rotation quaternion
  114289. */
  114290. rotationQuaternion: Nullable<Quaternion>;
  114291. /**
  114292. * Stores the scaling vector
  114293. */
  114294. scaling: Vector3;
  114295. /**
  114296. * Convert the Mesh to CSG
  114297. * @param mesh The Mesh to convert to CSG
  114298. * @returns A new CSG from the Mesh
  114299. */
  114300. static FromMesh(mesh: Mesh): CSG;
  114301. /**
  114302. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  114303. * @param polygons Polygons used to construct a CSG solid
  114304. */
  114305. private static FromPolygons;
  114306. /**
  114307. * Clones, or makes a deep copy, of the CSG
  114308. * @returns A new CSG
  114309. */
  114310. clone(): CSG;
  114311. /**
  114312. * Unions this CSG with another CSG
  114313. * @param csg The CSG to union against this CSG
  114314. * @returns The unioned CSG
  114315. */
  114316. union(csg: CSG): CSG;
  114317. /**
  114318. * Unions this CSG with another CSG in place
  114319. * @param csg The CSG to union against this CSG
  114320. */
  114321. unionInPlace(csg: CSG): void;
  114322. /**
  114323. * Subtracts this CSG with another CSG
  114324. * @param csg The CSG to subtract against this CSG
  114325. * @returns A new CSG
  114326. */
  114327. subtract(csg: CSG): CSG;
  114328. /**
  114329. * Subtracts this CSG with another CSG in place
  114330. * @param csg The CSG to subtact against this CSG
  114331. */
  114332. subtractInPlace(csg: CSG): void;
  114333. /**
  114334. * Intersect this CSG with another CSG
  114335. * @param csg The CSG to intersect against this CSG
  114336. * @returns A new CSG
  114337. */
  114338. intersect(csg: CSG): CSG;
  114339. /**
  114340. * Intersects this CSG with another CSG in place
  114341. * @param csg The CSG to intersect against this CSG
  114342. */
  114343. intersectInPlace(csg: CSG): void;
  114344. /**
  114345. * Return a new CSG solid with solid and empty space switched. This solid is
  114346. * not modified.
  114347. * @returns A new CSG solid with solid and empty space switched
  114348. */
  114349. inverse(): CSG;
  114350. /**
  114351. * Inverses the CSG in place
  114352. */
  114353. inverseInPlace(): void;
  114354. /**
  114355. * This is used to keep meshes transformations so they can be restored
  114356. * when we build back a Babylon Mesh
  114357. * NB : All CSG operations are performed in world coordinates
  114358. * @param csg The CSG to copy the transform attributes from
  114359. * @returns This CSG
  114360. */
  114361. copyTransformAttributes(csg: CSG): CSG;
  114362. /**
  114363. * Build Raw mesh from CSG
  114364. * Coordinates here are in world space
  114365. * @param name The name of the mesh geometry
  114366. * @param scene The Scene
  114367. * @param keepSubMeshes Specifies if the submeshes should be kept
  114368. * @returns A new Mesh
  114369. */
  114370. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  114371. /**
  114372. * Build Mesh from CSG taking material and transforms into account
  114373. * @param name The name of the Mesh
  114374. * @param material The material of the Mesh
  114375. * @param scene The Scene
  114376. * @param keepSubMeshes Specifies if submeshes should be kept
  114377. * @returns The new Mesh
  114378. */
  114379. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  114380. }
  114381. }
  114382. declare module BABYLON {
  114383. /**
  114384. * Class used to create a trail following a mesh
  114385. */
  114386. export class TrailMesh extends Mesh {
  114387. private _generator;
  114388. private _autoStart;
  114389. private _running;
  114390. private _diameter;
  114391. private _length;
  114392. private _sectionPolygonPointsCount;
  114393. private _sectionVectors;
  114394. private _sectionNormalVectors;
  114395. private _beforeRenderObserver;
  114396. /**
  114397. * @constructor
  114398. * @param name The value used by scene.getMeshByName() to do a lookup.
  114399. * @param generator The mesh to generate a trail.
  114400. * @param scene The scene to add this mesh to.
  114401. * @param diameter Diameter of trailing mesh. Default is 1.
  114402. * @param length Length of trailing mesh. Default is 60.
  114403. * @param autoStart Automatically start trailing mesh. Default true.
  114404. */
  114405. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  114406. /**
  114407. * "TrailMesh"
  114408. * @returns "TrailMesh"
  114409. */
  114410. getClassName(): string;
  114411. private _createMesh;
  114412. /**
  114413. * Start trailing mesh.
  114414. */
  114415. start(): void;
  114416. /**
  114417. * Stop trailing mesh.
  114418. */
  114419. stop(): void;
  114420. /**
  114421. * Update trailing mesh geometry.
  114422. */
  114423. update(): void;
  114424. /**
  114425. * Returns a new TrailMesh object.
  114426. * @param name is a string, the name given to the new mesh
  114427. * @param newGenerator use new generator object for cloned trail mesh
  114428. * @returns a new mesh
  114429. */
  114430. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  114431. /**
  114432. * Serializes this trail mesh
  114433. * @param serializationObject object to write serialization to
  114434. */
  114435. serialize(serializationObject: any): void;
  114436. /**
  114437. * Parses a serialized trail mesh
  114438. * @param parsedMesh the serialized mesh
  114439. * @param scene the scene to create the trail mesh in
  114440. * @returns the created trail mesh
  114441. */
  114442. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  114443. }
  114444. }
  114445. declare module BABYLON {
  114446. /**
  114447. * Class containing static functions to help procedurally build meshes
  114448. */
  114449. export class TiledBoxBuilder {
  114450. /**
  114451. * Creates a box mesh
  114452. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  114453. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114457. * @param name defines the name of the mesh
  114458. * @param options defines the options used to create the mesh
  114459. * @param scene defines the hosting scene
  114460. * @returns the box mesh
  114461. */
  114462. static CreateTiledBox(name: string, options: {
  114463. pattern?: number;
  114464. width?: number;
  114465. height?: number;
  114466. depth?: number;
  114467. tileSize?: number;
  114468. tileWidth?: number;
  114469. tileHeight?: number;
  114470. alignHorizontal?: number;
  114471. alignVertical?: number;
  114472. faceUV?: Vector4[];
  114473. faceColors?: Color4[];
  114474. sideOrientation?: number;
  114475. updatable?: boolean;
  114476. }, scene?: Nullable<Scene>): Mesh;
  114477. }
  114478. }
  114479. declare module BABYLON {
  114480. /**
  114481. * Class containing static functions to help procedurally build meshes
  114482. */
  114483. export class TorusKnotBuilder {
  114484. /**
  114485. * Creates a torus knot mesh
  114486. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114487. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114488. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114489. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114490. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114493. * @param name defines the name of the mesh
  114494. * @param options defines the options used to create the mesh
  114495. * @param scene defines the hosting scene
  114496. * @returns the torus knot mesh
  114497. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114498. */
  114499. static CreateTorusKnot(name: string, options: {
  114500. radius?: number;
  114501. tube?: number;
  114502. radialSegments?: number;
  114503. tubularSegments?: number;
  114504. p?: number;
  114505. q?: number;
  114506. updatable?: boolean;
  114507. sideOrientation?: number;
  114508. frontUVs?: Vector4;
  114509. backUVs?: Vector4;
  114510. }, scene: any): Mesh;
  114511. }
  114512. }
  114513. declare module BABYLON {
  114514. /**
  114515. * Polygon
  114516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114517. */
  114518. export class Polygon {
  114519. /**
  114520. * Creates a rectangle
  114521. * @param xmin bottom X coord
  114522. * @param ymin bottom Y coord
  114523. * @param xmax top X coord
  114524. * @param ymax top Y coord
  114525. * @returns points that make the resulting rectation
  114526. */
  114527. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  114528. /**
  114529. * Creates a circle
  114530. * @param radius radius of circle
  114531. * @param cx scale in x
  114532. * @param cy scale in y
  114533. * @param numberOfSides number of sides that make up the circle
  114534. * @returns points that make the resulting circle
  114535. */
  114536. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  114537. /**
  114538. * Creates a polygon from input string
  114539. * @param input Input polygon data
  114540. * @returns the parsed points
  114541. */
  114542. static Parse(input: string): Vector2[];
  114543. /**
  114544. * Starts building a polygon from x and y coordinates
  114545. * @param x x coordinate
  114546. * @param y y coordinate
  114547. * @returns the started path2
  114548. */
  114549. static StartingAt(x: number, y: number): Path2;
  114550. }
  114551. /**
  114552. * Builds a polygon
  114553. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114554. */
  114555. export class PolygonMeshBuilder {
  114556. private _points;
  114557. private _outlinepoints;
  114558. private _holes;
  114559. private _name;
  114560. private _scene;
  114561. private _epoints;
  114562. private _eholes;
  114563. private _addToepoint;
  114564. /**
  114565. * Babylon reference to the earcut plugin.
  114566. */
  114567. bjsEarcut: any;
  114568. /**
  114569. * Creates a PolygonMeshBuilder
  114570. * @param name name of the builder
  114571. * @param contours Path of the polygon
  114572. * @param scene scene to add to when creating the mesh
  114573. * @param earcutInjection can be used to inject your own earcut reference
  114574. */
  114575. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  114576. /**
  114577. * Adds a whole within the polygon
  114578. * @param hole Array of points defining the hole
  114579. * @returns this
  114580. */
  114581. addHole(hole: Vector2[]): PolygonMeshBuilder;
  114582. /**
  114583. * Creates the polygon
  114584. * @param updatable If the mesh should be updatable
  114585. * @param depth The depth of the mesh created
  114586. * @returns the created mesh
  114587. */
  114588. build(updatable?: boolean, depth?: number): Mesh;
  114589. /**
  114590. * Creates the polygon
  114591. * @param depth The depth of the mesh created
  114592. * @returns the created VertexData
  114593. */
  114594. buildVertexData(depth?: number): VertexData;
  114595. /**
  114596. * Adds a side to the polygon
  114597. * @param positions points that make the polygon
  114598. * @param normals normals of the polygon
  114599. * @param uvs uvs of the polygon
  114600. * @param indices indices of the polygon
  114601. * @param bounds bounds of the polygon
  114602. * @param points points of the polygon
  114603. * @param depth depth of the polygon
  114604. * @param flip flip of the polygon
  114605. */
  114606. private addSide;
  114607. }
  114608. }
  114609. declare module BABYLON {
  114610. /**
  114611. * Class containing static functions to help procedurally build meshes
  114612. */
  114613. export class PolygonBuilder {
  114614. /**
  114615. * Creates a polygon mesh
  114616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114617. * * 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
  114618. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114621. * * Remember you can only change the shape positions, not their number when updating a polygon
  114622. * @param name defines the name of the mesh
  114623. * @param options defines the options used to create the mesh
  114624. * @param scene defines the hosting scene
  114625. * @param earcutInjection can be used to inject your own earcut reference
  114626. * @returns the polygon mesh
  114627. */
  114628. static CreatePolygon(name: string, options: {
  114629. shape: Vector3[];
  114630. holes?: Vector3[][];
  114631. depth?: number;
  114632. faceUV?: Vector4[];
  114633. faceColors?: Color4[];
  114634. updatable?: boolean;
  114635. sideOrientation?: number;
  114636. frontUVs?: Vector4;
  114637. backUVs?: Vector4;
  114638. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114639. /**
  114640. * Creates an extruded polygon mesh, with depth in the Y direction.
  114641. * * 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)
  114642. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114643. * @param name defines the name of the mesh
  114644. * @param options defines the options used to create the mesh
  114645. * @param scene defines the hosting scene
  114646. * @param earcutInjection can be used to inject your own earcut reference
  114647. * @returns the polygon mesh
  114648. */
  114649. static ExtrudePolygon(name: string, options: {
  114650. shape: Vector3[];
  114651. holes?: Vector3[][];
  114652. depth?: number;
  114653. faceUV?: Vector4[];
  114654. faceColors?: Color4[];
  114655. updatable?: boolean;
  114656. sideOrientation?: number;
  114657. frontUVs?: Vector4;
  114658. backUVs?: Vector4;
  114659. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114660. }
  114661. }
  114662. declare module BABYLON {
  114663. /**
  114664. * Class containing static functions to help procedurally build meshes
  114665. */
  114666. export class LatheBuilder {
  114667. /**
  114668. * Creates lathe mesh.
  114669. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114670. * * 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
  114671. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114672. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114673. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114674. * * 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
  114675. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114676. * * 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
  114677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114681. * @param name defines the name of the mesh
  114682. * @param options defines the options used to create the mesh
  114683. * @param scene defines the hosting scene
  114684. * @returns the lathe mesh
  114685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  114686. */
  114687. static CreateLathe(name: string, options: {
  114688. shape: Vector3[];
  114689. radius?: number;
  114690. tessellation?: number;
  114691. clip?: number;
  114692. arc?: number;
  114693. closed?: boolean;
  114694. updatable?: boolean;
  114695. sideOrientation?: number;
  114696. frontUVs?: Vector4;
  114697. backUVs?: Vector4;
  114698. cap?: number;
  114699. invertUV?: boolean;
  114700. }, scene?: Nullable<Scene>): Mesh;
  114701. }
  114702. }
  114703. declare module BABYLON {
  114704. /**
  114705. * Class containing static functions to help procedurally build meshes
  114706. */
  114707. export class TiledPlaneBuilder {
  114708. /**
  114709. * Creates a tiled plane mesh
  114710. * * The parameter `pattern` will, depending on value, do nothing or
  114711. * * * flip (reflect about central vertical) alternate tiles across and up
  114712. * * * flip every tile on alternate rows
  114713. * * * rotate (180 degs) alternate tiles across and up
  114714. * * * rotate every tile on alternate rows
  114715. * * * flip and rotate alternate tiles across and up
  114716. * * * flip and rotate every tile on alternate rows
  114717. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  114718. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  114719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114720. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114721. * * 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)
  114722. * * 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)
  114723. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114724. * @param name defines the name of the mesh
  114725. * @param options defines the options used to create the mesh
  114726. * @param scene defines the hosting scene
  114727. * @returns the box mesh
  114728. */
  114729. static CreateTiledPlane(name: string, options: {
  114730. pattern?: number;
  114731. tileSize?: number;
  114732. tileWidth?: number;
  114733. tileHeight?: number;
  114734. size?: number;
  114735. width?: number;
  114736. height?: number;
  114737. alignHorizontal?: number;
  114738. alignVertical?: number;
  114739. sideOrientation?: number;
  114740. frontUVs?: Vector4;
  114741. backUVs?: Vector4;
  114742. updatable?: boolean;
  114743. }, scene?: Nullable<Scene>): Mesh;
  114744. }
  114745. }
  114746. declare module BABYLON {
  114747. /**
  114748. * Class containing static functions to help procedurally build meshes
  114749. */
  114750. export class TubeBuilder {
  114751. /**
  114752. * Creates a tube mesh.
  114753. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114754. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  114755. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  114756. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  114757. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  114758. * * 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)
  114759. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  114760. * * 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
  114761. * * 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
  114762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114763. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114766. * @param name defines the name of the mesh
  114767. * @param options defines the options used to create the mesh
  114768. * @param scene defines the hosting scene
  114769. * @returns the tube mesh
  114770. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114771. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114772. */
  114773. static CreateTube(name: string, options: {
  114774. path: Vector3[];
  114775. radius?: number;
  114776. tessellation?: number;
  114777. radiusFunction?: {
  114778. (i: number, distance: number): number;
  114779. };
  114780. cap?: number;
  114781. arc?: number;
  114782. updatable?: boolean;
  114783. sideOrientation?: number;
  114784. frontUVs?: Vector4;
  114785. backUVs?: Vector4;
  114786. instance?: Mesh;
  114787. invertUV?: boolean;
  114788. }, scene?: Nullable<Scene>): Mesh;
  114789. }
  114790. }
  114791. declare module BABYLON {
  114792. /**
  114793. * Class containing static functions to help procedurally build meshes
  114794. */
  114795. export class IcoSphereBuilder {
  114796. /**
  114797. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114798. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114799. * * 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`)
  114800. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114801. * * 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
  114802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114803. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114805. * @param name defines the name of the mesh
  114806. * @param options defines the options used to create the mesh
  114807. * @param scene defines the hosting scene
  114808. * @returns the icosahedron mesh
  114809. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114810. */
  114811. static CreateIcoSphere(name: string, options: {
  114812. radius?: number;
  114813. radiusX?: number;
  114814. radiusY?: number;
  114815. radiusZ?: number;
  114816. flat?: boolean;
  114817. subdivisions?: number;
  114818. sideOrientation?: number;
  114819. frontUVs?: Vector4;
  114820. backUVs?: Vector4;
  114821. updatable?: boolean;
  114822. }, scene?: Nullable<Scene>): Mesh;
  114823. }
  114824. }
  114825. declare module BABYLON {
  114826. /**
  114827. * Class containing static functions to help procedurally build meshes
  114828. */
  114829. export class DecalBuilder {
  114830. /**
  114831. * Creates a decal mesh.
  114832. * 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
  114833. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  114834. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  114835. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  114836. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  114837. * @param name defines the name of the mesh
  114838. * @param sourceMesh defines the mesh where the decal must be applied
  114839. * @param options defines the options used to create the mesh
  114840. * @param scene defines the hosting scene
  114841. * @returns the decal mesh
  114842. * @see https://doc.babylonjs.com/how_to/decals
  114843. */
  114844. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  114845. position?: Vector3;
  114846. normal?: Vector3;
  114847. size?: Vector3;
  114848. angle?: number;
  114849. }): Mesh;
  114850. }
  114851. }
  114852. declare module BABYLON {
  114853. /**
  114854. * Class containing static functions to help procedurally build meshes
  114855. */
  114856. export class MeshBuilder {
  114857. /**
  114858. * Creates a box mesh
  114859. * * The parameter `size` sets the size (float) of each box side (default 1)
  114860. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  114861. * * 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)
  114862. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114866. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114867. * @param name defines the name of the mesh
  114868. * @param options defines the options used to create the mesh
  114869. * @param scene defines the hosting scene
  114870. * @returns the box mesh
  114871. */
  114872. static CreateBox(name: string, options: {
  114873. size?: number;
  114874. width?: number;
  114875. height?: number;
  114876. depth?: number;
  114877. faceUV?: Vector4[];
  114878. faceColors?: Color4[];
  114879. sideOrientation?: number;
  114880. frontUVs?: Vector4;
  114881. backUVs?: Vector4;
  114882. updatable?: boolean;
  114883. }, scene?: Nullable<Scene>): Mesh;
  114884. /**
  114885. * Creates a tiled box mesh
  114886. * * faceTiles sets the pattern, tile size and number of tiles for a face
  114887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114888. * @param name defines the name of the mesh
  114889. * @param options defines the options used to create the mesh
  114890. * @param scene defines the hosting scene
  114891. * @returns the tiled box mesh
  114892. */
  114893. static CreateTiledBox(name: string, options: {
  114894. pattern?: number;
  114895. size?: number;
  114896. width?: number;
  114897. height?: number;
  114898. depth: number;
  114899. tileSize?: number;
  114900. tileWidth?: number;
  114901. tileHeight?: number;
  114902. faceUV?: Vector4[];
  114903. faceColors?: Color4[];
  114904. alignHorizontal?: number;
  114905. alignVertical?: number;
  114906. sideOrientation?: number;
  114907. updatable?: boolean;
  114908. }, scene?: Nullable<Scene>): Mesh;
  114909. /**
  114910. * Creates a sphere mesh
  114911. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  114912. * * 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`)
  114913. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  114914. * * 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
  114915. * * 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)
  114916. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114917. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114919. * @param name defines the name of the mesh
  114920. * @param options defines the options used to create the mesh
  114921. * @param scene defines the hosting scene
  114922. * @returns the sphere mesh
  114923. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  114924. */
  114925. static CreateSphere(name: string, options: {
  114926. segments?: number;
  114927. diameter?: number;
  114928. diameterX?: number;
  114929. diameterY?: number;
  114930. diameterZ?: number;
  114931. arc?: number;
  114932. slice?: number;
  114933. sideOrientation?: number;
  114934. frontUVs?: Vector4;
  114935. backUVs?: Vector4;
  114936. updatable?: boolean;
  114937. }, scene?: Nullable<Scene>): Mesh;
  114938. /**
  114939. * Creates a plane polygonal mesh. By default, this is a disc
  114940. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114941. * * 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
  114942. * * 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
  114943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114946. * @param name defines the name of the mesh
  114947. * @param options defines the options used to create the mesh
  114948. * @param scene defines the hosting scene
  114949. * @returns the plane polygonal mesh
  114950. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114951. */
  114952. static CreateDisc(name: string, options: {
  114953. radius?: number;
  114954. tessellation?: number;
  114955. arc?: number;
  114956. updatable?: boolean;
  114957. sideOrientation?: number;
  114958. frontUVs?: Vector4;
  114959. backUVs?: Vector4;
  114960. }, scene?: Nullable<Scene>): Mesh;
  114961. /**
  114962. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114963. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114964. * * 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`)
  114965. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114966. * * 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
  114967. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114968. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114970. * @param name defines the name of the mesh
  114971. * @param options defines the options used to create the mesh
  114972. * @param scene defines the hosting scene
  114973. * @returns the icosahedron mesh
  114974. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114975. */
  114976. static CreateIcoSphere(name: string, options: {
  114977. radius?: number;
  114978. radiusX?: number;
  114979. radiusY?: number;
  114980. radiusZ?: number;
  114981. flat?: boolean;
  114982. subdivisions?: number;
  114983. sideOrientation?: number;
  114984. frontUVs?: Vector4;
  114985. backUVs?: Vector4;
  114986. updatable?: boolean;
  114987. }, scene?: Nullable<Scene>): Mesh;
  114988. /**
  114989. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114990. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114991. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114992. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114993. * * 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
  114994. * * 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
  114995. * * 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
  114996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114999. * * 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
  115000. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115001. * * 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
  115002. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115003. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115004. * @param name defines the name of the mesh
  115005. * @param options defines the options used to create the mesh
  115006. * @param scene defines the hosting scene
  115007. * @returns the ribbon mesh
  115008. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115009. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115010. */
  115011. static CreateRibbon(name: string, options: {
  115012. pathArray: Vector3[][];
  115013. closeArray?: boolean;
  115014. closePath?: boolean;
  115015. offset?: number;
  115016. updatable?: boolean;
  115017. sideOrientation?: number;
  115018. frontUVs?: Vector4;
  115019. backUVs?: Vector4;
  115020. instance?: Mesh;
  115021. invertUV?: boolean;
  115022. uvs?: Vector2[];
  115023. colors?: Color4[];
  115024. }, scene?: Nullable<Scene>): Mesh;
  115025. /**
  115026. * Creates a cylinder or a cone mesh
  115027. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115028. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115029. * * 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.
  115030. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115031. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115032. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115033. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115034. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  115035. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115036. * * 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).
  115037. * * 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
  115038. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115039. * * 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
  115040. * * 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.
  115041. * * If `enclose` is false, a ring surface is one element.
  115042. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115043. * * 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
  115044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115047. * @param name defines the name of the mesh
  115048. * @param options defines the options used to create the mesh
  115049. * @param scene defines the hosting scene
  115050. * @returns the cylinder mesh
  115051. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115052. */
  115053. static CreateCylinder(name: string, options: {
  115054. height?: number;
  115055. diameterTop?: number;
  115056. diameterBottom?: number;
  115057. diameter?: number;
  115058. tessellation?: number;
  115059. subdivisions?: number;
  115060. arc?: number;
  115061. faceColors?: Color4[];
  115062. faceUV?: Vector4[];
  115063. updatable?: boolean;
  115064. hasRings?: boolean;
  115065. enclose?: boolean;
  115066. cap?: number;
  115067. sideOrientation?: number;
  115068. frontUVs?: Vector4;
  115069. backUVs?: Vector4;
  115070. }, scene?: Nullable<Scene>): Mesh;
  115071. /**
  115072. * Creates a torus mesh
  115073. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115074. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115075. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115079. * @param name defines the name of the mesh
  115080. * @param options defines the options used to create the mesh
  115081. * @param scene defines the hosting scene
  115082. * @returns the torus mesh
  115083. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115084. */
  115085. static CreateTorus(name: string, options: {
  115086. diameter?: number;
  115087. thickness?: number;
  115088. tessellation?: number;
  115089. updatable?: boolean;
  115090. sideOrientation?: number;
  115091. frontUVs?: Vector4;
  115092. backUVs?: Vector4;
  115093. }, scene?: Nullable<Scene>): Mesh;
  115094. /**
  115095. * Creates a torus knot mesh
  115096. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115097. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115098. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115099. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115100. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115103. * @param name defines the name of the mesh
  115104. * @param options defines the options used to create the mesh
  115105. * @param scene defines the hosting scene
  115106. * @returns the torus knot mesh
  115107. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115108. */
  115109. static CreateTorusKnot(name: string, options: {
  115110. radius?: number;
  115111. tube?: number;
  115112. radialSegments?: number;
  115113. tubularSegments?: number;
  115114. p?: number;
  115115. q?: number;
  115116. updatable?: boolean;
  115117. sideOrientation?: number;
  115118. frontUVs?: Vector4;
  115119. backUVs?: Vector4;
  115120. }, scene?: Nullable<Scene>): Mesh;
  115121. /**
  115122. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115123. * * 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
  115124. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115125. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115126. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115127. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115128. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115129. * * 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
  115130. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115133. * @param name defines the name of the new line system
  115134. * @param options defines the options used to create the line system
  115135. * @param scene defines the hosting scene
  115136. * @returns a new line system mesh
  115137. */
  115138. static CreateLineSystem(name: string, options: {
  115139. lines: Vector3[][];
  115140. updatable?: boolean;
  115141. instance?: Nullable<LinesMesh>;
  115142. colors?: Nullable<Color4[][]>;
  115143. useVertexAlpha?: boolean;
  115144. }, scene: Nullable<Scene>): LinesMesh;
  115145. /**
  115146. * Creates a line mesh
  115147. * 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
  115148. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115149. * * The parameter `points` is an array successive Vector3
  115150. * * 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
  115151. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115152. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115153. * * When updating an instance, remember that only point positions can change, not the number of points
  115154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115155. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115156. * @param name defines the name of the new line system
  115157. * @param options defines the options used to create the line system
  115158. * @param scene defines the hosting scene
  115159. * @returns a new line mesh
  115160. */
  115161. static CreateLines(name: string, options: {
  115162. points: Vector3[];
  115163. updatable?: boolean;
  115164. instance?: Nullable<LinesMesh>;
  115165. colors?: Color4[];
  115166. useVertexAlpha?: boolean;
  115167. }, scene?: Nullable<Scene>): LinesMesh;
  115168. /**
  115169. * Creates a dashed line mesh
  115170. * * 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
  115171. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115172. * * The parameter `points` is an array successive Vector3
  115173. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115174. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115175. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115176. * * 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
  115177. * * When updating an instance, remember that only point positions can change, not the number of points
  115178. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115179. * @param name defines the name of the mesh
  115180. * @param options defines the options used to create the mesh
  115181. * @param scene defines the hosting scene
  115182. * @returns the dashed line mesh
  115183. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115184. */
  115185. static CreateDashedLines(name: string, options: {
  115186. points: Vector3[];
  115187. dashSize?: number;
  115188. gapSize?: number;
  115189. dashNb?: number;
  115190. updatable?: boolean;
  115191. instance?: LinesMesh;
  115192. }, scene?: Nullable<Scene>): LinesMesh;
  115193. /**
  115194. * 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.
  115195. * * 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.
  115196. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115197. * * 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.
  115198. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115199. * * 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
  115200. * * 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
  115201. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115206. * @param name defines the name of the mesh
  115207. * @param options defines the options used to create the mesh
  115208. * @param scene defines the hosting scene
  115209. * @returns the extruded shape mesh
  115210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115212. */
  115213. static ExtrudeShape(name: string, options: {
  115214. shape: Vector3[];
  115215. path: Vector3[];
  115216. scale?: number;
  115217. rotation?: number;
  115218. cap?: number;
  115219. updatable?: boolean;
  115220. sideOrientation?: number;
  115221. frontUVs?: Vector4;
  115222. backUVs?: Vector4;
  115223. instance?: Mesh;
  115224. invertUV?: boolean;
  115225. }, scene?: Nullable<Scene>): Mesh;
  115226. /**
  115227. * Creates an custom extruded shape mesh.
  115228. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115229. * * 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.
  115230. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115231. * * 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
  115232. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115233. * * 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
  115234. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115235. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115236. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115237. * * 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
  115238. * * 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
  115239. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115244. * @param name defines the name of the mesh
  115245. * @param options defines the options used to create the mesh
  115246. * @param scene defines the hosting scene
  115247. * @returns the custom extruded shape mesh
  115248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115249. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115250. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115251. */
  115252. static ExtrudeShapeCustom(name: string, options: {
  115253. shape: Vector3[];
  115254. path: Vector3[];
  115255. scaleFunction?: any;
  115256. rotationFunction?: any;
  115257. ribbonCloseArray?: boolean;
  115258. ribbonClosePath?: boolean;
  115259. cap?: number;
  115260. updatable?: boolean;
  115261. sideOrientation?: number;
  115262. frontUVs?: Vector4;
  115263. backUVs?: Vector4;
  115264. instance?: Mesh;
  115265. invertUV?: boolean;
  115266. }, scene?: Nullable<Scene>): Mesh;
  115267. /**
  115268. * Creates lathe mesh.
  115269. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115270. * * 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
  115271. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115272. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115273. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115274. * * 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
  115275. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115276. * * 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
  115277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115279. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115281. * @param name defines the name of the mesh
  115282. * @param options defines the options used to create the mesh
  115283. * @param scene defines the hosting scene
  115284. * @returns the lathe mesh
  115285. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115286. */
  115287. static CreateLathe(name: string, options: {
  115288. shape: Vector3[];
  115289. radius?: number;
  115290. tessellation?: number;
  115291. clip?: number;
  115292. arc?: number;
  115293. closed?: boolean;
  115294. updatable?: boolean;
  115295. sideOrientation?: number;
  115296. frontUVs?: Vector4;
  115297. backUVs?: Vector4;
  115298. cap?: number;
  115299. invertUV?: boolean;
  115300. }, scene?: Nullable<Scene>): Mesh;
  115301. /**
  115302. * Creates a tiled plane mesh
  115303. * * You can set a limited pattern arrangement with the tiles
  115304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115307. * @param name defines the name of the mesh
  115308. * @param options defines the options used to create the mesh
  115309. * @param scene defines the hosting scene
  115310. * @returns the plane mesh
  115311. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115312. */
  115313. static CreateTiledPlane(name: string, options: {
  115314. pattern?: number;
  115315. tileSize?: number;
  115316. tileWidth?: number;
  115317. tileHeight?: number;
  115318. size?: number;
  115319. width?: number;
  115320. height?: number;
  115321. alignHorizontal?: number;
  115322. alignVertical?: number;
  115323. sideOrientation?: number;
  115324. frontUVs?: Vector4;
  115325. backUVs?: Vector4;
  115326. updatable?: boolean;
  115327. }, scene?: Nullable<Scene>): Mesh;
  115328. /**
  115329. * Creates a plane mesh
  115330. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  115331. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  115332. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  115333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115336. * @param name defines the name of the mesh
  115337. * @param options defines the options used to create the mesh
  115338. * @param scene defines the hosting scene
  115339. * @returns the plane mesh
  115340. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  115341. */
  115342. static CreatePlane(name: string, options: {
  115343. size?: number;
  115344. width?: number;
  115345. height?: number;
  115346. sideOrientation?: number;
  115347. frontUVs?: Vector4;
  115348. backUVs?: Vector4;
  115349. updatable?: boolean;
  115350. sourcePlane?: Plane;
  115351. }, scene?: Nullable<Scene>): Mesh;
  115352. /**
  115353. * Creates a ground mesh
  115354. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115355. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115357. * @param name defines the name of the mesh
  115358. * @param options defines the options used to create the mesh
  115359. * @param scene defines the hosting scene
  115360. * @returns the ground mesh
  115361. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115362. */
  115363. static CreateGround(name: string, options: {
  115364. width?: number;
  115365. height?: number;
  115366. subdivisions?: number;
  115367. subdivisionsX?: number;
  115368. subdivisionsY?: number;
  115369. updatable?: boolean;
  115370. }, scene?: Nullable<Scene>): Mesh;
  115371. /**
  115372. * Creates a tiled ground mesh
  115373. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115374. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115375. * * 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
  115376. * * 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
  115377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115378. * @param name defines the name of the mesh
  115379. * @param options defines the options used to create the mesh
  115380. * @param scene defines the hosting scene
  115381. * @returns the tiled ground mesh
  115382. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115383. */
  115384. static CreateTiledGround(name: string, options: {
  115385. xmin: number;
  115386. zmin: number;
  115387. xmax: number;
  115388. zmax: number;
  115389. subdivisions?: {
  115390. w: number;
  115391. h: number;
  115392. };
  115393. precision?: {
  115394. w: number;
  115395. h: number;
  115396. };
  115397. updatable?: boolean;
  115398. }, scene?: Nullable<Scene>): Mesh;
  115399. /**
  115400. * Creates a ground mesh from a height map
  115401. * * The parameter `url` sets the URL of the height map image resource.
  115402. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115403. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115404. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115405. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115406. * * 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.
  115407. * * 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).
  115408. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115410. * @param name defines the name of the mesh
  115411. * @param url defines the url to the height map
  115412. * @param options defines the options used to create the mesh
  115413. * @param scene defines the hosting scene
  115414. * @returns the ground mesh
  115415. * @see https://doc.babylonjs.com/babylon101/height_map
  115416. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115417. */
  115418. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115419. width?: number;
  115420. height?: number;
  115421. subdivisions?: number;
  115422. minHeight?: number;
  115423. maxHeight?: number;
  115424. colorFilter?: Color3;
  115425. alphaFilter?: number;
  115426. updatable?: boolean;
  115427. onReady?: (mesh: GroundMesh) => void;
  115428. }, scene?: Nullable<Scene>): GroundMesh;
  115429. /**
  115430. * Creates a polygon mesh
  115431. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115432. * * 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
  115433. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115436. * * Remember you can only change the shape positions, not their number when updating a polygon
  115437. * @param name defines the name of the mesh
  115438. * @param options defines the options used to create the mesh
  115439. * @param scene defines the hosting scene
  115440. * @param earcutInjection can be used to inject your own earcut reference
  115441. * @returns the polygon mesh
  115442. */
  115443. static CreatePolygon(name: string, options: {
  115444. shape: Vector3[];
  115445. holes?: Vector3[][];
  115446. depth?: number;
  115447. faceUV?: Vector4[];
  115448. faceColors?: Color4[];
  115449. updatable?: boolean;
  115450. sideOrientation?: number;
  115451. frontUVs?: Vector4;
  115452. backUVs?: Vector4;
  115453. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115454. /**
  115455. * Creates an extruded polygon mesh, with depth in the Y direction.
  115456. * * 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)
  115457. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115458. * @param name defines the name of the mesh
  115459. * @param options defines the options used to create the mesh
  115460. * @param scene defines the hosting scene
  115461. * @param earcutInjection can be used to inject your own earcut reference
  115462. * @returns the polygon mesh
  115463. */
  115464. static ExtrudePolygon(name: string, options: {
  115465. shape: Vector3[];
  115466. holes?: Vector3[][];
  115467. depth?: number;
  115468. faceUV?: Vector4[];
  115469. faceColors?: Color4[];
  115470. updatable?: boolean;
  115471. sideOrientation?: number;
  115472. frontUVs?: Vector4;
  115473. backUVs?: Vector4;
  115474. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115475. /**
  115476. * Creates a tube mesh.
  115477. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115478. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115479. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115480. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115481. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115482. * * 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)
  115483. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115484. * * 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
  115485. * * 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
  115486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115487. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115488. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115490. * @param name defines the name of the mesh
  115491. * @param options defines the options used to create the mesh
  115492. * @param scene defines the hosting scene
  115493. * @returns the tube mesh
  115494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115495. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115496. */
  115497. static CreateTube(name: string, options: {
  115498. path: Vector3[];
  115499. radius?: number;
  115500. tessellation?: number;
  115501. radiusFunction?: {
  115502. (i: number, distance: number): number;
  115503. };
  115504. cap?: number;
  115505. arc?: number;
  115506. updatable?: boolean;
  115507. sideOrientation?: number;
  115508. frontUVs?: Vector4;
  115509. backUVs?: Vector4;
  115510. instance?: Mesh;
  115511. invertUV?: boolean;
  115512. }, scene?: Nullable<Scene>): Mesh;
  115513. /**
  115514. * Creates a polyhedron mesh
  115515. * * 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
  115516. * * The parameter `size` (positive float, default 1) sets the polygon size
  115517. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  115518. * * 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`
  115519. * * 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
  115520. * * 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)`)
  115521. * * 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
  115522. * * 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
  115523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115524. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115526. * @param name defines the name of the mesh
  115527. * @param options defines the options used to create the mesh
  115528. * @param scene defines the hosting scene
  115529. * @returns the polyhedron mesh
  115530. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  115531. */
  115532. static CreatePolyhedron(name: string, options: {
  115533. type?: number;
  115534. size?: number;
  115535. sizeX?: number;
  115536. sizeY?: number;
  115537. sizeZ?: number;
  115538. custom?: any;
  115539. faceUV?: Vector4[];
  115540. faceColors?: Color4[];
  115541. flat?: boolean;
  115542. updatable?: boolean;
  115543. sideOrientation?: number;
  115544. frontUVs?: Vector4;
  115545. backUVs?: Vector4;
  115546. }, scene?: Nullable<Scene>): Mesh;
  115547. /**
  115548. * Creates a decal mesh.
  115549. * 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
  115550. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115551. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115552. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115553. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115554. * @param name defines the name of the mesh
  115555. * @param sourceMesh defines the mesh where the decal must be applied
  115556. * @param options defines the options used to create the mesh
  115557. * @param scene defines the hosting scene
  115558. * @returns the decal mesh
  115559. * @see https://doc.babylonjs.com/how_to/decals
  115560. */
  115561. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115562. position?: Vector3;
  115563. normal?: Vector3;
  115564. size?: Vector3;
  115565. angle?: number;
  115566. }): Mesh;
  115567. }
  115568. }
  115569. declare module BABYLON {
  115570. /**
  115571. * A simplifier interface for future simplification implementations
  115572. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115573. */
  115574. export interface ISimplifier {
  115575. /**
  115576. * Simplification of a given mesh according to the given settings.
  115577. * Since this requires computation, it is assumed that the function runs async.
  115578. * @param settings The settings of the simplification, including quality and distance
  115579. * @param successCallback A callback that will be called after the mesh was simplified.
  115580. * @param errorCallback in case of an error, this callback will be called. optional.
  115581. */
  115582. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  115583. }
  115584. /**
  115585. * Expected simplification settings.
  115586. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  115587. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115588. */
  115589. export interface ISimplificationSettings {
  115590. /**
  115591. * Gets or sets the expected quality
  115592. */
  115593. quality: number;
  115594. /**
  115595. * Gets or sets the distance when this optimized version should be used
  115596. */
  115597. distance: number;
  115598. /**
  115599. * Gets an already optimized mesh
  115600. */
  115601. optimizeMesh?: boolean;
  115602. }
  115603. /**
  115604. * Class used to specify simplification options
  115605. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115606. */
  115607. export class SimplificationSettings implements ISimplificationSettings {
  115608. /** expected quality */
  115609. quality: number;
  115610. /** distance when this optimized version should be used */
  115611. distance: number;
  115612. /** already optimized mesh */
  115613. optimizeMesh?: boolean | undefined;
  115614. /**
  115615. * Creates a SimplificationSettings
  115616. * @param quality expected quality
  115617. * @param distance distance when this optimized version should be used
  115618. * @param optimizeMesh already optimized mesh
  115619. */
  115620. constructor(
  115621. /** expected quality */
  115622. quality: number,
  115623. /** distance when this optimized version should be used */
  115624. distance: number,
  115625. /** already optimized mesh */
  115626. optimizeMesh?: boolean | undefined);
  115627. }
  115628. /**
  115629. * Interface used to define a simplification task
  115630. */
  115631. export interface ISimplificationTask {
  115632. /**
  115633. * Array of settings
  115634. */
  115635. settings: Array<ISimplificationSettings>;
  115636. /**
  115637. * Simplification type
  115638. */
  115639. simplificationType: SimplificationType;
  115640. /**
  115641. * Mesh to simplify
  115642. */
  115643. mesh: Mesh;
  115644. /**
  115645. * Callback called on success
  115646. */
  115647. successCallback?: () => void;
  115648. /**
  115649. * Defines if parallel processing can be used
  115650. */
  115651. parallelProcessing: boolean;
  115652. }
  115653. /**
  115654. * Queue used to order the simplification tasks
  115655. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115656. */
  115657. export class SimplificationQueue {
  115658. private _simplificationArray;
  115659. /**
  115660. * Gets a boolean indicating that the process is still running
  115661. */
  115662. running: boolean;
  115663. /**
  115664. * Creates a new queue
  115665. */
  115666. constructor();
  115667. /**
  115668. * Adds a new simplification task
  115669. * @param task defines a task to add
  115670. */
  115671. addTask(task: ISimplificationTask): void;
  115672. /**
  115673. * Execute next task
  115674. */
  115675. executeNext(): void;
  115676. /**
  115677. * Execute a simplification task
  115678. * @param task defines the task to run
  115679. */
  115680. runSimplification(task: ISimplificationTask): void;
  115681. private getSimplifier;
  115682. }
  115683. /**
  115684. * The implemented types of simplification
  115685. * At the moment only Quadratic Error Decimation is implemented
  115686. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115687. */
  115688. export enum SimplificationType {
  115689. /** Quadratic error decimation */
  115690. QUADRATIC = 0
  115691. }
  115692. }
  115693. declare module BABYLON {
  115694. interface Scene {
  115695. /** @hidden (Backing field) */
  115696. _simplificationQueue: SimplificationQueue;
  115697. /**
  115698. * Gets or sets the simplification queue attached to the scene
  115699. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115700. */
  115701. simplificationQueue: SimplificationQueue;
  115702. }
  115703. interface Mesh {
  115704. /**
  115705. * Simplify the mesh according to the given array of settings.
  115706. * Function will return immediately and will simplify async
  115707. * @param settings a collection of simplification settings
  115708. * @param parallelProcessing should all levels calculate parallel or one after the other
  115709. * @param simplificationType the type of simplification to run
  115710. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  115711. * @returns the current mesh
  115712. */
  115713. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  115714. }
  115715. /**
  115716. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  115717. * created in a scene
  115718. */
  115719. export class SimplicationQueueSceneComponent implements ISceneComponent {
  115720. /**
  115721. * The component name helpfull to identify the component in the list of scene components.
  115722. */
  115723. readonly name: string;
  115724. /**
  115725. * The scene the component belongs to.
  115726. */
  115727. scene: Scene;
  115728. /**
  115729. * Creates a new instance of the component for the given scene
  115730. * @param scene Defines the scene to register the component in
  115731. */
  115732. constructor(scene: Scene);
  115733. /**
  115734. * Registers the component in a given scene
  115735. */
  115736. register(): void;
  115737. /**
  115738. * Rebuilds the elements related to this component in case of
  115739. * context lost for instance.
  115740. */
  115741. rebuild(): void;
  115742. /**
  115743. * Disposes the component and the associated ressources
  115744. */
  115745. dispose(): void;
  115746. private _beforeCameraUpdate;
  115747. }
  115748. }
  115749. declare module BABYLON {
  115750. /**
  115751. * Class used to enable access to IndexedDB
  115752. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115753. */
  115754. export class Database implements IOfflineProvider {
  115755. private _callbackManifestChecked;
  115756. private _currentSceneUrl;
  115757. private _db;
  115758. private _enableSceneOffline;
  115759. private _enableTexturesOffline;
  115760. private _manifestVersionFound;
  115761. private _mustUpdateRessources;
  115762. private _hasReachedQuota;
  115763. private _isSupported;
  115764. private _idbFactory;
  115765. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  115766. private static IsUASupportingBlobStorage;
  115767. /**
  115768. * Gets a boolean indicating if Database storate is enabled (off by default)
  115769. */
  115770. static IDBStorageEnabled: boolean;
  115771. /**
  115772. * Gets a boolean indicating if scene must be saved in the database
  115773. */
  115774. readonly enableSceneOffline: boolean;
  115775. /**
  115776. * Gets a boolean indicating if textures must be saved in the database
  115777. */
  115778. readonly enableTexturesOffline: boolean;
  115779. /**
  115780. * Creates a new Database
  115781. * @param urlToScene defines the url to load the scene
  115782. * @param callbackManifestChecked defines the callback to use when manifest is checked
  115783. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  115784. */
  115785. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  115786. private static _ParseURL;
  115787. private static _ReturnFullUrlLocation;
  115788. private _checkManifestFile;
  115789. /**
  115790. * Open the database and make it available
  115791. * @param successCallback defines the callback to call on success
  115792. * @param errorCallback defines the callback to call on error
  115793. */
  115794. open(successCallback: () => void, errorCallback: () => void): void;
  115795. /**
  115796. * Loads an image from the database
  115797. * @param url defines the url to load from
  115798. * @param image defines the target DOM image
  115799. */
  115800. loadImage(url: string, image: HTMLImageElement): void;
  115801. private _loadImageFromDBAsync;
  115802. private _saveImageIntoDBAsync;
  115803. private _checkVersionFromDB;
  115804. private _loadVersionFromDBAsync;
  115805. private _saveVersionIntoDBAsync;
  115806. /**
  115807. * Loads a file from database
  115808. * @param url defines the URL to load from
  115809. * @param sceneLoaded defines a callback to call on success
  115810. * @param progressCallBack defines a callback to call when progress changed
  115811. * @param errorCallback defines a callback to call on error
  115812. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  115813. */
  115814. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  115815. private _loadFileAsync;
  115816. private _saveFileAsync;
  115817. /**
  115818. * Validates if xhr data is correct
  115819. * @param xhr defines the request to validate
  115820. * @param dataType defines the expected data type
  115821. * @returns true if data is correct
  115822. */
  115823. private static _ValidateXHRData;
  115824. }
  115825. }
  115826. declare module BABYLON {
  115827. /** @hidden */
  115828. export var gpuUpdateParticlesPixelShader: {
  115829. name: string;
  115830. shader: string;
  115831. };
  115832. }
  115833. declare module BABYLON {
  115834. /** @hidden */
  115835. export var gpuUpdateParticlesVertexShader: {
  115836. name: string;
  115837. shader: string;
  115838. };
  115839. }
  115840. declare module BABYLON {
  115841. /** @hidden */
  115842. export var clipPlaneFragmentDeclaration2: {
  115843. name: string;
  115844. shader: string;
  115845. };
  115846. }
  115847. declare module BABYLON {
  115848. /** @hidden */
  115849. export var gpuRenderParticlesPixelShader: {
  115850. name: string;
  115851. shader: string;
  115852. };
  115853. }
  115854. declare module BABYLON {
  115855. /** @hidden */
  115856. export var clipPlaneVertexDeclaration2: {
  115857. name: string;
  115858. shader: string;
  115859. };
  115860. }
  115861. declare module BABYLON {
  115862. /** @hidden */
  115863. export var gpuRenderParticlesVertexShader: {
  115864. name: string;
  115865. shader: string;
  115866. };
  115867. }
  115868. declare module BABYLON {
  115869. /**
  115870. * This represents a GPU particle system in Babylon
  115871. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  115872. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  115873. */
  115874. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  115875. /**
  115876. * The layer mask we are rendering the particles through.
  115877. */
  115878. layerMask: number;
  115879. private _capacity;
  115880. private _activeCount;
  115881. private _currentActiveCount;
  115882. private _accumulatedCount;
  115883. private _renderEffect;
  115884. private _updateEffect;
  115885. private _buffer0;
  115886. private _buffer1;
  115887. private _spriteBuffer;
  115888. private _updateVAO;
  115889. private _renderVAO;
  115890. private _targetIndex;
  115891. private _sourceBuffer;
  115892. private _targetBuffer;
  115893. private _engine;
  115894. private _currentRenderId;
  115895. private _started;
  115896. private _stopped;
  115897. private _timeDelta;
  115898. private _randomTexture;
  115899. private _randomTexture2;
  115900. private _attributesStrideSize;
  115901. private _updateEffectOptions;
  115902. private _randomTextureSize;
  115903. private _actualFrame;
  115904. private readonly _rawTextureWidth;
  115905. /**
  115906. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  115907. */
  115908. static readonly IsSupported: boolean;
  115909. /**
  115910. * An event triggered when the system is disposed.
  115911. */
  115912. onDisposeObservable: Observable<GPUParticleSystem>;
  115913. /**
  115914. * Gets the maximum number of particles active at the same time.
  115915. * @returns The max number of active particles.
  115916. */
  115917. getCapacity(): number;
  115918. /**
  115919. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  115920. * to override the particles.
  115921. */
  115922. forceDepthWrite: boolean;
  115923. /**
  115924. * Gets or set the number of active particles
  115925. */
  115926. activeParticleCount: number;
  115927. private _preWarmDone;
  115928. /**
  115929. * Is this system ready to be used/rendered
  115930. * @return true if the system is ready
  115931. */
  115932. isReady(): boolean;
  115933. /**
  115934. * Gets if the system has been started. (Note: this will still be true after stop is called)
  115935. * @returns True if it has been started, otherwise false.
  115936. */
  115937. isStarted(): boolean;
  115938. /**
  115939. * Starts the particle system and begins to emit
  115940. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  115941. */
  115942. start(delay?: number): void;
  115943. /**
  115944. * Stops the particle system.
  115945. */
  115946. stop(): void;
  115947. /**
  115948. * Remove all active particles
  115949. */
  115950. reset(): void;
  115951. /**
  115952. * Returns the string "GPUParticleSystem"
  115953. * @returns a string containing the class name
  115954. */
  115955. getClassName(): string;
  115956. private _colorGradientsTexture;
  115957. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  115958. /**
  115959. * Adds a new color gradient
  115960. * @param gradient defines the gradient to use (between 0 and 1)
  115961. * @param color1 defines the color to affect to the specified gradient
  115962. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  115963. * @returns the current particle system
  115964. */
  115965. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  115966. /**
  115967. * Remove a specific color gradient
  115968. * @param gradient defines the gradient to remove
  115969. * @returns the current particle system
  115970. */
  115971. removeColorGradient(gradient: number): GPUParticleSystem;
  115972. private _angularSpeedGradientsTexture;
  115973. private _sizeGradientsTexture;
  115974. private _velocityGradientsTexture;
  115975. private _limitVelocityGradientsTexture;
  115976. private _dragGradientsTexture;
  115977. private _addFactorGradient;
  115978. /**
  115979. * Adds a new size gradient
  115980. * @param gradient defines the gradient to use (between 0 and 1)
  115981. * @param factor defines the size factor to affect to the specified gradient
  115982. * @returns the current particle system
  115983. */
  115984. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  115985. /**
  115986. * Remove a specific size gradient
  115987. * @param gradient defines the gradient to remove
  115988. * @returns the current particle system
  115989. */
  115990. removeSizeGradient(gradient: number): GPUParticleSystem;
  115991. /**
  115992. * Adds a new angular speed gradient
  115993. * @param gradient defines the gradient to use (between 0 and 1)
  115994. * @param factor defines the angular speed to affect to the specified gradient
  115995. * @returns the current particle system
  115996. */
  115997. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  115998. /**
  115999. * Remove a specific angular speed gradient
  116000. * @param gradient defines the gradient to remove
  116001. * @returns the current particle system
  116002. */
  116003. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116004. /**
  116005. * Adds a new velocity gradient
  116006. * @param gradient defines the gradient to use (between 0 and 1)
  116007. * @param factor defines the velocity to affect to the specified gradient
  116008. * @returns the current particle system
  116009. */
  116010. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116011. /**
  116012. * Remove a specific velocity gradient
  116013. * @param gradient defines the gradient to remove
  116014. * @returns the current particle system
  116015. */
  116016. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116017. /**
  116018. * Adds a new limit velocity gradient
  116019. * @param gradient defines the gradient to use (between 0 and 1)
  116020. * @param factor defines the limit velocity value to affect to the specified gradient
  116021. * @returns the current particle system
  116022. */
  116023. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116024. /**
  116025. * Remove a specific limit velocity gradient
  116026. * @param gradient defines the gradient to remove
  116027. * @returns the current particle system
  116028. */
  116029. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116030. /**
  116031. * Adds a new drag gradient
  116032. * @param gradient defines the gradient to use (between 0 and 1)
  116033. * @param factor defines the drag value to affect to the specified gradient
  116034. * @returns the current particle system
  116035. */
  116036. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116037. /**
  116038. * Remove a specific drag gradient
  116039. * @param gradient defines the gradient to remove
  116040. * @returns the current particle system
  116041. */
  116042. removeDragGradient(gradient: number): GPUParticleSystem;
  116043. /**
  116044. * Not supported by GPUParticleSystem
  116045. * @param gradient defines the gradient to use (between 0 and 1)
  116046. * @param factor defines the emit rate value to affect to the specified gradient
  116047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116048. * @returns the current particle system
  116049. */
  116050. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116051. /**
  116052. * Not supported by GPUParticleSystem
  116053. * @param gradient defines the gradient to remove
  116054. * @returns the current particle system
  116055. */
  116056. removeEmitRateGradient(gradient: number): IParticleSystem;
  116057. /**
  116058. * Not supported by GPUParticleSystem
  116059. * @param gradient defines the gradient to use (between 0 and 1)
  116060. * @param factor defines the start size value to affect to the specified gradient
  116061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116062. * @returns the current particle system
  116063. */
  116064. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116065. /**
  116066. * Not supported by GPUParticleSystem
  116067. * @param gradient defines the gradient to remove
  116068. * @returns the current particle system
  116069. */
  116070. removeStartSizeGradient(gradient: number): IParticleSystem;
  116071. /**
  116072. * Not supported by GPUParticleSystem
  116073. * @param gradient defines the gradient to use (between 0 and 1)
  116074. * @param min defines the color remap minimal range
  116075. * @param max defines the color remap maximal range
  116076. * @returns the current particle system
  116077. */
  116078. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116079. /**
  116080. * Not supported by GPUParticleSystem
  116081. * @param gradient defines the gradient to remove
  116082. * @returns the current particle system
  116083. */
  116084. removeColorRemapGradient(): IParticleSystem;
  116085. /**
  116086. * Not supported by GPUParticleSystem
  116087. * @param gradient defines the gradient to use (between 0 and 1)
  116088. * @param min defines the alpha remap minimal range
  116089. * @param max defines the alpha remap maximal range
  116090. * @returns the current particle system
  116091. */
  116092. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116093. /**
  116094. * Not supported by GPUParticleSystem
  116095. * @param gradient defines the gradient to remove
  116096. * @returns the current particle system
  116097. */
  116098. removeAlphaRemapGradient(): IParticleSystem;
  116099. /**
  116100. * Not supported by GPUParticleSystem
  116101. * @param gradient defines the gradient to use (between 0 and 1)
  116102. * @param color defines the color to affect to the specified gradient
  116103. * @returns the current particle system
  116104. */
  116105. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116106. /**
  116107. * Not supported by GPUParticleSystem
  116108. * @param gradient defines the gradient to remove
  116109. * @returns the current particle system
  116110. */
  116111. removeRampGradient(): IParticleSystem;
  116112. /**
  116113. * Not supported by GPUParticleSystem
  116114. * @returns the list of ramp gradients
  116115. */
  116116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116117. /**
  116118. * Not supported by GPUParticleSystem
  116119. * Gets or sets a boolean indicating that ramp gradients must be used
  116120. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116121. */
  116122. useRampGradients: boolean;
  116123. /**
  116124. * Not supported by GPUParticleSystem
  116125. * @param gradient defines the gradient to use (between 0 and 1)
  116126. * @param factor defines the life time factor to affect to the specified gradient
  116127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116128. * @returns the current particle system
  116129. */
  116130. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116131. /**
  116132. * Not supported by GPUParticleSystem
  116133. * @param gradient defines the gradient to remove
  116134. * @returns the current particle system
  116135. */
  116136. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116137. /**
  116138. * Instantiates a GPU particle system.
  116139. * 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.
  116140. * @param name The name of the particle system
  116141. * @param options The options used to create the system
  116142. * @param scene The scene the particle system belongs to
  116143. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116144. */
  116145. constructor(name: string, options: Partial<{
  116146. capacity: number;
  116147. randomTextureSize: number;
  116148. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116149. protected _reset(): void;
  116150. private _createUpdateVAO;
  116151. private _createRenderVAO;
  116152. private _initialize;
  116153. /** @hidden */
  116154. _recreateUpdateEffect(): void;
  116155. /** @hidden */
  116156. _recreateRenderEffect(): void;
  116157. /**
  116158. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116159. * @param preWarm defines if we are in the pre-warmimg phase
  116160. */
  116161. animate(preWarm?: boolean): void;
  116162. private _createFactorGradientTexture;
  116163. private _createSizeGradientTexture;
  116164. private _createAngularSpeedGradientTexture;
  116165. private _createVelocityGradientTexture;
  116166. private _createLimitVelocityGradientTexture;
  116167. private _createDragGradientTexture;
  116168. private _createColorGradientTexture;
  116169. /**
  116170. * Renders the particle system in its current state
  116171. * @param preWarm defines if the system should only update the particles but not render them
  116172. * @returns the current number of particles
  116173. */
  116174. render(preWarm?: boolean): number;
  116175. /**
  116176. * Rebuilds the particle system
  116177. */
  116178. rebuild(): void;
  116179. private _releaseBuffers;
  116180. private _releaseVAOs;
  116181. /**
  116182. * Disposes the particle system and free the associated resources
  116183. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116184. */
  116185. dispose(disposeTexture?: boolean): void;
  116186. /**
  116187. * Clones the particle system.
  116188. * @param name The name of the cloned object
  116189. * @param newEmitter The new emitter to use
  116190. * @returns the cloned particle system
  116191. */
  116192. clone(name: string, newEmitter: any): GPUParticleSystem;
  116193. /**
  116194. * Serializes the particle system to a JSON object.
  116195. * @returns the JSON object
  116196. */
  116197. serialize(): any;
  116198. /**
  116199. * Parses a JSON object to create a GPU particle system.
  116200. * @param parsedParticleSystem The JSON object to parse
  116201. * @param scene The scene to create the particle system in
  116202. * @param rootUrl The root url to use to load external dependencies like texture
  116203. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116204. * @returns the parsed GPU particle system
  116205. */
  116206. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116207. }
  116208. }
  116209. declare module BABYLON {
  116210. /**
  116211. * Represents a set of particle systems working together to create a specific effect
  116212. */
  116213. export class ParticleSystemSet implements IDisposable {
  116214. private _emitterCreationOptions;
  116215. private _emitterNode;
  116216. /**
  116217. * Gets the particle system list
  116218. */
  116219. systems: IParticleSystem[];
  116220. /**
  116221. * Gets the emitter node used with this set
  116222. */
  116223. readonly emitterNode: Nullable<TransformNode>;
  116224. /**
  116225. * Creates a new emitter mesh as a sphere
  116226. * @param options defines the options used to create the sphere
  116227. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116228. * @param scene defines the hosting scene
  116229. */
  116230. setEmitterAsSphere(options: {
  116231. diameter: number;
  116232. segments: number;
  116233. color: Color3;
  116234. }, renderingGroupId: number, scene: Scene): void;
  116235. /**
  116236. * Starts all particle systems of the set
  116237. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116238. */
  116239. start(emitter?: AbstractMesh): void;
  116240. /**
  116241. * Release all associated resources
  116242. */
  116243. dispose(): void;
  116244. /**
  116245. * Serialize the set into a JSON compatible object
  116246. * @returns a JSON compatible representation of the set
  116247. */
  116248. serialize(): any;
  116249. /**
  116250. * Parse a new ParticleSystemSet from a serialized source
  116251. * @param data defines a JSON compatible representation of the set
  116252. * @param scene defines the hosting scene
  116253. * @param gpu defines if we want GPU particles or CPU particles
  116254. * @returns a new ParticleSystemSet
  116255. */
  116256. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  116257. }
  116258. }
  116259. declare module BABYLON {
  116260. /**
  116261. * This class is made for on one-liner static method to help creating particle system set.
  116262. */
  116263. export class ParticleHelper {
  116264. /**
  116265. * Gets or sets base Assets URL
  116266. */
  116267. static BaseAssetsUrl: string;
  116268. /**
  116269. * Create a default particle system that you can tweak
  116270. * @param emitter defines the emitter to use
  116271. * @param capacity defines the system capacity (default is 500 particles)
  116272. * @param scene defines the hosting scene
  116273. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  116274. * @returns the new Particle system
  116275. */
  116276. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  116277. /**
  116278. * This is the main static method (one-liner) of this helper to create different particle systems
  116279. * @param type This string represents the type to the particle system to create
  116280. * @param scene The scene where the particle system should live
  116281. * @param gpu If the system will use gpu
  116282. * @returns the ParticleSystemSet created
  116283. */
  116284. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  116285. /**
  116286. * Static function used to export a particle system to a ParticleSystemSet variable.
  116287. * Please note that the emitter shape is not exported
  116288. * @param systems defines the particle systems to export
  116289. * @returns the created particle system set
  116290. */
  116291. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  116292. }
  116293. }
  116294. declare module BABYLON {
  116295. interface Engine {
  116296. /**
  116297. * Create an effect to use with particle systems.
  116298. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  116299. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  116300. * @param uniformsNames defines a list of attribute names
  116301. * @param samplers defines an array of string used to represent textures
  116302. * @param defines defines the string containing the defines to use to compile the shaders
  116303. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116304. * @param onCompiled defines a function to call when the effect creation is successful
  116305. * @param onError defines a function to call when the effect creation has failed
  116306. * @returns the new Effect
  116307. */
  116308. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  116309. }
  116310. interface Mesh {
  116311. /**
  116312. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  116313. * @returns an array of IParticleSystem
  116314. */
  116315. getEmittedParticleSystems(): IParticleSystem[];
  116316. /**
  116317. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  116318. * @returns an array of IParticleSystem
  116319. */
  116320. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  116321. }
  116322. /**
  116323. * @hidden
  116324. */
  116325. export var _IDoNeedToBeInTheBuild: number;
  116326. }
  116327. declare module BABYLON {
  116328. interface Scene {
  116329. /** @hidden (Backing field) */
  116330. _physicsEngine: Nullable<IPhysicsEngine>;
  116331. /**
  116332. * Gets the current physics engine
  116333. * @returns a IPhysicsEngine or null if none attached
  116334. */
  116335. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  116336. /**
  116337. * Enables physics to the current scene
  116338. * @param gravity defines the scene's gravity for the physics engine
  116339. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116340. * @return a boolean indicating if the physics engine was initialized
  116341. */
  116342. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  116343. /**
  116344. * Disables and disposes the physics engine associated with the scene
  116345. */
  116346. disablePhysicsEngine(): void;
  116347. /**
  116348. * Gets a boolean indicating if there is an active physics engine
  116349. * @returns a boolean indicating if there is an active physics engine
  116350. */
  116351. isPhysicsEnabled(): boolean;
  116352. /**
  116353. * Deletes a physics compound impostor
  116354. * @param compound defines the compound to delete
  116355. */
  116356. deleteCompoundImpostor(compound: any): void;
  116357. /**
  116358. * An event triggered when physic simulation is about to be run
  116359. */
  116360. onBeforePhysicsObservable: Observable<Scene>;
  116361. /**
  116362. * An event triggered when physic simulation has been done
  116363. */
  116364. onAfterPhysicsObservable: Observable<Scene>;
  116365. }
  116366. interface AbstractMesh {
  116367. /** @hidden */
  116368. _physicsImpostor: Nullable<PhysicsImpostor>;
  116369. /**
  116370. * Gets or sets impostor used for physic simulation
  116371. * @see http://doc.babylonjs.com/features/physics_engine
  116372. */
  116373. physicsImpostor: Nullable<PhysicsImpostor>;
  116374. /**
  116375. * Gets the current physics impostor
  116376. * @see http://doc.babylonjs.com/features/physics_engine
  116377. * @returns a physics impostor or null
  116378. */
  116379. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  116380. /** Apply a physic impulse to the mesh
  116381. * @param force defines the force to apply
  116382. * @param contactPoint defines where to apply the force
  116383. * @returns the current mesh
  116384. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116385. */
  116386. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  116387. /**
  116388. * Creates a physic joint between two meshes
  116389. * @param otherMesh defines the other mesh to use
  116390. * @param pivot1 defines the pivot to use on this mesh
  116391. * @param pivot2 defines the pivot to use on the other mesh
  116392. * @param options defines additional options (can be plugin dependent)
  116393. * @returns the current mesh
  116394. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116395. */
  116396. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  116397. /** @hidden */
  116398. _disposePhysicsObserver: Nullable<Observer<Node>>;
  116399. }
  116400. /**
  116401. * Defines the physics engine scene component responsible to manage a physics engine
  116402. */
  116403. export class PhysicsEngineSceneComponent implements ISceneComponent {
  116404. /**
  116405. * The component name helpful to identify the component in the list of scene components.
  116406. */
  116407. readonly name: string;
  116408. /**
  116409. * The scene the component belongs to.
  116410. */
  116411. scene: Scene;
  116412. /**
  116413. * Creates a new instance of the component for the given scene
  116414. * @param scene Defines the scene to register the component in
  116415. */
  116416. constructor(scene: Scene);
  116417. /**
  116418. * Registers the component in a given scene
  116419. */
  116420. register(): void;
  116421. /**
  116422. * Rebuilds the elements related to this component in case of
  116423. * context lost for instance.
  116424. */
  116425. rebuild(): void;
  116426. /**
  116427. * Disposes the component and the associated ressources
  116428. */
  116429. dispose(): void;
  116430. }
  116431. }
  116432. declare module BABYLON {
  116433. /**
  116434. * A helper for physics simulations
  116435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116436. */
  116437. export class PhysicsHelper {
  116438. private _scene;
  116439. private _physicsEngine;
  116440. /**
  116441. * Initializes the Physics helper
  116442. * @param scene Babylon.js scene
  116443. */
  116444. constructor(scene: Scene);
  116445. /**
  116446. * Applies a radial explosion impulse
  116447. * @param origin the origin of the explosion
  116448. * @param radiusOrEventOptions the radius or the options of radial explosion
  116449. * @param strength the explosion strength
  116450. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116451. * @returns A physics radial explosion event, or null
  116452. */
  116453. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116454. /**
  116455. * Applies a radial explosion force
  116456. * @param origin the origin of the explosion
  116457. * @param radiusOrEventOptions the radius or the options of radial explosion
  116458. * @param strength the explosion strength
  116459. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116460. * @returns A physics radial explosion event, or null
  116461. */
  116462. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  116463. /**
  116464. * Creates a gravitational field
  116465. * @param origin the origin of the explosion
  116466. * @param radiusOrEventOptions the radius or the options of radial explosion
  116467. * @param strength the explosion strength
  116468. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116469. * @returns A physics gravitational field event, or null
  116470. */
  116471. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  116472. /**
  116473. * Creates a physics updraft event
  116474. * @param origin the origin of the updraft
  116475. * @param radiusOrEventOptions the radius or the options of the updraft
  116476. * @param strength the strength of the updraft
  116477. * @param height the height of the updraft
  116478. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116479. * @returns A physics updraft event, or null
  116480. */
  116481. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  116482. /**
  116483. * Creates a physics vortex event
  116484. * @param origin the of the vortex
  116485. * @param radiusOrEventOptions the radius or the options of the vortex
  116486. * @param strength the strength of the vortex
  116487. * @param height the height of the vortex
  116488. * @returns a Physics vortex event, or null
  116489. * A physics vortex event or null
  116490. */
  116491. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  116492. }
  116493. /**
  116494. * Represents a physics radial explosion event
  116495. */
  116496. class PhysicsRadialExplosionEvent {
  116497. private _scene;
  116498. private _options;
  116499. private _sphere;
  116500. private _dataFetched;
  116501. /**
  116502. * Initializes a radial explosioin event
  116503. * @param _scene BabylonJS scene
  116504. * @param _options The options for the vortex event
  116505. */
  116506. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  116507. /**
  116508. * Returns the data related to the radial explosion event (sphere).
  116509. * @returns The radial explosion event data
  116510. */
  116511. getData(): PhysicsRadialExplosionEventData;
  116512. /**
  116513. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116514. * @param impostor A physics imposter
  116515. * @param origin the origin of the explosion
  116516. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116517. */
  116518. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  116519. /**
  116520. * Triggers affecterd impostors callbacks
  116521. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116522. */
  116523. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  116524. /**
  116525. * Disposes the sphere.
  116526. * @param force Specifies if the sphere should be disposed by force
  116527. */
  116528. dispose(force?: boolean): void;
  116529. /*** Helpers ***/
  116530. private _prepareSphere;
  116531. private _intersectsWithSphere;
  116532. }
  116533. /**
  116534. * Represents a gravitational field event
  116535. */
  116536. class PhysicsGravitationalFieldEvent {
  116537. private _physicsHelper;
  116538. private _scene;
  116539. private _origin;
  116540. private _options;
  116541. private _tickCallback;
  116542. private _sphere;
  116543. private _dataFetched;
  116544. /**
  116545. * Initializes the physics gravitational field event
  116546. * @param _physicsHelper A physics helper
  116547. * @param _scene BabylonJS scene
  116548. * @param _origin The origin position of the gravitational field event
  116549. * @param _options The options for the vortex event
  116550. */
  116551. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116552. /**
  116553. * Returns the data related to the gravitational field event (sphere).
  116554. * @returns A gravitational field event
  116555. */
  116556. getData(): PhysicsGravitationalFieldEventData;
  116557. /**
  116558. * Enables the gravitational field.
  116559. */
  116560. enable(): void;
  116561. /**
  116562. * Disables the gravitational field.
  116563. */
  116564. disable(): void;
  116565. /**
  116566. * Disposes the sphere.
  116567. * @param force The force to dispose from the gravitational field event
  116568. */
  116569. dispose(force?: boolean): void;
  116570. private _tick;
  116571. }
  116572. /**
  116573. * Represents a physics updraft event
  116574. */
  116575. class PhysicsUpdraftEvent {
  116576. private _scene;
  116577. private _origin;
  116578. private _options;
  116579. private _physicsEngine;
  116580. private _originTop;
  116581. private _originDirection;
  116582. private _tickCallback;
  116583. private _cylinder;
  116584. private _cylinderPosition;
  116585. private _dataFetched;
  116586. /**
  116587. * Initializes the physics updraft event
  116588. * @param _scene BabylonJS scene
  116589. * @param _origin The origin position of the updraft
  116590. * @param _options The options for the updraft event
  116591. */
  116592. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  116593. /**
  116594. * Returns the data related to the updraft event (cylinder).
  116595. * @returns A physics updraft event
  116596. */
  116597. getData(): PhysicsUpdraftEventData;
  116598. /**
  116599. * Enables the updraft.
  116600. */
  116601. enable(): void;
  116602. /**
  116603. * Disables the updraft.
  116604. */
  116605. disable(): void;
  116606. /**
  116607. * Disposes the cylinder.
  116608. * @param force Specifies if the updraft should be disposed by force
  116609. */
  116610. dispose(force?: boolean): void;
  116611. private getImpostorHitData;
  116612. private _tick;
  116613. /*** Helpers ***/
  116614. private _prepareCylinder;
  116615. private _intersectsWithCylinder;
  116616. }
  116617. /**
  116618. * Represents a physics vortex event
  116619. */
  116620. class PhysicsVortexEvent {
  116621. private _scene;
  116622. private _origin;
  116623. private _options;
  116624. private _physicsEngine;
  116625. private _originTop;
  116626. private _tickCallback;
  116627. private _cylinder;
  116628. private _cylinderPosition;
  116629. private _dataFetched;
  116630. /**
  116631. * Initializes the physics vortex event
  116632. * @param _scene The BabylonJS scene
  116633. * @param _origin The origin position of the vortex
  116634. * @param _options The options for the vortex event
  116635. */
  116636. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  116637. /**
  116638. * Returns the data related to the vortex event (cylinder).
  116639. * @returns The physics vortex event data
  116640. */
  116641. getData(): PhysicsVortexEventData;
  116642. /**
  116643. * Enables the vortex.
  116644. */
  116645. enable(): void;
  116646. /**
  116647. * Disables the cortex.
  116648. */
  116649. disable(): void;
  116650. /**
  116651. * Disposes the sphere.
  116652. * @param force
  116653. */
  116654. dispose(force?: boolean): void;
  116655. private getImpostorHitData;
  116656. private _tick;
  116657. /*** Helpers ***/
  116658. private _prepareCylinder;
  116659. private _intersectsWithCylinder;
  116660. }
  116661. /**
  116662. * Options fot the radial explosion event
  116663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116664. */
  116665. export class PhysicsRadialExplosionEventOptions {
  116666. /**
  116667. * The radius of the sphere for the radial explosion.
  116668. */
  116669. radius: number;
  116670. /**
  116671. * The strenth of the explosion.
  116672. */
  116673. strength: number;
  116674. /**
  116675. * The strenght of the force in correspondence to the distance of the affected object
  116676. */
  116677. falloff: PhysicsRadialImpulseFalloff;
  116678. /**
  116679. * Sphere options for the radial explosion.
  116680. */
  116681. sphere: {
  116682. segments: number;
  116683. diameter: number;
  116684. };
  116685. /**
  116686. * Sphere options for the radial explosion.
  116687. */
  116688. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  116689. }
  116690. /**
  116691. * Options fot the updraft event
  116692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116693. */
  116694. export class PhysicsUpdraftEventOptions {
  116695. /**
  116696. * The radius of the cylinder for the vortex
  116697. */
  116698. radius: number;
  116699. /**
  116700. * The strenth of the updraft.
  116701. */
  116702. strength: number;
  116703. /**
  116704. * The height of the cylinder for the updraft.
  116705. */
  116706. height: number;
  116707. /**
  116708. * The mode for the the updraft.
  116709. */
  116710. updraftMode: PhysicsUpdraftMode;
  116711. }
  116712. /**
  116713. * Options fot the vortex event
  116714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116715. */
  116716. export class PhysicsVortexEventOptions {
  116717. /**
  116718. * The radius of the cylinder for the vortex
  116719. */
  116720. radius: number;
  116721. /**
  116722. * The strenth of the vortex.
  116723. */
  116724. strength: number;
  116725. /**
  116726. * The height of the cylinder for the vortex.
  116727. */
  116728. height: number;
  116729. /**
  116730. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  116731. */
  116732. centripetalForceThreshold: number;
  116733. /**
  116734. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  116735. */
  116736. centripetalForceMultiplier: number;
  116737. /**
  116738. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  116739. */
  116740. centrifugalForceMultiplier: number;
  116741. /**
  116742. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  116743. */
  116744. updraftForceMultiplier: number;
  116745. }
  116746. /**
  116747. * The strenght of the force in correspondence to the distance of the affected object
  116748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116749. */
  116750. export enum PhysicsRadialImpulseFalloff {
  116751. /** Defines that impulse is constant in strength across it's whole radius */
  116752. Constant = 0,
  116753. /** Defines that impulse gets weaker if it's further from the origin */
  116754. Linear = 1
  116755. }
  116756. /**
  116757. * The strength of the force in correspondence to the distance of the affected object
  116758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116759. */
  116760. export enum PhysicsUpdraftMode {
  116761. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  116762. Center = 0,
  116763. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  116764. Perpendicular = 1
  116765. }
  116766. /**
  116767. * Interface for a physics hit data
  116768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116769. */
  116770. export interface PhysicsHitData {
  116771. /**
  116772. * The force applied at the contact point
  116773. */
  116774. force: Vector3;
  116775. /**
  116776. * The contact point
  116777. */
  116778. contactPoint: Vector3;
  116779. /**
  116780. * The distance from the origin to the contact point
  116781. */
  116782. distanceFromOrigin: number;
  116783. }
  116784. /**
  116785. * Interface for radial explosion event data
  116786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116787. */
  116788. export interface PhysicsRadialExplosionEventData {
  116789. /**
  116790. * A sphere used for the radial explosion event
  116791. */
  116792. sphere: Mesh;
  116793. }
  116794. /**
  116795. * Interface for gravitational field event data
  116796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116797. */
  116798. export interface PhysicsGravitationalFieldEventData {
  116799. /**
  116800. * A sphere mesh used for the gravitational field event
  116801. */
  116802. sphere: Mesh;
  116803. }
  116804. /**
  116805. * Interface for updraft event data
  116806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116807. */
  116808. export interface PhysicsUpdraftEventData {
  116809. /**
  116810. * A cylinder used for the updraft event
  116811. */
  116812. cylinder: Mesh;
  116813. }
  116814. /**
  116815. * Interface for vortex event data
  116816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116817. */
  116818. export interface PhysicsVortexEventData {
  116819. /**
  116820. * A cylinder used for the vortex event
  116821. */
  116822. cylinder: Mesh;
  116823. }
  116824. /**
  116825. * Interface for an affected physics impostor
  116826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116827. */
  116828. export interface PhysicsAffectedImpostorWithData {
  116829. /**
  116830. * The impostor affected by the effect
  116831. */
  116832. impostor: PhysicsImpostor;
  116833. /**
  116834. * The data about the hit/horce from the explosion
  116835. */
  116836. hitData: PhysicsHitData;
  116837. }
  116838. }
  116839. declare module BABYLON {
  116840. /** @hidden */
  116841. export var blackAndWhitePixelShader: {
  116842. name: string;
  116843. shader: string;
  116844. };
  116845. }
  116846. declare module BABYLON {
  116847. /**
  116848. * Post process used to render in black and white
  116849. */
  116850. export class BlackAndWhitePostProcess extends PostProcess {
  116851. /**
  116852. * Linear about to convert he result to black and white (default: 1)
  116853. */
  116854. degree: number;
  116855. /**
  116856. * Creates a black and white post process
  116857. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116858. * @param name The name of the effect.
  116859. * @param options The required width/height ratio to downsize to before computing the render pass.
  116860. * @param camera The camera to apply the render pass to.
  116861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116862. * @param engine The engine which the post process will be applied. (default: current engine)
  116863. * @param reusable If the post process can be reused on the same frame. (default: false)
  116864. */
  116865. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116866. }
  116867. }
  116868. declare module BABYLON {
  116869. /**
  116870. * This represents a set of one or more post processes in Babylon.
  116871. * A post process can be used to apply a shader to a texture after it is rendered.
  116872. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116873. */
  116874. export class PostProcessRenderEffect {
  116875. private _postProcesses;
  116876. private _getPostProcesses;
  116877. private _singleInstance;
  116878. private _cameras;
  116879. private _indicesForCamera;
  116880. /**
  116881. * Name of the effect
  116882. * @hidden
  116883. */
  116884. _name: string;
  116885. /**
  116886. * Instantiates a post process render effect.
  116887. * A post process can be used to apply a shader to a texture after it is rendered.
  116888. * @param engine The engine the effect is tied to
  116889. * @param name The name of the effect
  116890. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  116891. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  116892. */
  116893. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  116894. /**
  116895. * Checks if all the post processes in the effect are supported.
  116896. */
  116897. readonly isSupported: boolean;
  116898. /**
  116899. * Updates the current state of the effect
  116900. * @hidden
  116901. */
  116902. _update(): void;
  116903. /**
  116904. * Attaches the effect on cameras
  116905. * @param cameras The camera to attach to.
  116906. * @hidden
  116907. */
  116908. _attachCameras(cameras: Camera): void;
  116909. /**
  116910. * Attaches the effect on cameras
  116911. * @param cameras The camera to attach to.
  116912. * @hidden
  116913. */
  116914. _attachCameras(cameras: Camera[]): void;
  116915. /**
  116916. * Detaches the effect on cameras
  116917. * @param cameras The camera to detatch from.
  116918. * @hidden
  116919. */
  116920. _detachCameras(cameras: Camera): void;
  116921. /**
  116922. * Detatches the effect on cameras
  116923. * @param cameras The camera to detatch from.
  116924. * @hidden
  116925. */
  116926. _detachCameras(cameras: Camera[]): void;
  116927. /**
  116928. * Enables the effect on given cameras
  116929. * @param cameras The camera to enable.
  116930. * @hidden
  116931. */
  116932. _enable(cameras: Camera): void;
  116933. /**
  116934. * Enables the effect on given cameras
  116935. * @param cameras The camera to enable.
  116936. * @hidden
  116937. */
  116938. _enable(cameras: Nullable<Camera[]>): void;
  116939. /**
  116940. * Disables the effect on the given cameras
  116941. * @param cameras The camera to disable.
  116942. * @hidden
  116943. */
  116944. _disable(cameras: Camera): void;
  116945. /**
  116946. * Disables the effect on the given cameras
  116947. * @param cameras The camera to disable.
  116948. * @hidden
  116949. */
  116950. _disable(cameras: Nullable<Camera[]>): void;
  116951. /**
  116952. * Gets a list of the post processes contained in the effect.
  116953. * @param camera The camera to get the post processes on.
  116954. * @returns The list of the post processes in the effect.
  116955. */
  116956. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  116957. }
  116958. }
  116959. declare module BABYLON {
  116960. /** @hidden */
  116961. export var extractHighlightsPixelShader: {
  116962. name: string;
  116963. shader: string;
  116964. };
  116965. }
  116966. declare module BABYLON {
  116967. /**
  116968. * 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.
  116969. */
  116970. export class ExtractHighlightsPostProcess extends PostProcess {
  116971. /**
  116972. * The luminance threshold, pixels below this value will be set to black.
  116973. */
  116974. threshold: number;
  116975. /** @hidden */
  116976. _exposure: number;
  116977. /**
  116978. * Post process which has the input texture to be used when performing highlight extraction
  116979. * @hidden
  116980. */
  116981. _inputPostProcess: Nullable<PostProcess>;
  116982. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116983. }
  116984. }
  116985. declare module BABYLON {
  116986. /** @hidden */
  116987. export var bloomMergePixelShader: {
  116988. name: string;
  116989. shader: string;
  116990. };
  116991. }
  116992. declare module BABYLON {
  116993. /**
  116994. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116995. */
  116996. export class BloomMergePostProcess extends PostProcess {
  116997. /** Weight of the bloom to be added to the original input. */
  116998. weight: number;
  116999. /**
  117000. * Creates a new instance of @see BloomMergePostProcess
  117001. * @param name The name of the effect.
  117002. * @param originalFromInput Post process which's input will be used for the merge.
  117003. * @param blurred Blurred highlights post process which's output will be used.
  117004. * @param weight Weight of the bloom to be added to the original input.
  117005. * @param options The required width/height ratio to downsize to before computing the render pass.
  117006. * @param camera The camera to apply the render pass to.
  117007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117008. * @param engine The engine which the post process will be applied. (default: current engine)
  117009. * @param reusable If the post process can be reused on the same frame. (default: false)
  117010. * @param textureType Type of textures used when performing the post process. (default: 0)
  117011. * @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)
  117012. */
  117013. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117014. /** Weight of the bloom to be added to the original input. */
  117015. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117016. }
  117017. }
  117018. declare module BABYLON {
  117019. /**
  117020. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117021. */
  117022. export class BloomEffect extends PostProcessRenderEffect {
  117023. private bloomScale;
  117024. /**
  117025. * @hidden Internal
  117026. */
  117027. _effects: Array<PostProcess>;
  117028. /**
  117029. * @hidden Internal
  117030. */
  117031. _downscale: ExtractHighlightsPostProcess;
  117032. private _blurX;
  117033. private _blurY;
  117034. private _merge;
  117035. /**
  117036. * The luminance threshold to find bright areas of the image to bloom.
  117037. */
  117038. threshold: number;
  117039. /**
  117040. * The strength of the bloom.
  117041. */
  117042. weight: number;
  117043. /**
  117044. * Specifies the size of the bloom blur kernel, relative to the final output size
  117045. */
  117046. kernel: number;
  117047. /**
  117048. * Creates a new instance of @see BloomEffect
  117049. * @param scene The scene the effect belongs to.
  117050. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117051. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117052. * @param bloomWeight The the strength of bloom.
  117053. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117054. * @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)
  117055. */
  117056. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117057. /**
  117058. * Disposes each of the internal effects for a given camera.
  117059. * @param camera The camera to dispose the effect on.
  117060. */
  117061. disposeEffects(camera: Camera): void;
  117062. /**
  117063. * @hidden Internal
  117064. */
  117065. _updateEffects(): void;
  117066. /**
  117067. * Internal
  117068. * @returns if all the contained post processes are ready.
  117069. * @hidden
  117070. */
  117071. _isReady(): boolean;
  117072. }
  117073. }
  117074. declare module BABYLON {
  117075. /** @hidden */
  117076. export var chromaticAberrationPixelShader: {
  117077. name: string;
  117078. shader: string;
  117079. };
  117080. }
  117081. declare module BABYLON {
  117082. /**
  117083. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117084. */
  117085. export class ChromaticAberrationPostProcess extends PostProcess {
  117086. /**
  117087. * The amount of seperation of rgb channels (default: 30)
  117088. */
  117089. aberrationAmount: number;
  117090. /**
  117091. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117092. */
  117093. radialIntensity: number;
  117094. /**
  117095. * 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))
  117096. */
  117097. direction: Vector2;
  117098. /**
  117099. * 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))
  117100. */
  117101. centerPosition: Vector2;
  117102. /**
  117103. * Creates a new instance ChromaticAberrationPostProcess
  117104. * @param name The name of the effect.
  117105. * @param screenWidth The width of the screen to apply the effect on.
  117106. * @param screenHeight The height of the screen to apply the effect on.
  117107. * @param options The required width/height ratio to downsize to before computing the render pass.
  117108. * @param camera The camera to apply the render pass to.
  117109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117110. * @param engine The engine which the post process will be applied. (default: current engine)
  117111. * @param reusable If the post process can be reused on the same frame. (default: false)
  117112. * @param textureType Type of textures used when performing the post process. (default: 0)
  117113. * @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)
  117114. */
  117115. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117116. }
  117117. }
  117118. declare module BABYLON {
  117119. /** @hidden */
  117120. export var circleOfConfusionPixelShader: {
  117121. name: string;
  117122. shader: string;
  117123. };
  117124. }
  117125. declare module BABYLON {
  117126. /**
  117127. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117128. */
  117129. export class CircleOfConfusionPostProcess extends PostProcess {
  117130. /**
  117131. * 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.
  117132. */
  117133. lensSize: number;
  117134. /**
  117135. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117136. */
  117137. fStop: number;
  117138. /**
  117139. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117140. */
  117141. focusDistance: number;
  117142. /**
  117143. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117144. */
  117145. focalLength: number;
  117146. private _depthTexture;
  117147. /**
  117148. * Creates a new instance CircleOfConfusionPostProcess
  117149. * @param name The name of the effect.
  117150. * @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.
  117151. * @param options The required width/height ratio to downsize to before computing the render pass.
  117152. * @param camera The camera to apply the render pass to.
  117153. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117154. * @param engine The engine which the post process will be applied. (default: current engine)
  117155. * @param reusable If the post process can be reused on the same frame. (default: false)
  117156. * @param textureType Type of textures used when performing the post process. (default: 0)
  117157. * @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)
  117158. */
  117159. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117160. /**
  117161. * 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.
  117162. */
  117163. depthTexture: RenderTargetTexture;
  117164. }
  117165. }
  117166. declare module BABYLON {
  117167. /** @hidden */
  117168. export var colorCorrectionPixelShader: {
  117169. name: string;
  117170. shader: string;
  117171. };
  117172. }
  117173. declare module BABYLON {
  117174. /**
  117175. *
  117176. * This post-process allows the modification of rendered colors by using
  117177. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117178. *
  117179. * The object needs to be provided an url to a texture containing the color
  117180. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117181. * Use an image editing software to tweak the LUT to match your needs.
  117182. *
  117183. * For an example of a color LUT, see here:
  117184. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117185. * For explanations on color grading, see here:
  117186. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117187. *
  117188. */
  117189. export class ColorCorrectionPostProcess extends PostProcess {
  117190. private _colorTableTexture;
  117191. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117192. }
  117193. }
  117194. declare module BABYLON {
  117195. /** @hidden */
  117196. export var convolutionPixelShader: {
  117197. name: string;
  117198. shader: string;
  117199. };
  117200. }
  117201. declare module BABYLON {
  117202. /**
  117203. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117204. * input texture to perform effects such as edge detection or sharpening
  117205. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117206. */
  117207. export class ConvolutionPostProcess extends PostProcess {
  117208. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117209. kernel: number[];
  117210. /**
  117211. * Creates a new instance ConvolutionPostProcess
  117212. * @param name The name of the effect.
  117213. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  117214. * @param options The required width/height ratio to downsize to before computing the render pass.
  117215. * @param camera The camera to apply the render pass to.
  117216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117217. * @param engine The engine which the post process will be applied. (default: current engine)
  117218. * @param reusable If the post process can be reused on the same frame. (default: false)
  117219. * @param textureType Type of textures used when performing the post process. (default: 0)
  117220. */
  117221. constructor(name: string,
  117222. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117223. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117224. /**
  117225. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117226. */
  117227. static EdgeDetect0Kernel: number[];
  117228. /**
  117229. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117230. */
  117231. static EdgeDetect1Kernel: number[];
  117232. /**
  117233. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117234. */
  117235. static EdgeDetect2Kernel: number[];
  117236. /**
  117237. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117238. */
  117239. static SharpenKernel: number[];
  117240. /**
  117241. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117242. */
  117243. static EmbossKernel: number[];
  117244. /**
  117245. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117246. */
  117247. static GaussianKernel: number[];
  117248. }
  117249. }
  117250. declare module BABYLON {
  117251. /**
  117252. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117253. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117254. * based on samples that have a large difference in distance than the center pixel.
  117255. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117256. */
  117257. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  117258. direction: Vector2;
  117259. /**
  117260. * Creates a new instance CircleOfConfusionPostProcess
  117261. * @param name The name of the effect.
  117262. * @param scene The scene the effect belongs to.
  117263. * @param direction The direction the blur should be applied.
  117264. * @param kernel The size of the kernel used to blur.
  117265. * @param options The required width/height ratio to downsize to before computing the render pass.
  117266. * @param camera The camera to apply the render pass to.
  117267. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117268. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117269. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117270. * @param engine The engine which the post process will be applied. (default: current engine)
  117271. * @param reusable If the post process can be reused on the same frame. (default: false)
  117272. * @param textureType Type of textures used when performing the post process. (default: 0)
  117273. * @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)
  117274. */
  117275. 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);
  117276. }
  117277. }
  117278. declare module BABYLON {
  117279. /** @hidden */
  117280. export var depthOfFieldMergePixelShader: {
  117281. name: string;
  117282. shader: string;
  117283. };
  117284. }
  117285. declare module BABYLON {
  117286. /**
  117287. * Options to be set when merging outputs from the default pipeline.
  117288. */
  117289. export class DepthOfFieldMergePostProcessOptions {
  117290. /**
  117291. * The original image to merge on top of
  117292. */
  117293. originalFromInput: PostProcess;
  117294. /**
  117295. * Parameters to perform the merge of the depth of field effect
  117296. */
  117297. depthOfField?: {
  117298. circleOfConfusion: PostProcess;
  117299. blurSteps: Array<PostProcess>;
  117300. };
  117301. /**
  117302. * Parameters to perform the merge of bloom effect
  117303. */
  117304. bloom?: {
  117305. blurred: PostProcess;
  117306. weight: number;
  117307. };
  117308. }
  117309. /**
  117310. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117311. */
  117312. export class DepthOfFieldMergePostProcess extends PostProcess {
  117313. private blurSteps;
  117314. /**
  117315. * Creates a new instance of DepthOfFieldMergePostProcess
  117316. * @param name The name of the effect.
  117317. * @param originalFromInput Post process which's input will be used for the merge.
  117318. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  117319. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  117320. * @param options The required width/height ratio to downsize to before computing the render pass.
  117321. * @param camera The camera to apply the render pass to.
  117322. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117323. * @param engine The engine which the post process will be applied. (default: current engine)
  117324. * @param reusable If the post process can be reused on the same frame. (default: false)
  117325. * @param textureType Type of textures used when performing the post process. (default: 0)
  117326. * @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)
  117327. */
  117328. 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);
  117329. /**
  117330. * Updates the effect with the current post process compile time values and recompiles the shader.
  117331. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117332. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117333. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117334. * @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
  117335. * @param onCompiled Called when the shader has been compiled.
  117336. * @param onError Called if there is an error when compiling a shader.
  117337. */
  117338. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  117339. }
  117340. }
  117341. declare module BABYLON {
  117342. /**
  117343. * Specifies the level of max blur that should be applied when using the depth of field effect
  117344. */
  117345. export enum DepthOfFieldEffectBlurLevel {
  117346. /**
  117347. * Subtle blur
  117348. */
  117349. Low = 0,
  117350. /**
  117351. * Medium blur
  117352. */
  117353. Medium = 1,
  117354. /**
  117355. * Large blur
  117356. */
  117357. High = 2
  117358. }
  117359. /**
  117360. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117361. */
  117362. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  117363. private _circleOfConfusion;
  117364. /**
  117365. * @hidden Internal, blurs from high to low
  117366. */
  117367. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  117368. private _depthOfFieldBlurY;
  117369. private _dofMerge;
  117370. /**
  117371. * @hidden Internal post processes in depth of field effect
  117372. */
  117373. _effects: Array<PostProcess>;
  117374. /**
  117375. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117376. */
  117377. focalLength: number;
  117378. /**
  117379. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117380. */
  117381. fStop: number;
  117382. /**
  117383. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117384. */
  117385. focusDistance: number;
  117386. /**
  117387. * 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.
  117388. */
  117389. lensSize: number;
  117390. /**
  117391. * Creates a new instance DepthOfFieldEffect
  117392. * @param scene The scene the effect belongs to.
  117393. * @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.
  117394. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117395. * @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)
  117396. */
  117397. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  117398. /**
  117399. * Get the current class name of the current effet
  117400. * @returns "DepthOfFieldEffect"
  117401. */
  117402. getClassName(): string;
  117403. /**
  117404. * 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.
  117405. */
  117406. depthTexture: RenderTargetTexture;
  117407. /**
  117408. * Disposes each of the internal effects for a given camera.
  117409. * @param camera The camera to dispose the effect on.
  117410. */
  117411. disposeEffects(camera: Camera): void;
  117412. /**
  117413. * @hidden Internal
  117414. */
  117415. _updateEffects(): void;
  117416. /**
  117417. * Internal
  117418. * @returns if all the contained post processes are ready.
  117419. * @hidden
  117420. */
  117421. _isReady(): boolean;
  117422. }
  117423. }
  117424. declare module BABYLON {
  117425. /** @hidden */
  117426. export var displayPassPixelShader: {
  117427. name: string;
  117428. shader: string;
  117429. };
  117430. }
  117431. declare module BABYLON {
  117432. /**
  117433. * DisplayPassPostProcess which produces an output the same as it's input
  117434. */
  117435. export class DisplayPassPostProcess extends PostProcess {
  117436. /**
  117437. * Creates the DisplayPassPostProcess
  117438. * @param name The name of the effect.
  117439. * @param options The required width/height ratio to downsize to before computing the render pass.
  117440. * @param camera The camera to apply the render pass to.
  117441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117442. * @param engine The engine which the post process will be applied. (default: current engine)
  117443. * @param reusable If the post process can be reused on the same frame. (default: false)
  117444. */
  117445. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117446. }
  117447. }
  117448. declare module BABYLON {
  117449. /** @hidden */
  117450. export var filterPixelShader: {
  117451. name: string;
  117452. shader: string;
  117453. };
  117454. }
  117455. declare module BABYLON {
  117456. /**
  117457. * Applies a kernel filter to the image
  117458. */
  117459. export class FilterPostProcess extends PostProcess {
  117460. /** The matrix to be applied to the image */
  117461. kernelMatrix: Matrix;
  117462. /**
  117463. *
  117464. * @param name The name of the effect.
  117465. * @param kernelMatrix The matrix to be applied to the image
  117466. * @param options The required width/height ratio to downsize to before computing the render pass.
  117467. * @param camera The camera to apply the render pass to.
  117468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117469. * @param engine The engine which the post process will be applied. (default: current engine)
  117470. * @param reusable If the post process can be reused on the same frame. (default: false)
  117471. */
  117472. constructor(name: string,
  117473. /** The matrix to be applied to the image */
  117474. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117475. }
  117476. }
  117477. declare module BABYLON {
  117478. /** @hidden */
  117479. export var fxaaPixelShader: {
  117480. name: string;
  117481. shader: string;
  117482. };
  117483. }
  117484. declare module BABYLON {
  117485. /** @hidden */
  117486. export var fxaaVertexShader: {
  117487. name: string;
  117488. shader: string;
  117489. };
  117490. }
  117491. declare module BABYLON {
  117492. /**
  117493. * Fxaa post process
  117494. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  117495. */
  117496. export class FxaaPostProcess extends PostProcess {
  117497. /** @hidden */
  117498. texelWidth: number;
  117499. /** @hidden */
  117500. texelHeight: number;
  117501. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117502. private _getDefines;
  117503. }
  117504. }
  117505. declare module BABYLON {
  117506. /** @hidden */
  117507. export var grainPixelShader: {
  117508. name: string;
  117509. shader: string;
  117510. };
  117511. }
  117512. declare module BABYLON {
  117513. /**
  117514. * The GrainPostProcess adds noise to the image at mid luminance levels
  117515. */
  117516. export class GrainPostProcess extends PostProcess {
  117517. /**
  117518. * The intensity of the grain added (default: 30)
  117519. */
  117520. intensity: number;
  117521. /**
  117522. * If the grain should be randomized on every frame
  117523. */
  117524. animated: boolean;
  117525. /**
  117526. * Creates a new instance of @see GrainPostProcess
  117527. * @param name The name of the effect.
  117528. * @param options The required width/height ratio to downsize to before computing the render pass.
  117529. * @param camera The camera to apply the render pass to.
  117530. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117531. * @param engine The engine which the post process will be applied. (default: current engine)
  117532. * @param reusable If the post process can be reused on the same frame. (default: false)
  117533. * @param textureType Type of textures used when performing the post process. (default: 0)
  117534. * @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)
  117535. */
  117536. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117537. }
  117538. }
  117539. declare module BABYLON {
  117540. /** @hidden */
  117541. export var highlightsPixelShader: {
  117542. name: string;
  117543. shader: string;
  117544. };
  117545. }
  117546. declare module BABYLON {
  117547. /**
  117548. * Extracts highlights from the image
  117549. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117550. */
  117551. export class HighlightsPostProcess extends PostProcess {
  117552. /**
  117553. * Extracts highlights from the image
  117554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117555. * @param name The name of the effect.
  117556. * @param options The required width/height ratio to downsize to before computing the render pass.
  117557. * @param camera The camera to apply the render pass to.
  117558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117559. * @param engine The engine which the post process will be applied. (default: current engine)
  117560. * @param reusable If the post process can be reused on the same frame. (default: false)
  117561. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117562. */
  117563. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117564. }
  117565. }
  117566. declare module BABYLON {
  117567. /** @hidden */
  117568. export var mrtFragmentDeclaration: {
  117569. name: string;
  117570. shader: string;
  117571. };
  117572. }
  117573. declare module BABYLON {
  117574. /** @hidden */
  117575. export var geometryPixelShader: {
  117576. name: string;
  117577. shader: string;
  117578. };
  117579. }
  117580. declare module BABYLON {
  117581. /** @hidden */
  117582. export var geometryVertexShader: {
  117583. name: string;
  117584. shader: string;
  117585. };
  117586. }
  117587. declare module BABYLON {
  117588. /** @hidden */
  117589. interface ISavedTransformationMatrix {
  117590. world: Matrix;
  117591. viewProjection: Matrix;
  117592. }
  117593. /**
  117594. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  117595. */
  117596. export class GeometryBufferRenderer {
  117597. /**
  117598. * Constant used to retrieve the position texture index in the G-Buffer textures array
  117599. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  117600. */
  117601. static readonly POSITION_TEXTURE_TYPE: number;
  117602. /**
  117603. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  117604. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  117605. */
  117606. static readonly VELOCITY_TEXTURE_TYPE: number;
  117607. /**
  117608. * Dictionary used to store the previous transformation matrices of each rendered mesh
  117609. * in order to compute objects velocities when enableVelocity is set to "true"
  117610. * @hidden
  117611. */
  117612. _previousTransformationMatrices: {
  117613. [index: number]: ISavedTransformationMatrix;
  117614. };
  117615. /**
  117616. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  117617. * in order to compute objects velocities when enableVelocity is set to "true"
  117618. * @hidden
  117619. */
  117620. _previousBonesTransformationMatrices: {
  117621. [index: number]: Float32Array;
  117622. };
  117623. /**
  117624. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  117625. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  117626. */
  117627. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  117628. private _scene;
  117629. private _multiRenderTarget;
  117630. private _ratio;
  117631. private _enablePosition;
  117632. private _enableVelocity;
  117633. private _positionIndex;
  117634. private _velocityIndex;
  117635. protected _effect: Effect;
  117636. protected _cachedDefines: string;
  117637. /**
  117638. * Set the render list (meshes to be rendered) used in the G buffer.
  117639. */
  117640. renderList: Mesh[];
  117641. /**
  117642. * Gets wether or not G buffer are supported by the running hardware.
  117643. * This requires draw buffer supports
  117644. */
  117645. readonly isSupported: boolean;
  117646. /**
  117647. * Returns the index of the given texture type in the G-Buffer textures array
  117648. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  117649. * @returns the index of the given texture type in the G-Buffer textures array
  117650. */
  117651. getTextureIndex(textureType: number): number;
  117652. /**
  117653. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  117654. */
  117655. /**
  117656. * Sets whether or not objects positions are enabled for the G buffer.
  117657. */
  117658. enablePosition: boolean;
  117659. /**
  117660. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  117661. */
  117662. /**
  117663. * Sets wether or not objects velocities are enabled for the G buffer.
  117664. */
  117665. enableVelocity: boolean;
  117666. /**
  117667. * Gets the scene associated with the buffer.
  117668. */
  117669. readonly scene: Scene;
  117670. /**
  117671. * Gets the ratio used by the buffer during its creation.
  117672. * How big is the buffer related to the main canvas.
  117673. */
  117674. readonly ratio: number;
  117675. /** @hidden */
  117676. static _SceneComponentInitialization: (scene: Scene) => void;
  117677. /**
  117678. * Creates a new G Buffer for the scene
  117679. * @param scene The scene the buffer belongs to
  117680. * @param ratio How big is the buffer related to the main canvas.
  117681. */
  117682. constructor(scene: Scene, ratio?: number);
  117683. /**
  117684. * Checks wether everything is ready to render a submesh to the G buffer.
  117685. * @param subMesh the submesh to check readiness for
  117686. * @param useInstances is the mesh drawn using instance or not
  117687. * @returns true if ready otherwise false
  117688. */
  117689. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117690. /**
  117691. * Gets the current underlying G Buffer.
  117692. * @returns the buffer
  117693. */
  117694. getGBuffer(): MultiRenderTarget;
  117695. /**
  117696. * Gets the number of samples used to render the buffer (anti aliasing).
  117697. */
  117698. /**
  117699. * Sets the number of samples used to render the buffer (anti aliasing).
  117700. */
  117701. samples: number;
  117702. /**
  117703. * Disposes the renderer and frees up associated resources.
  117704. */
  117705. dispose(): void;
  117706. protected _createRenderTargets(): void;
  117707. private _copyBonesTransformationMatrices;
  117708. }
  117709. }
  117710. declare module BABYLON {
  117711. interface Scene {
  117712. /** @hidden (Backing field) */
  117713. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117714. /**
  117715. * Gets or Sets the current geometry buffer associated to the scene.
  117716. */
  117717. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117718. /**
  117719. * Enables a GeometryBufferRender and associates it with the scene
  117720. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  117721. * @returns the GeometryBufferRenderer
  117722. */
  117723. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  117724. /**
  117725. * Disables the GeometryBufferRender associated with the scene
  117726. */
  117727. disableGeometryBufferRenderer(): void;
  117728. }
  117729. /**
  117730. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  117731. * in several rendering techniques.
  117732. */
  117733. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  117734. /**
  117735. * The component name helpful to identify the component in the list of scene components.
  117736. */
  117737. readonly name: string;
  117738. /**
  117739. * The scene the component belongs to.
  117740. */
  117741. scene: Scene;
  117742. /**
  117743. * Creates a new instance of the component for the given scene
  117744. * @param scene Defines the scene to register the component in
  117745. */
  117746. constructor(scene: Scene);
  117747. /**
  117748. * Registers the component in a given scene
  117749. */
  117750. register(): void;
  117751. /**
  117752. * Rebuilds the elements related to this component in case of
  117753. * context lost for instance.
  117754. */
  117755. rebuild(): void;
  117756. /**
  117757. * Disposes the component and the associated ressources
  117758. */
  117759. dispose(): void;
  117760. private _gatherRenderTargets;
  117761. }
  117762. }
  117763. declare module BABYLON {
  117764. /** @hidden */
  117765. export var motionBlurPixelShader: {
  117766. name: string;
  117767. shader: string;
  117768. };
  117769. }
  117770. declare module BABYLON {
  117771. /**
  117772. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117773. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117774. * As an example, all you have to do is to create the post-process:
  117775. * var mb = new BABYLON.MotionBlurPostProcess(
  117776. * 'mb', // The name of the effect.
  117777. * scene, // The scene containing the objects to blur according to their velocity.
  117778. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117779. * camera // The camera to apply the render pass to.
  117780. * );
  117781. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117782. */
  117783. export class MotionBlurPostProcess extends PostProcess {
  117784. /**
  117785. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117786. */
  117787. motionStrength: number;
  117788. /**
  117789. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117790. */
  117791. /**
  117792. * Sets the number of iterations to be used for motion blur quality
  117793. */
  117794. motionBlurSamples: number;
  117795. private _motionBlurSamples;
  117796. private _geometryBufferRenderer;
  117797. /**
  117798. * Creates a new instance MotionBlurPostProcess
  117799. * @param name The name of the effect.
  117800. * @param scene The scene containing the objects to blur according to their velocity.
  117801. * @param options The required width/height ratio to downsize to before computing the render pass.
  117802. * @param camera The camera to apply the render pass to.
  117803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117804. * @param engine The engine which the post process will be applied. (default: current engine)
  117805. * @param reusable If the post process can be reused on the same frame. (default: false)
  117806. * @param textureType Type of textures used when performing the post process. (default: 0)
  117807. * @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)
  117808. */
  117809. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117810. /**
  117811. * Excludes the given skinned mesh from computing bones velocities.
  117812. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  117813. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  117814. */
  117815. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117816. /**
  117817. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  117818. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  117819. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  117820. */
  117821. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117822. /**
  117823. * Disposes the post process.
  117824. * @param camera The camera to dispose the post process on.
  117825. */
  117826. dispose(camera?: Camera): void;
  117827. }
  117828. }
  117829. declare module BABYLON {
  117830. /** @hidden */
  117831. export var refractionPixelShader: {
  117832. name: string;
  117833. shader: string;
  117834. };
  117835. }
  117836. declare module BABYLON {
  117837. /**
  117838. * Post process which applies a refractin texture
  117839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117840. */
  117841. export class RefractionPostProcess extends PostProcess {
  117842. /** the base color of the refraction (used to taint the rendering) */
  117843. color: Color3;
  117844. /** simulated refraction depth */
  117845. depth: number;
  117846. /** the coefficient of the base color (0 to remove base color tainting) */
  117847. colorLevel: number;
  117848. private _refTexture;
  117849. private _ownRefractionTexture;
  117850. /**
  117851. * Gets or sets the refraction texture
  117852. * Please note that you are responsible for disposing the texture if you set it manually
  117853. */
  117854. refractionTexture: Texture;
  117855. /**
  117856. * Initializes the RefractionPostProcess
  117857. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117858. * @param name The name of the effect.
  117859. * @param refractionTextureUrl Url of the refraction texture to use
  117860. * @param color the base color of the refraction (used to taint the rendering)
  117861. * @param depth simulated refraction depth
  117862. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117863. * @param camera The camera to apply the render pass to.
  117864. * @param options The required width/height ratio to downsize to before computing the render pass.
  117865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117866. * @param engine The engine which the post process will be applied. (default: current engine)
  117867. * @param reusable If the post process can be reused on the same frame. (default: false)
  117868. */
  117869. constructor(name: string, refractionTextureUrl: string,
  117870. /** the base color of the refraction (used to taint the rendering) */
  117871. color: Color3,
  117872. /** simulated refraction depth */
  117873. depth: number,
  117874. /** the coefficient of the base color (0 to remove base color tainting) */
  117875. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117876. /**
  117877. * Disposes of the post process
  117878. * @param camera Camera to dispose post process on
  117879. */
  117880. dispose(camera: Camera): void;
  117881. }
  117882. }
  117883. declare module BABYLON {
  117884. /** @hidden */
  117885. export var sharpenPixelShader: {
  117886. name: string;
  117887. shader: string;
  117888. };
  117889. }
  117890. declare module BABYLON {
  117891. /**
  117892. * The SharpenPostProcess applies a sharpen kernel to every pixel
  117893. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117894. */
  117895. export class SharpenPostProcess extends PostProcess {
  117896. /**
  117897. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  117898. */
  117899. colorAmount: number;
  117900. /**
  117901. * How much sharpness should be applied (default: 0.3)
  117902. */
  117903. edgeAmount: number;
  117904. /**
  117905. * Creates a new instance ConvolutionPostProcess
  117906. * @param name The name of the effect.
  117907. * @param options The required width/height ratio to downsize to before computing the render pass.
  117908. * @param camera The camera to apply the render pass to.
  117909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117910. * @param engine The engine which the post process will be applied. (default: current engine)
  117911. * @param reusable If the post process can be reused on the same frame. (default: false)
  117912. * @param textureType Type of textures used when performing the post process. (default: 0)
  117913. * @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)
  117914. */
  117915. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117916. }
  117917. }
  117918. declare module BABYLON {
  117919. /**
  117920. * PostProcessRenderPipeline
  117921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117922. */
  117923. export class PostProcessRenderPipeline {
  117924. private engine;
  117925. private _renderEffects;
  117926. private _renderEffectsForIsolatedPass;
  117927. /**
  117928. * List of inspectable custom properties (used by the Inspector)
  117929. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117930. */
  117931. inspectableCustomProperties: IInspectable[];
  117932. /**
  117933. * @hidden
  117934. */
  117935. protected _cameras: Camera[];
  117936. /** @hidden */
  117937. _name: string;
  117938. /**
  117939. * Gets pipeline name
  117940. */
  117941. readonly name: string;
  117942. /**
  117943. * Initializes a PostProcessRenderPipeline
  117944. * @param engine engine to add the pipeline to
  117945. * @param name name of the pipeline
  117946. */
  117947. constructor(engine: Engine, name: string);
  117948. /**
  117949. * Gets the class name
  117950. * @returns "PostProcessRenderPipeline"
  117951. */
  117952. getClassName(): string;
  117953. /**
  117954. * If all the render effects in the pipeline are supported
  117955. */
  117956. readonly isSupported: boolean;
  117957. /**
  117958. * Adds an effect to the pipeline
  117959. * @param renderEffect the effect to add
  117960. */
  117961. addEffect(renderEffect: PostProcessRenderEffect): void;
  117962. /** @hidden */
  117963. _rebuild(): void;
  117964. /** @hidden */
  117965. _enableEffect(renderEffectName: string, cameras: Camera): void;
  117966. /** @hidden */
  117967. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  117968. /** @hidden */
  117969. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117970. /** @hidden */
  117971. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117972. /** @hidden */
  117973. _attachCameras(cameras: Camera, unique: boolean): void;
  117974. /** @hidden */
  117975. _attachCameras(cameras: Camera[], unique: boolean): void;
  117976. /** @hidden */
  117977. _detachCameras(cameras: Camera): void;
  117978. /** @hidden */
  117979. _detachCameras(cameras: Nullable<Camera[]>): void;
  117980. /** @hidden */
  117981. _update(): void;
  117982. /** @hidden */
  117983. _reset(): void;
  117984. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  117985. /**
  117986. * Disposes of the pipeline
  117987. */
  117988. dispose(): void;
  117989. }
  117990. }
  117991. declare module BABYLON {
  117992. /**
  117993. * PostProcessRenderPipelineManager class
  117994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117995. */
  117996. export class PostProcessRenderPipelineManager {
  117997. private _renderPipelines;
  117998. /**
  117999. * Initializes a PostProcessRenderPipelineManager
  118000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118001. */
  118002. constructor();
  118003. /**
  118004. * Gets the list of supported render pipelines
  118005. */
  118006. readonly supportedPipelines: PostProcessRenderPipeline[];
  118007. /**
  118008. * Adds a pipeline to the manager
  118009. * @param renderPipeline The pipeline to add
  118010. */
  118011. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118012. /**
  118013. * Attaches a camera to the pipeline
  118014. * @param renderPipelineName The name of the pipeline to attach to
  118015. * @param cameras the camera to attach
  118016. * @param unique if the camera can be attached multiple times to the pipeline
  118017. */
  118018. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118019. /**
  118020. * Detaches a camera from the pipeline
  118021. * @param renderPipelineName The name of the pipeline to detach from
  118022. * @param cameras the camera to detach
  118023. */
  118024. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118025. /**
  118026. * Enables an effect by name on a pipeline
  118027. * @param renderPipelineName the name of the pipeline to enable the effect in
  118028. * @param renderEffectName the name of the effect to enable
  118029. * @param cameras the cameras that the effect should be enabled on
  118030. */
  118031. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118032. /**
  118033. * Disables an effect by name on a pipeline
  118034. * @param renderPipelineName the name of the pipeline to disable the effect in
  118035. * @param renderEffectName the name of the effect to disable
  118036. * @param cameras the cameras that the effect should be disabled on
  118037. */
  118038. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118039. /**
  118040. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118041. */
  118042. update(): void;
  118043. /** @hidden */
  118044. _rebuild(): void;
  118045. /**
  118046. * Disposes of the manager and pipelines
  118047. */
  118048. dispose(): void;
  118049. }
  118050. }
  118051. declare module BABYLON {
  118052. interface Scene {
  118053. /** @hidden (Backing field) */
  118054. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118055. /**
  118056. * Gets the postprocess render pipeline manager
  118057. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118058. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118059. */
  118060. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118061. }
  118062. /**
  118063. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118064. */
  118065. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118066. /**
  118067. * The component name helpfull to identify the component in the list of scene components.
  118068. */
  118069. readonly name: string;
  118070. /**
  118071. * The scene the component belongs to.
  118072. */
  118073. scene: Scene;
  118074. /**
  118075. * Creates a new instance of the component for the given scene
  118076. * @param scene Defines the scene to register the component in
  118077. */
  118078. constructor(scene: Scene);
  118079. /**
  118080. * Registers the component in a given scene
  118081. */
  118082. register(): void;
  118083. /**
  118084. * Rebuilds the elements related to this component in case of
  118085. * context lost for instance.
  118086. */
  118087. rebuild(): void;
  118088. /**
  118089. * Disposes the component and the associated ressources
  118090. */
  118091. dispose(): void;
  118092. private _gatherRenderTargets;
  118093. }
  118094. }
  118095. declare module BABYLON {
  118096. /**
  118097. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118098. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118099. */
  118100. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118101. private _scene;
  118102. private _camerasToBeAttached;
  118103. /**
  118104. * ID of the sharpen post process,
  118105. */
  118106. private readonly SharpenPostProcessId;
  118107. /**
  118108. * @ignore
  118109. * ID of the image processing post process;
  118110. */
  118111. readonly ImageProcessingPostProcessId: string;
  118112. /**
  118113. * @ignore
  118114. * ID of the Fast Approximate Anti-Aliasing post process;
  118115. */
  118116. readonly FxaaPostProcessId: string;
  118117. /**
  118118. * ID of the chromatic aberration post process,
  118119. */
  118120. private readonly ChromaticAberrationPostProcessId;
  118121. /**
  118122. * ID of the grain post process
  118123. */
  118124. private readonly GrainPostProcessId;
  118125. /**
  118126. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118127. */
  118128. sharpen: SharpenPostProcess;
  118129. private _sharpenEffect;
  118130. private bloom;
  118131. /**
  118132. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118133. */
  118134. depthOfField: DepthOfFieldEffect;
  118135. /**
  118136. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118137. */
  118138. fxaa: FxaaPostProcess;
  118139. /**
  118140. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118141. */
  118142. imageProcessing: ImageProcessingPostProcess;
  118143. /**
  118144. * Chromatic aberration post process which will shift rgb colors in the image
  118145. */
  118146. chromaticAberration: ChromaticAberrationPostProcess;
  118147. private _chromaticAberrationEffect;
  118148. /**
  118149. * Grain post process which add noise to the image
  118150. */
  118151. grain: GrainPostProcess;
  118152. private _grainEffect;
  118153. /**
  118154. * Glow post process which adds a glow to emissive areas of the image
  118155. */
  118156. private _glowLayer;
  118157. /**
  118158. * Animations which can be used to tweak settings over a period of time
  118159. */
  118160. animations: Animation[];
  118161. private _imageProcessingConfigurationObserver;
  118162. private _sharpenEnabled;
  118163. private _bloomEnabled;
  118164. private _depthOfFieldEnabled;
  118165. private _depthOfFieldBlurLevel;
  118166. private _fxaaEnabled;
  118167. private _imageProcessingEnabled;
  118168. private _defaultPipelineTextureType;
  118169. private _bloomScale;
  118170. private _chromaticAberrationEnabled;
  118171. private _grainEnabled;
  118172. private _buildAllowed;
  118173. /**
  118174. * Gets active scene
  118175. */
  118176. readonly scene: Scene;
  118177. /**
  118178. * Enable or disable the sharpen process from the pipeline
  118179. */
  118180. sharpenEnabled: boolean;
  118181. private _resizeObserver;
  118182. private _hardwareScaleLevel;
  118183. private _bloomKernel;
  118184. /**
  118185. * Specifies the size of the bloom blur kernel, relative to the final output size
  118186. */
  118187. bloomKernel: number;
  118188. /**
  118189. * Specifies the weight of the bloom in the final rendering
  118190. */
  118191. private _bloomWeight;
  118192. /**
  118193. * Specifies the luma threshold for the area that will be blurred by the bloom
  118194. */
  118195. private _bloomThreshold;
  118196. private _hdr;
  118197. /**
  118198. * The strength of the bloom.
  118199. */
  118200. bloomWeight: number;
  118201. /**
  118202. * The strength of the bloom.
  118203. */
  118204. bloomThreshold: number;
  118205. /**
  118206. * The scale of the bloom, lower value will provide better performance.
  118207. */
  118208. bloomScale: number;
  118209. /**
  118210. * Enable or disable the bloom from the pipeline
  118211. */
  118212. bloomEnabled: boolean;
  118213. private _rebuildBloom;
  118214. /**
  118215. * If the depth of field is enabled.
  118216. */
  118217. depthOfFieldEnabled: boolean;
  118218. /**
  118219. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118220. */
  118221. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118222. /**
  118223. * If the anti aliasing is enabled.
  118224. */
  118225. fxaaEnabled: boolean;
  118226. private _samples;
  118227. /**
  118228. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118229. */
  118230. samples: number;
  118231. /**
  118232. * If image processing is enabled.
  118233. */
  118234. imageProcessingEnabled: boolean;
  118235. /**
  118236. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118237. */
  118238. glowLayerEnabled: boolean;
  118239. /**
  118240. * Gets the glow layer (or null if not defined)
  118241. */
  118242. readonly glowLayer: Nullable<GlowLayer>;
  118243. /**
  118244. * Enable or disable the chromaticAberration process from the pipeline
  118245. */
  118246. chromaticAberrationEnabled: boolean;
  118247. /**
  118248. * Enable or disable the grain process from the pipeline
  118249. */
  118250. grainEnabled: boolean;
  118251. /**
  118252. * @constructor
  118253. * @param name - The rendering pipeline name (default: "")
  118254. * @param hdr - If high dynamic range textures should be used (default: true)
  118255. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118256. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118257. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118258. */
  118259. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  118260. /**
  118261. * Get the class name
  118262. * @returns "DefaultRenderingPipeline"
  118263. */
  118264. getClassName(): string;
  118265. /**
  118266. * Force the compilation of the entire pipeline.
  118267. */
  118268. prepare(): void;
  118269. private _hasCleared;
  118270. private _prevPostProcess;
  118271. private _prevPrevPostProcess;
  118272. private _setAutoClearAndTextureSharing;
  118273. private _depthOfFieldSceneObserver;
  118274. private _buildPipeline;
  118275. private _disposePostProcesses;
  118276. /**
  118277. * Adds a camera to the pipeline
  118278. * @param camera the camera to be added
  118279. */
  118280. addCamera(camera: Camera): void;
  118281. /**
  118282. * Removes a camera from the pipeline
  118283. * @param camera the camera to remove
  118284. */
  118285. removeCamera(camera: Camera): void;
  118286. /**
  118287. * Dispose of the pipeline and stop all post processes
  118288. */
  118289. dispose(): void;
  118290. /**
  118291. * Serialize the rendering pipeline (Used when exporting)
  118292. * @returns the serialized object
  118293. */
  118294. serialize(): any;
  118295. /**
  118296. * Parse the serialized pipeline
  118297. * @param source Source pipeline.
  118298. * @param scene The scene to load the pipeline to.
  118299. * @param rootUrl The URL of the serialized pipeline.
  118300. * @returns An instantiated pipeline from the serialized object.
  118301. */
  118302. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  118303. }
  118304. }
  118305. declare module BABYLON {
  118306. /** @hidden */
  118307. export var lensHighlightsPixelShader: {
  118308. name: string;
  118309. shader: string;
  118310. };
  118311. }
  118312. declare module BABYLON {
  118313. /** @hidden */
  118314. export var depthOfFieldPixelShader: {
  118315. name: string;
  118316. shader: string;
  118317. };
  118318. }
  118319. declare module BABYLON {
  118320. /**
  118321. * BABYLON.JS Chromatic Aberration GLSL Shader
  118322. * Author: Olivier Guyot
  118323. * Separates very slightly R, G and B colors on the edges of the screen
  118324. * Inspired by Francois Tarlier & Martins Upitis
  118325. */
  118326. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  118327. /**
  118328. * @ignore
  118329. * The chromatic aberration PostProcess id in the pipeline
  118330. */
  118331. LensChromaticAberrationEffect: string;
  118332. /**
  118333. * @ignore
  118334. * The highlights enhancing PostProcess id in the pipeline
  118335. */
  118336. HighlightsEnhancingEffect: string;
  118337. /**
  118338. * @ignore
  118339. * The depth-of-field PostProcess id in the pipeline
  118340. */
  118341. LensDepthOfFieldEffect: string;
  118342. private _scene;
  118343. private _depthTexture;
  118344. private _grainTexture;
  118345. private _chromaticAberrationPostProcess;
  118346. private _highlightsPostProcess;
  118347. private _depthOfFieldPostProcess;
  118348. private _edgeBlur;
  118349. private _grainAmount;
  118350. private _chromaticAberration;
  118351. private _distortion;
  118352. private _highlightsGain;
  118353. private _highlightsThreshold;
  118354. private _dofDistance;
  118355. private _dofAperture;
  118356. private _dofDarken;
  118357. private _dofPentagon;
  118358. private _blurNoise;
  118359. /**
  118360. * @constructor
  118361. *
  118362. * Effect parameters are as follow:
  118363. * {
  118364. * chromatic_aberration: number; // from 0 to x (1 for realism)
  118365. * edge_blur: number; // from 0 to x (1 for realism)
  118366. * distortion: number; // from 0 to x (1 for realism)
  118367. * grain_amount: number; // from 0 to 1
  118368. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  118369. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  118370. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  118371. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  118372. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  118373. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  118374. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  118375. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  118376. * }
  118377. * Note: if an effect parameter is unset, effect is disabled
  118378. *
  118379. * @param name The rendering pipeline name
  118380. * @param parameters - An object containing all parameters (see above)
  118381. * @param scene The scene linked to this pipeline
  118382. * @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)
  118383. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118384. */
  118385. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  118386. /**
  118387. * Get the class name
  118388. * @returns "LensRenderingPipeline"
  118389. */
  118390. getClassName(): string;
  118391. /**
  118392. * Gets associated scene
  118393. */
  118394. readonly scene: Scene;
  118395. /**
  118396. * Gets or sets the edge blur
  118397. */
  118398. edgeBlur: number;
  118399. /**
  118400. * Gets or sets the grain amount
  118401. */
  118402. grainAmount: number;
  118403. /**
  118404. * Gets or sets the chromatic aberration amount
  118405. */
  118406. chromaticAberration: number;
  118407. /**
  118408. * Gets or sets the depth of field aperture
  118409. */
  118410. dofAperture: number;
  118411. /**
  118412. * Gets or sets the edge distortion
  118413. */
  118414. edgeDistortion: number;
  118415. /**
  118416. * Gets or sets the depth of field distortion
  118417. */
  118418. dofDistortion: number;
  118419. /**
  118420. * Gets or sets the darken out of focus amount
  118421. */
  118422. darkenOutOfFocus: number;
  118423. /**
  118424. * Gets or sets a boolean indicating if blur noise is enabled
  118425. */
  118426. blurNoise: boolean;
  118427. /**
  118428. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  118429. */
  118430. pentagonBokeh: boolean;
  118431. /**
  118432. * Gets or sets the highlight grain amount
  118433. */
  118434. highlightsGain: number;
  118435. /**
  118436. * Gets or sets the highlight threshold
  118437. */
  118438. highlightsThreshold: number;
  118439. /**
  118440. * Sets the amount of blur at the edges
  118441. * @param amount blur amount
  118442. */
  118443. setEdgeBlur(amount: number): void;
  118444. /**
  118445. * Sets edge blur to 0
  118446. */
  118447. disableEdgeBlur(): void;
  118448. /**
  118449. * Sets the amout of grain
  118450. * @param amount Amount of grain
  118451. */
  118452. setGrainAmount(amount: number): void;
  118453. /**
  118454. * Set grain amount to 0
  118455. */
  118456. disableGrain(): void;
  118457. /**
  118458. * Sets the chromatic aberration amount
  118459. * @param amount amount of chromatic aberration
  118460. */
  118461. setChromaticAberration(amount: number): void;
  118462. /**
  118463. * Sets chromatic aberration amount to 0
  118464. */
  118465. disableChromaticAberration(): void;
  118466. /**
  118467. * Sets the EdgeDistortion amount
  118468. * @param amount amount of EdgeDistortion
  118469. */
  118470. setEdgeDistortion(amount: number): void;
  118471. /**
  118472. * Sets edge distortion to 0
  118473. */
  118474. disableEdgeDistortion(): void;
  118475. /**
  118476. * Sets the FocusDistance amount
  118477. * @param amount amount of FocusDistance
  118478. */
  118479. setFocusDistance(amount: number): void;
  118480. /**
  118481. * Disables depth of field
  118482. */
  118483. disableDepthOfField(): void;
  118484. /**
  118485. * Sets the Aperture amount
  118486. * @param amount amount of Aperture
  118487. */
  118488. setAperture(amount: number): void;
  118489. /**
  118490. * Sets the DarkenOutOfFocus amount
  118491. * @param amount amount of DarkenOutOfFocus
  118492. */
  118493. setDarkenOutOfFocus(amount: number): void;
  118494. private _pentagonBokehIsEnabled;
  118495. /**
  118496. * Creates a pentagon bokeh effect
  118497. */
  118498. enablePentagonBokeh(): void;
  118499. /**
  118500. * Disables the pentagon bokeh effect
  118501. */
  118502. disablePentagonBokeh(): void;
  118503. /**
  118504. * Enables noise blur
  118505. */
  118506. enableNoiseBlur(): void;
  118507. /**
  118508. * Disables noise blur
  118509. */
  118510. disableNoiseBlur(): void;
  118511. /**
  118512. * Sets the HighlightsGain amount
  118513. * @param amount amount of HighlightsGain
  118514. */
  118515. setHighlightsGain(amount: number): void;
  118516. /**
  118517. * Sets the HighlightsThreshold amount
  118518. * @param amount amount of HighlightsThreshold
  118519. */
  118520. setHighlightsThreshold(amount: number): void;
  118521. /**
  118522. * Disables highlights
  118523. */
  118524. disableHighlights(): void;
  118525. /**
  118526. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  118527. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  118528. */
  118529. dispose(disableDepthRender?: boolean): void;
  118530. private _createChromaticAberrationPostProcess;
  118531. private _createHighlightsPostProcess;
  118532. private _createDepthOfFieldPostProcess;
  118533. private _createGrainTexture;
  118534. }
  118535. }
  118536. declare module BABYLON {
  118537. /** @hidden */
  118538. export var ssao2PixelShader: {
  118539. name: string;
  118540. shader: string;
  118541. };
  118542. }
  118543. declare module BABYLON {
  118544. /** @hidden */
  118545. export var ssaoCombinePixelShader: {
  118546. name: string;
  118547. shader: string;
  118548. };
  118549. }
  118550. declare module BABYLON {
  118551. /**
  118552. * Render pipeline to produce ssao effect
  118553. */
  118554. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118555. /**
  118556. * @ignore
  118557. * The PassPostProcess id in the pipeline that contains the original scene color
  118558. */
  118559. SSAOOriginalSceneColorEffect: string;
  118560. /**
  118561. * @ignore
  118562. * The SSAO PostProcess id in the pipeline
  118563. */
  118564. SSAORenderEffect: string;
  118565. /**
  118566. * @ignore
  118567. * The horizontal blur PostProcess id in the pipeline
  118568. */
  118569. SSAOBlurHRenderEffect: string;
  118570. /**
  118571. * @ignore
  118572. * The vertical blur PostProcess id in the pipeline
  118573. */
  118574. SSAOBlurVRenderEffect: string;
  118575. /**
  118576. * @ignore
  118577. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118578. */
  118579. SSAOCombineRenderEffect: string;
  118580. /**
  118581. * The output strength of the SSAO post-process. Default value is 1.0.
  118582. */
  118583. totalStrength: number;
  118584. /**
  118585. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118586. */
  118587. maxZ: number;
  118588. /**
  118589. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118590. */
  118591. minZAspect: number;
  118592. private _samples;
  118593. /**
  118594. * Number of samples used for the SSAO calculations. Default value is 8
  118595. */
  118596. samples: number;
  118597. private _textureSamples;
  118598. /**
  118599. * Number of samples to use for antialiasing
  118600. */
  118601. textureSamples: number;
  118602. /**
  118603. * Ratio object used for SSAO ratio and blur ratio
  118604. */
  118605. private _ratio;
  118606. /**
  118607. * Dynamically generated sphere sampler.
  118608. */
  118609. private _sampleSphere;
  118610. /**
  118611. * Blur filter offsets
  118612. */
  118613. private _samplerOffsets;
  118614. private _expensiveBlur;
  118615. /**
  118616. * If bilateral blur should be used
  118617. */
  118618. expensiveBlur: boolean;
  118619. /**
  118620. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118621. */
  118622. radius: number;
  118623. /**
  118624. * The base color of the SSAO post-process
  118625. * The final result is "base + ssao" between [0, 1]
  118626. */
  118627. base: number;
  118628. /**
  118629. * Support test.
  118630. */
  118631. static readonly IsSupported: boolean;
  118632. private _scene;
  118633. private _depthTexture;
  118634. private _normalTexture;
  118635. private _randomTexture;
  118636. private _originalColorPostProcess;
  118637. private _ssaoPostProcess;
  118638. private _blurHPostProcess;
  118639. private _blurVPostProcess;
  118640. private _ssaoCombinePostProcess;
  118641. private _firstUpdate;
  118642. /**
  118643. * Gets active scene
  118644. */
  118645. readonly scene: Scene;
  118646. /**
  118647. * @constructor
  118648. * @param name The rendering pipeline name
  118649. * @param scene The scene linked to this pipeline
  118650. * @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 }
  118651. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118652. */
  118653. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118654. /**
  118655. * Get the class name
  118656. * @returns "SSAO2RenderingPipeline"
  118657. */
  118658. getClassName(): string;
  118659. /**
  118660. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118661. */
  118662. dispose(disableGeometryBufferRenderer?: boolean): void;
  118663. private _createBlurPostProcess;
  118664. /** @hidden */
  118665. _rebuild(): void;
  118666. private _bits;
  118667. private _radicalInverse_VdC;
  118668. private _hammersley;
  118669. private _hemisphereSample_uniform;
  118670. private _generateHemisphere;
  118671. private _createSSAOPostProcess;
  118672. private _createSSAOCombinePostProcess;
  118673. private _createRandomTexture;
  118674. /**
  118675. * Serialize the rendering pipeline (Used when exporting)
  118676. * @returns the serialized object
  118677. */
  118678. serialize(): any;
  118679. /**
  118680. * Parse the serialized pipeline
  118681. * @param source Source pipeline.
  118682. * @param scene The scene to load the pipeline to.
  118683. * @param rootUrl The URL of the serialized pipeline.
  118684. * @returns An instantiated pipeline from the serialized object.
  118685. */
  118686. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  118687. }
  118688. }
  118689. declare module BABYLON {
  118690. /** @hidden */
  118691. export var ssaoPixelShader: {
  118692. name: string;
  118693. shader: string;
  118694. };
  118695. }
  118696. declare module BABYLON {
  118697. /**
  118698. * Render pipeline to produce ssao effect
  118699. */
  118700. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  118701. /**
  118702. * @ignore
  118703. * The PassPostProcess id in the pipeline that contains the original scene color
  118704. */
  118705. SSAOOriginalSceneColorEffect: string;
  118706. /**
  118707. * @ignore
  118708. * The SSAO PostProcess id in the pipeline
  118709. */
  118710. SSAORenderEffect: string;
  118711. /**
  118712. * @ignore
  118713. * The horizontal blur PostProcess id in the pipeline
  118714. */
  118715. SSAOBlurHRenderEffect: string;
  118716. /**
  118717. * @ignore
  118718. * The vertical blur PostProcess id in the pipeline
  118719. */
  118720. SSAOBlurVRenderEffect: string;
  118721. /**
  118722. * @ignore
  118723. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118724. */
  118725. SSAOCombineRenderEffect: string;
  118726. /**
  118727. * The output strength of the SSAO post-process. Default value is 1.0.
  118728. */
  118729. totalStrength: number;
  118730. /**
  118731. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  118732. */
  118733. radius: number;
  118734. /**
  118735. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  118736. * Must not be equal to fallOff and superior to fallOff.
  118737. * Default value is 0.0075
  118738. */
  118739. area: number;
  118740. /**
  118741. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  118742. * Must not be equal to area and inferior to area.
  118743. * Default value is 0.000001
  118744. */
  118745. fallOff: number;
  118746. /**
  118747. * The base color of the SSAO post-process
  118748. * The final result is "base + ssao" between [0, 1]
  118749. */
  118750. base: number;
  118751. private _scene;
  118752. private _depthTexture;
  118753. private _randomTexture;
  118754. private _originalColorPostProcess;
  118755. private _ssaoPostProcess;
  118756. private _blurHPostProcess;
  118757. private _blurVPostProcess;
  118758. private _ssaoCombinePostProcess;
  118759. private _firstUpdate;
  118760. /**
  118761. * Gets active scene
  118762. */
  118763. readonly scene: Scene;
  118764. /**
  118765. * @constructor
  118766. * @param name - The rendering pipeline name
  118767. * @param scene - The scene linked to this pipeline
  118768. * @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 }
  118769. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  118770. */
  118771. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118772. /**
  118773. * Get the class name
  118774. * @returns "SSAORenderingPipeline"
  118775. */
  118776. getClassName(): string;
  118777. /**
  118778. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118779. */
  118780. dispose(disableDepthRender?: boolean): void;
  118781. private _createBlurPostProcess;
  118782. /** @hidden */
  118783. _rebuild(): void;
  118784. private _createSSAOPostProcess;
  118785. private _createSSAOCombinePostProcess;
  118786. private _createRandomTexture;
  118787. }
  118788. }
  118789. declare module BABYLON {
  118790. /** @hidden */
  118791. export var standardPixelShader: {
  118792. name: string;
  118793. shader: string;
  118794. };
  118795. }
  118796. declare module BABYLON {
  118797. /**
  118798. * Standard rendering pipeline
  118799. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118800. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  118801. */
  118802. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118803. /**
  118804. * Public members
  118805. */
  118806. /**
  118807. * Post-process which contains the original scene color before the pipeline applies all the effects
  118808. */
  118809. originalPostProcess: Nullable<PostProcess>;
  118810. /**
  118811. * Post-process used to down scale an image x4
  118812. */
  118813. downSampleX4PostProcess: Nullable<PostProcess>;
  118814. /**
  118815. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  118816. */
  118817. brightPassPostProcess: Nullable<PostProcess>;
  118818. /**
  118819. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  118820. */
  118821. blurHPostProcesses: PostProcess[];
  118822. /**
  118823. * Post-process array storing all the vertical blur post-processes used by the pipeline
  118824. */
  118825. blurVPostProcesses: PostProcess[];
  118826. /**
  118827. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  118828. */
  118829. textureAdderPostProcess: Nullable<PostProcess>;
  118830. /**
  118831. * Post-process used to create volumetric lighting effect
  118832. */
  118833. volumetricLightPostProcess: Nullable<PostProcess>;
  118834. /**
  118835. * Post-process used to smooth the previous volumetric light post-process on the X axis
  118836. */
  118837. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  118838. /**
  118839. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  118840. */
  118841. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  118842. /**
  118843. * Post-process used to merge the volumetric light effect and the real scene color
  118844. */
  118845. volumetricLightMergePostProces: Nullable<PostProcess>;
  118846. /**
  118847. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  118848. */
  118849. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  118850. /**
  118851. * Base post-process used to calculate the average luminance of the final image for HDR
  118852. */
  118853. luminancePostProcess: Nullable<PostProcess>;
  118854. /**
  118855. * Post-processes used to create down sample post-processes in order to get
  118856. * the average luminance of the final image for HDR
  118857. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  118858. */
  118859. luminanceDownSamplePostProcesses: PostProcess[];
  118860. /**
  118861. * Post-process used to create a HDR effect (light adaptation)
  118862. */
  118863. hdrPostProcess: Nullable<PostProcess>;
  118864. /**
  118865. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  118866. */
  118867. textureAdderFinalPostProcess: Nullable<PostProcess>;
  118868. /**
  118869. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  118870. */
  118871. lensFlareFinalPostProcess: Nullable<PostProcess>;
  118872. /**
  118873. * Post-process used to merge the final HDR post-process and the real scene color
  118874. */
  118875. hdrFinalPostProcess: Nullable<PostProcess>;
  118876. /**
  118877. * Post-process used to create a lens flare effect
  118878. */
  118879. lensFlarePostProcess: Nullable<PostProcess>;
  118880. /**
  118881. * Post-process that merges the result of the lens flare post-process and the real scene color
  118882. */
  118883. lensFlareComposePostProcess: Nullable<PostProcess>;
  118884. /**
  118885. * Post-process used to create a motion blur effect
  118886. */
  118887. motionBlurPostProcess: Nullable<PostProcess>;
  118888. /**
  118889. * Post-process used to create a depth of field effect
  118890. */
  118891. depthOfFieldPostProcess: Nullable<PostProcess>;
  118892. /**
  118893. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118894. */
  118895. fxaaPostProcess: Nullable<FxaaPostProcess>;
  118896. /**
  118897. * Represents the brightness threshold in order to configure the illuminated surfaces
  118898. */
  118899. brightThreshold: number;
  118900. /**
  118901. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  118902. */
  118903. blurWidth: number;
  118904. /**
  118905. * Sets if the blur for highlighted surfaces must be only horizontal
  118906. */
  118907. horizontalBlur: boolean;
  118908. /**
  118909. * Gets the overall exposure used by the pipeline
  118910. */
  118911. /**
  118912. * Sets the overall exposure used by the pipeline
  118913. */
  118914. exposure: number;
  118915. /**
  118916. * Texture used typically to simulate "dirty" on camera lens
  118917. */
  118918. lensTexture: Nullable<Texture>;
  118919. /**
  118920. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  118921. */
  118922. volumetricLightCoefficient: number;
  118923. /**
  118924. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  118925. */
  118926. volumetricLightPower: number;
  118927. /**
  118928. * Used the set the blur intensity to smooth the volumetric lights
  118929. */
  118930. volumetricLightBlurScale: number;
  118931. /**
  118932. * Light (spot or directional) used to generate the volumetric lights rays
  118933. * The source light must have a shadow generate so the pipeline can get its
  118934. * depth map
  118935. */
  118936. sourceLight: Nullable<SpotLight | DirectionalLight>;
  118937. /**
  118938. * For eye adaptation, represents the minimum luminance the eye can see
  118939. */
  118940. hdrMinimumLuminance: number;
  118941. /**
  118942. * For eye adaptation, represents the decrease luminance speed
  118943. */
  118944. hdrDecreaseRate: number;
  118945. /**
  118946. * For eye adaptation, represents the increase luminance speed
  118947. */
  118948. hdrIncreaseRate: number;
  118949. /**
  118950. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118951. */
  118952. /**
  118953. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118954. */
  118955. hdrAutoExposure: boolean;
  118956. /**
  118957. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  118958. */
  118959. lensColorTexture: Nullable<Texture>;
  118960. /**
  118961. * The overall strengh for the lens flare effect
  118962. */
  118963. lensFlareStrength: number;
  118964. /**
  118965. * Dispersion coefficient for lens flare ghosts
  118966. */
  118967. lensFlareGhostDispersal: number;
  118968. /**
  118969. * Main lens flare halo width
  118970. */
  118971. lensFlareHaloWidth: number;
  118972. /**
  118973. * Based on the lens distortion effect, defines how much the lens flare result
  118974. * is distorted
  118975. */
  118976. lensFlareDistortionStrength: number;
  118977. /**
  118978. * Lens star texture must be used to simulate rays on the flares and is available
  118979. * in the documentation
  118980. */
  118981. lensStarTexture: Nullable<Texture>;
  118982. /**
  118983. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  118984. * flare effect by taking account of the dirt texture
  118985. */
  118986. lensFlareDirtTexture: Nullable<Texture>;
  118987. /**
  118988. * Represents the focal length for the depth of field effect
  118989. */
  118990. depthOfFieldDistance: number;
  118991. /**
  118992. * Represents the blur intensity for the blurred part of the depth of field effect
  118993. */
  118994. depthOfFieldBlurWidth: number;
  118995. /**
  118996. * Gets how much the image is blurred by the movement while using the motion blur post-process
  118997. */
  118998. /**
  118999. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119000. */
  119001. motionStrength: number;
  119002. /**
  119003. * Gets wether or not the motion blur post-process is object based or screen based.
  119004. */
  119005. /**
  119006. * Sets wether or not the motion blur post-process should be object based or screen based
  119007. */
  119008. objectBasedMotionBlur: boolean;
  119009. /**
  119010. * List of animations for the pipeline (IAnimatable implementation)
  119011. */
  119012. animations: Animation[];
  119013. /**
  119014. * Private members
  119015. */
  119016. private _scene;
  119017. private _currentDepthOfFieldSource;
  119018. private _basePostProcess;
  119019. private _fixedExposure;
  119020. private _currentExposure;
  119021. private _hdrAutoExposure;
  119022. private _hdrCurrentLuminance;
  119023. private _motionStrength;
  119024. private _isObjectBasedMotionBlur;
  119025. private _floatTextureType;
  119026. private _ratio;
  119027. private _bloomEnabled;
  119028. private _depthOfFieldEnabled;
  119029. private _vlsEnabled;
  119030. private _lensFlareEnabled;
  119031. private _hdrEnabled;
  119032. private _motionBlurEnabled;
  119033. private _fxaaEnabled;
  119034. private _motionBlurSamples;
  119035. private _volumetricLightStepsCount;
  119036. private _samples;
  119037. /**
  119038. * @ignore
  119039. * Specifies if the bloom pipeline is enabled
  119040. */
  119041. BloomEnabled: boolean;
  119042. /**
  119043. * @ignore
  119044. * Specifies if the depth of field pipeline is enabed
  119045. */
  119046. DepthOfFieldEnabled: boolean;
  119047. /**
  119048. * @ignore
  119049. * Specifies if the lens flare pipeline is enabed
  119050. */
  119051. LensFlareEnabled: boolean;
  119052. /**
  119053. * @ignore
  119054. * Specifies if the HDR pipeline is enabled
  119055. */
  119056. HDREnabled: boolean;
  119057. /**
  119058. * @ignore
  119059. * Specifies if the volumetric lights scattering effect is enabled
  119060. */
  119061. VLSEnabled: boolean;
  119062. /**
  119063. * @ignore
  119064. * Specifies if the motion blur effect is enabled
  119065. */
  119066. MotionBlurEnabled: boolean;
  119067. /**
  119068. * Specifies if anti-aliasing is enabled
  119069. */
  119070. fxaaEnabled: boolean;
  119071. /**
  119072. * Specifies the number of steps used to calculate the volumetric lights
  119073. * Typically in interval [50, 200]
  119074. */
  119075. volumetricLightStepsCount: number;
  119076. /**
  119077. * Specifies the number of samples used for the motion blur effect
  119078. * Typically in interval [16, 64]
  119079. */
  119080. motionBlurSamples: number;
  119081. /**
  119082. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119083. */
  119084. samples: number;
  119085. /**
  119086. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119087. * @constructor
  119088. * @param name The rendering pipeline name
  119089. * @param scene The scene linked to this pipeline
  119090. * @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)
  119091. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119092. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119093. */
  119094. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119095. private _buildPipeline;
  119096. private _createDownSampleX4PostProcess;
  119097. private _createBrightPassPostProcess;
  119098. private _createBlurPostProcesses;
  119099. private _createTextureAdderPostProcess;
  119100. private _createVolumetricLightPostProcess;
  119101. private _createLuminancePostProcesses;
  119102. private _createHdrPostProcess;
  119103. private _createLensFlarePostProcess;
  119104. private _createDepthOfFieldPostProcess;
  119105. private _createMotionBlurPostProcess;
  119106. private _getDepthTexture;
  119107. private _disposePostProcesses;
  119108. /**
  119109. * Dispose of the pipeline and stop all post processes
  119110. */
  119111. dispose(): void;
  119112. /**
  119113. * Serialize the rendering pipeline (Used when exporting)
  119114. * @returns the serialized object
  119115. */
  119116. serialize(): any;
  119117. /**
  119118. * Parse the serialized pipeline
  119119. * @param source Source pipeline.
  119120. * @param scene The scene to load the pipeline to.
  119121. * @param rootUrl The URL of the serialized pipeline.
  119122. * @returns An instantiated pipeline from the serialized object.
  119123. */
  119124. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119125. /**
  119126. * Luminance steps
  119127. */
  119128. static LuminanceSteps: number;
  119129. }
  119130. }
  119131. declare module BABYLON {
  119132. /** @hidden */
  119133. export var tonemapPixelShader: {
  119134. name: string;
  119135. shader: string;
  119136. };
  119137. }
  119138. declare module BABYLON {
  119139. /** Defines operator used for tonemapping */
  119140. export enum TonemappingOperator {
  119141. /** Hable */
  119142. Hable = 0,
  119143. /** Reinhard */
  119144. Reinhard = 1,
  119145. /** HejiDawson */
  119146. HejiDawson = 2,
  119147. /** Photographic */
  119148. Photographic = 3
  119149. }
  119150. /**
  119151. * Defines a post process to apply tone mapping
  119152. */
  119153. export class TonemapPostProcess extends PostProcess {
  119154. private _operator;
  119155. /** Defines the required exposure adjustement */
  119156. exposureAdjustment: number;
  119157. /**
  119158. * Creates a new TonemapPostProcess
  119159. * @param name defines the name of the postprocess
  119160. * @param _operator defines the operator to use
  119161. * @param exposureAdjustment defines the required exposure adjustement
  119162. * @param camera defines the camera to use (can be null)
  119163. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119164. * @param engine defines the hosting engine (can be ignore if camera is set)
  119165. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119166. */
  119167. constructor(name: string, _operator: TonemappingOperator,
  119168. /** Defines the required exposure adjustement */
  119169. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119170. }
  119171. }
  119172. declare module BABYLON {
  119173. /** @hidden */
  119174. export var depthVertexShader: {
  119175. name: string;
  119176. shader: string;
  119177. };
  119178. }
  119179. declare module BABYLON {
  119180. /** @hidden */
  119181. export var volumetricLightScatteringPixelShader: {
  119182. name: string;
  119183. shader: string;
  119184. };
  119185. }
  119186. declare module BABYLON {
  119187. /** @hidden */
  119188. export var volumetricLightScatteringPassPixelShader: {
  119189. name: string;
  119190. shader: string;
  119191. };
  119192. }
  119193. declare module BABYLON {
  119194. /**
  119195. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119196. */
  119197. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119198. private _volumetricLightScatteringPass;
  119199. private _volumetricLightScatteringRTT;
  119200. private _viewPort;
  119201. private _screenCoordinates;
  119202. private _cachedDefines;
  119203. /**
  119204. * If not undefined, the mesh position is computed from the attached node position
  119205. */
  119206. attachedNode: {
  119207. position: Vector3;
  119208. };
  119209. /**
  119210. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119211. */
  119212. customMeshPosition: Vector3;
  119213. /**
  119214. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119215. */
  119216. useCustomMeshPosition: boolean;
  119217. /**
  119218. * If the post-process should inverse the light scattering direction
  119219. */
  119220. invert: boolean;
  119221. /**
  119222. * The internal mesh used by the post-process
  119223. */
  119224. mesh: Mesh;
  119225. /**
  119226. * @hidden
  119227. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119228. */
  119229. useDiffuseColor: boolean;
  119230. /**
  119231. * Array containing the excluded meshes not rendered in the internal pass
  119232. */
  119233. excludedMeshes: AbstractMesh[];
  119234. /**
  119235. * Controls the overall intensity of the post-process
  119236. */
  119237. exposure: number;
  119238. /**
  119239. * Dissipates each sample's contribution in range [0, 1]
  119240. */
  119241. decay: number;
  119242. /**
  119243. * Controls the overall intensity of each sample
  119244. */
  119245. weight: number;
  119246. /**
  119247. * Controls the density of each sample
  119248. */
  119249. density: number;
  119250. /**
  119251. * @constructor
  119252. * @param name The post-process name
  119253. * @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)
  119254. * @param camera The camera that the post-process will be attached to
  119255. * @param mesh The mesh used to create the light scattering
  119256. * @param samples The post-process quality, default 100
  119257. * @param samplingModeThe post-process filtering mode
  119258. * @param engine The babylon engine
  119259. * @param reusable If the post-process is reusable
  119260. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  119261. */
  119262. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  119263. /**
  119264. * Returns the string "VolumetricLightScatteringPostProcess"
  119265. * @returns "VolumetricLightScatteringPostProcess"
  119266. */
  119267. getClassName(): string;
  119268. private _isReady;
  119269. /**
  119270. * Sets the new light position for light scattering effect
  119271. * @param position The new custom light position
  119272. */
  119273. setCustomMeshPosition(position: Vector3): void;
  119274. /**
  119275. * Returns the light position for light scattering effect
  119276. * @return Vector3 The custom light position
  119277. */
  119278. getCustomMeshPosition(): Vector3;
  119279. /**
  119280. * Disposes the internal assets and detaches the post-process from the camera
  119281. */
  119282. dispose(camera: Camera): void;
  119283. /**
  119284. * Returns the render target texture used by the post-process
  119285. * @return the render target texture used by the post-process
  119286. */
  119287. getPass(): RenderTargetTexture;
  119288. private _meshExcluded;
  119289. private _createPass;
  119290. private _updateMeshScreenCoordinates;
  119291. /**
  119292. * Creates a default mesh for the Volumeric Light Scattering post-process
  119293. * @param name The mesh name
  119294. * @param scene The scene where to create the mesh
  119295. * @return the default mesh
  119296. */
  119297. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  119298. }
  119299. }
  119300. declare module BABYLON {
  119301. interface Scene {
  119302. /** @hidden (Backing field) */
  119303. _boundingBoxRenderer: BoundingBoxRenderer;
  119304. /** @hidden (Backing field) */
  119305. _forceShowBoundingBoxes: boolean;
  119306. /**
  119307. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  119308. */
  119309. forceShowBoundingBoxes: boolean;
  119310. /**
  119311. * Gets the bounding box renderer associated with the scene
  119312. * @returns a BoundingBoxRenderer
  119313. */
  119314. getBoundingBoxRenderer(): BoundingBoxRenderer;
  119315. }
  119316. interface AbstractMesh {
  119317. /** @hidden (Backing field) */
  119318. _showBoundingBox: boolean;
  119319. /**
  119320. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  119321. */
  119322. showBoundingBox: boolean;
  119323. }
  119324. /**
  119325. * Component responsible of rendering the bounding box of the meshes in a scene.
  119326. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  119327. */
  119328. export class BoundingBoxRenderer implements ISceneComponent {
  119329. /**
  119330. * The component name helpfull to identify the component in the list of scene components.
  119331. */
  119332. readonly name: string;
  119333. /**
  119334. * The scene the component belongs to.
  119335. */
  119336. scene: Scene;
  119337. /**
  119338. * Color of the bounding box lines placed in front of an object
  119339. */
  119340. frontColor: Color3;
  119341. /**
  119342. * Color of the bounding box lines placed behind an object
  119343. */
  119344. backColor: Color3;
  119345. /**
  119346. * Defines if the renderer should show the back lines or not
  119347. */
  119348. showBackLines: boolean;
  119349. /**
  119350. * @hidden
  119351. */
  119352. renderList: SmartArray<BoundingBox>;
  119353. private _colorShader;
  119354. private _vertexBuffers;
  119355. private _indexBuffer;
  119356. private _fillIndexBuffer;
  119357. private _fillIndexData;
  119358. /**
  119359. * Instantiates a new bounding box renderer in a scene.
  119360. * @param scene the scene the renderer renders in
  119361. */
  119362. constructor(scene: Scene);
  119363. /**
  119364. * Registers the component in a given scene
  119365. */
  119366. register(): void;
  119367. private _evaluateSubMesh;
  119368. private _activeMesh;
  119369. private _prepareRessources;
  119370. private _createIndexBuffer;
  119371. /**
  119372. * Rebuilds the elements related to this component in case of
  119373. * context lost for instance.
  119374. */
  119375. rebuild(): void;
  119376. /**
  119377. * @hidden
  119378. */
  119379. reset(): void;
  119380. /**
  119381. * Render the bounding boxes of a specific rendering group
  119382. * @param renderingGroupId defines the rendering group to render
  119383. */
  119384. render(renderingGroupId: number): void;
  119385. /**
  119386. * In case of occlusion queries, we can render the occlusion bounding box through this method
  119387. * @param mesh Define the mesh to render the occlusion bounding box for
  119388. */
  119389. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  119390. /**
  119391. * Dispose and release the resources attached to this renderer.
  119392. */
  119393. dispose(): void;
  119394. }
  119395. }
  119396. declare module BABYLON {
  119397. /** @hidden */
  119398. export var depthPixelShader: {
  119399. name: string;
  119400. shader: string;
  119401. };
  119402. }
  119403. declare module BABYLON {
  119404. /**
  119405. * This represents a depth renderer in Babylon.
  119406. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  119407. */
  119408. export class DepthRenderer {
  119409. private _scene;
  119410. private _depthMap;
  119411. private _effect;
  119412. private _cachedDefines;
  119413. private _camera;
  119414. /**
  119415. * Specifiess that the depth renderer will only be used within
  119416. * the camera it is created for.
  119417. * This can help forcing its rendering during the camera processing.
  119418. */
  119419. useOnlyInActiveCamera: boolean;
  119420. /** @hidden */
  119421. static _SceneComponentInitialization: (scene: Scene) => void;
  119422. /**
  119423. * Instantiates a depth renderer
  119424. * @param scene The scene the renderer belongs to
  119425. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  119426. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  119427. */
  119428. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  119429. /**
  119430. * Creates the depth rendering effect and checks if the effect is ready.
  119431. * @param subMesh The submesh to be used to render the depth map of
  119432. * @param useInstances If multiple world instances should be used
  119433. * @returns if the depth renderer is ready to render the depth map
  119434. */
  119435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119436. /**
  119437. * Gets the texture which the depth map will be written to.
  119438. * @returns The depth map texture
  119439. */
  119440. getDepthMap(): RenderTargetTexture;
  119441. /**
  119442. * Disposes of the depth renderer.
  119443. */
  119444. dispose(): void;
  119445. }
  119446. }
  119447. declare module BABYLON {
  119448. interface Scene {
  119449. /** @hidden (Backing field) */
  119450. _depthRenderer: {
  119451. [id: string]: DepthRenderer;
  119452. };
  119453. /**
  119454. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  119455. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  119456. * @returns the created depth renderer
  119457. */
  119458. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  119459. /**
  119460. * Disables a depth renderer for a given camera
  119461. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  119462. */
  119463. disableDepthRenderer(camera?: Nullable<Camera>): void;
  119464. }
  119465. /**
  119466. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  119467. * in several rendering techniques.
  119468. */
  119469. export class DepthRendererSceneComponent implements ISceneComponent {
  119470. /**
  119471. * The component name helpfull to identify the component in the list of scene components.
  119472. */
  119473. readonly name: string;
  119474. /**
  119475. * The scene the component belongs to.
  119476. */
  119477. scene: Scene;
  119478. /**
  119479. * Creates a new instance of the component for the given scene
  119480. * @param scene Defines the scene to register the component in
  119481. */
  119482. constructor(scene: Scene);
  119483. /**
  119484. * Registers the component in a given scene
  119485. */
  119486. register(): void;
  119487. /**
  119488. * Rebuilds the elements related to this component in case of
  119489. * context lost for instance.
  119490. */
  119491. rebuild(): void;
  119492. /**
  119493. * Disposes the component and the associated ressources
  119494. */
  119495. dispose(): void;
  119496. private _gatherRenderTargets;
  119497. private _gatherActiveCameraRenderTargets;
  119498. }
  119499. }
  119500. declare module BABYLON {
  119501. /** @hidden */
  119502. export var outlinePixelShader: {
  119503. name: string;
  119504. shader: string;
  119505. };
  119506. }
  119507. declare module BABYLON {
  119508. /** @hidden */
  119509. export var outlineVertexShader: {
  119510. name: string;
  119511. shader: string;
  119512. };
  119513. }
  119514. declare module BABYLON {
  119515. interface Scene {
  119516. /** @hidden */
  119517. _outlineRenderer: OutlineRenderer;
  119518. /**
  119519. * Gets the outline renderer associated with the scene
  119520. * @returns a OutlineRenderer
  119521. */
  119522. getOutlineRenderer(): OutlineRenderer;
  119523. }
  119524. interface AbstractMesh {
  119525. /** @hidden (Backing field) */
  119526. _renderOutline: boolean;
  119527. /**
  119528. * Gets or sets a boolean indicating if the outline must be rendered as well
  119529. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  119530. */
  119531. renderOutline: boolean;
  119532. /** @hidden (Backing field) */
  119533. _renderOverlay: boolean;
  119534. /**
  119535. * Gets or sets a boolean indicating if the overlay must be rendered as well
  119536. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  119537. */
  119538. renderOverlay: boolean;
  119539. }
  119540. /**
  119541. * This class is responsible to draw bothe outline/overlay of meshes.
  119542. * It should not be used directly but through the available method on mesh.
  119543. */
  119544. export class OutlineRenderer implements ISceneComponent {
  119545. /**
  119546. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119547. */
  119548. private static _StencilReference;
  119549. /**
  119550. * The name of the component. Each component must have a unique name.
  119551. */
  119552. name: string;
  119553. /**
  119554. * The scene the component belongs to.
  119555. */
  119556. scene: Scene;
  119557. /**
  119558. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119559. */
  119560. zOffset: number;
  119561. private _engine;
  119562. private _effect;
  119563. private _cachedDefines;
  119564. private _savedDepthWrite;
  119565. /**
  119566. * Instantiates a new outline renderer. (There could be only one per scene).
  119567. * @param scene Defines the scene it belongs to
  119568. */
  119569. constructor(scene: Scene);
  119570. /**
  119571. * Register the component to one instance of a scene.
  119572. */
  119573. register(): void;
  119574. /**
  119575. * Rebuilds the elements related to this component in case of
  119576. * context lost for instance.
  119577. */
  119578. rebuild(): void;
  119579. /**
  119580. * Disposes the component and the associated ressources.
  119581. */
  119582. dispose(): void;
  119583. /**
  119584. * Renders the outline in the canvas.
  119585. * @param subMesh Defines the sumesh to render
  119586. * @param batch Defines the batch of meshes in case of instances
  119587. * @param useOverlay Defines if the rendering is for the overlay or the outline
  119588. */
  119589. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  119590. /**
  119591. * Returns whether or not the outline renderer is ready for a given submesh.
  119592. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  119593. * @param subMesh Defines the submesh to check readyness for
  119594. * @param useInstances Defines wheter wee are trying to render instances or not
  119595. * @returns true if ready otherwise false
  119596. */
  119597. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119598. private _beforeRenderingMesh;
  119599. private _afterRenderingMesh;
  119600. }
  119601. }
  119602. declare module BABYLON {
  119603. /**
  119604. * Defines the list of states available for a task inside a AssetsManager
  119605. */
  119606. export enum AssetTaskState {
  119607. /**
  119608. * Initialization
  119609. */
  119610. INIT = 0,
  119611. /**
  119612. * Running
  119613. */
  119614. RUNNING = 1,
  119615. /**
  119616. * Done
  119617. */
  119618. DONE = 2,
  119619. /**
  119620. * Error
  119621. */
  119622. ERROR = 3
  119623. }
  119624. /**
  119625. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  119626. */
  119627. export abstract class AbstractAssetTask {
  119628. /**
  119629. * Task name
  119630. */ name: string;
  119631. /**
  119632. * Callback called when the task is successful
  119633. */
  119634. onSuccess: (task: any) => void;
  119635. /**
  119636. * Callback called when the task is not successful
  119637. */
  119638. onError: (task: any, message?: string, exception?: any) => void;
  119639. /**
  119640. * Creates a new AssetsManager
  119641. * @param name defines the name of the task
  119642. */
  119643. constructor(
  119644. /**
  119645. * Task name
  119646. */ name: string);
  119647. private _isCompleted;
  119648. private _taskState;
  119649. private _errorObject;
  119650. /**
  119651. * Get if the task is completed
  119652. */
  119653. readonly isCompleted: boolean;
  119654. /**
  119655. * Gets the current state of the task
  119656. */
  119657. readonly taskState: AssetTaskState;
  119658. /**
  119659. * Gets the current error object (if task is in error)
  119660. */
  119661. readonly errorObject: {
  119662. message?: string;
  119663. exception?: any;
  119664. };
  119665. /**
  119666. * Internal only
  119667. * @hidden
  119668. */
  119669. _setErrorObject(message?: string, exception?: any): void;
  119670. /**
  119671. * Execute the current task
  119672. * @param scene defines the scene where you want your assets to be loaded
  119673. * @param onSuccess is a callback called when the task is successfully executed
  119674. * @param onError is a callback called if an error occurs
  119675. */
  119676. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119677. /**
  119678. * Execute the current task
  119679. * @param scene defines the scene where you want your assets to be loaded
  119680. * @param onSuccess is a callback called when the task is successfully executed
  119681. * @param onError is a callback called if an error occurs
  119682. */
  119683. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119684. /**
  119685. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  119686. * This can be used with failed tasks that have the reason for failure fixed.
  119687. */
  119688. reset(): void;
  119689. private onErrorCallback;
  119690. private onDoneCallback;
  119691. }
  119692. /**
  119693. * Define the interface used by progress events raised during assets loading
  119694. */
  119695. export interface IAssetsProgressEvent {
  119696. /**
  119697. * Defines the number of remaining tasks to process
  119698. */
  119699. remainingCount: number;
  119700. /**
  119701. * Defines the total number of tasks
  119702. */
  119703. totalCount: number;
  119704. /**
  119705. * Defines the task that was just processed
  119706. */
  119707. task: AbstractAssetTask;
  119708. }
  119709. /**
  119710. * Class used to share progress information about assets loading
  119711. */
  119712. export class AssetsProgressEvent implements IAssetsProgressEvent {
  119713. /**
  119714. * Defines the number of remaining tasks to process
  119715. */
  119716. remainingCount: number;
  119717. /**
  119718. * Defines the total number of tasks
  119719. */
  119720. totalCount: number;
  119721. /**
  119722. * Defines the task that was just processed
  119723. */
  119724. task: AbstractAssetTask;
  119725. /**
  119726. * Creates a AssetsProgressEvent
  119727. * @param remainingCount defines the number of remaining tasks to process
  119728. * @param totalCount defines the total number of tasks
  119729. * @param task defines the task that was just processed
  119730. */
  119731. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  119732. }
  119733. /**
  119734. * Define a task used by AssetsManager to load meshes
  119735. */
  119736. export class MeshAssetTask extends AbstractAssetTask {
  119737. /**
  119738. * Defines the name of the task
  119739. */
  119740. name: string;
  119741. /**
  119742. * Defines the list of mesh's names you want to load
  119743. */
  119744. meshesNames: any;
  119745. /**
  119746. * Defines the root url to use as a base to load your meshes and associated resources
  119747. */
  119748. rootUrl: string;
  119749. /**
  119750. * Defines the filename of the scene to load from
  119751. */
  119752. sceneFilename: string;
  119753. /**
  119754. * Gets the list of loaded meshes
  119755. */
  119756. loadedMeshes: Array<AbstractMesh>;
  119757. /**
  119758. * Gets the list of loaded particle systems
  119759. */
  119760. loadedParticleSystems: Array<IParticleSystem>;
  119761. /**
  119762. * Gets the list of loaded skeletons
  119763. */
  119764. loadedSkeletons: Array<Skeleton>;
  119765. /**
  119766. * Gets the list of loaded animation groups
  119767. */
  119768. loadedAnimationGroups: Array<AnimationGroup>;
  119769. /**
  119770. * Callback called when the task is successful
  119771. */
  119772. onSuccess: (task: MeshAssetTask) => void;
  119773. /**
  119774. * Callback called when the task is successful
  119775. */
  119776. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  119777. /**
  119778. * Creates a new MeshAssetTask
  119779. * @param name defines the name of the task
  119780. * @param meshesNames defines the list of mesh's names you want to load
  119781. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  119782. * @param sceneFilename defines the filename of the scene to load from
  119783. */
  119784. constructor(
  119785. /**
  119786. * Defines the name of the task
  119787. */
  119788. name: string,
  119789. /**
  119790. * Defines the list of mesh's names you want to load
  119791. */
  119792. meshesNames: any,
  119793. /**
  119794. * Defines the root url to use as a base to load your meshes and associated resources
  119795. */
  119796. rootUrl: string,
  119797. /**
  119798. * Defines the filename of the scene to load from
  119799. */
  119800. sceneFilename: string);
  119801. /**
  119802. * Execute the current task
  119803. * @param scene defines the scene where you want your assets to be loaded
  119804. * @param onSuccess is a callback called when the task is successfully executed
  119805. * @param onError is a callback called if an error occurs
  119806. */
  119807. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119808. }
  119809. /**
  119810. * Define a task used by AssetsManager to load text content
  119811. */
  119812. export class TextFileAssetTask extends AbstractAssetTask {
  119813. /**
  119814. * Defines the name of the task
  119815. */
  119816. name: string;
  119817. /**
  119818. * Defines the location of the file to load
  119819. */
  119820. url: string;
  119821. /**
  119822. * Gets the loaded text string
  119823. */
  119824. text: string;
  119825. /**
  119826. * Callback called when the task is successful
  119827. */
  119828. onSuccess: (task: TextFileAssetTask) => void;
  119829. /**
  119830. * Callback called when the task is successful
  119831. */
  119832. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  119833. /**
  119834. * Creates a new TextFileAssetTask object
  119835. * @param name defines the name of the task
  119836. * @param url defines the location of the file to load
  119837. */
  119838. constructor(
  119839. /**
  119840. * Defines the name of the task
  119841. */
  119842. name: string,
  119843. /**
  119844. * Defines the location of the file to load
  119845. */
  119846. url: string);
  119847. /**
  119848. * Execute the current task
  119849. * @param scene defines the scene where you want your assets to be loaded
  119850. * @param onSuccess is a callback called when the task is successfully executed
  119851. * @param onError is a callback called if an error occurs
  119852. */
  119853. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119854. }
  119855. /**
  119856. * Define a task used by AssetsManager to load binary data
  119857. */
  119858. export class BinaryFileAssetTask extends AbstractAssetTask {
  119859. /**
  119860. * Defines the name of the task
  119861. */
  119862. name: string;
  119863. /**
  119864. * Defines the location of the file to load
  119865. */
  119866. url: string;
  119867. /**
  119868. * Gets the lodaded data (as an array buffer)
  119869. */
  119870. data: ArrayBuffer;
  119871. /**
  119872. * Callback called when the task is successful
  119873. */
  119874. onSuccess: (task: BinaryFileAssetTask) => void;
  119875. /**
  119876. * Callback called when the task is successful
  119877. */
  119878. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  119879. /**
  119880. * Creates a new BinaryFileAssetTask object
  119881. * @param name defines the name of the new task
  119882. * @param url defines the location of the file to load
  119883. */
  119884. constructor(
  119885. /**
  119886. * Defines the name of the task
  119887. */
  119888. name: string,
  119889. /**
  119890. * Defines the location of the file to load
  119891. */
  119892. url: string);
  119893. /**
  119894. * Execute the current task
  119895. * @param scene defines the scene where you want your assets to be loaded
  119896. * @param onSuccess is a callback called when the task is successfully executed
  119897. * @param onError is a callback called if an error occurs
  119898. */
  119899. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119900. }
  119901. /**
  119902. * Define a task used by AssetsManager to load images
  119903. */
  119904. export class ImageAssetTask extends AbstractAssetTask {
  119905. /**
  119906. * Defines the name of the task
  119907. */
  119908. name: string;
  119909. /**
  119910. * Defines the location of the image to load
  119911. */
  119912. url: string;
  119913. /**
  119914. * Gets the loaded images
  119915. */
  119916. image: HTMLImageElement;
  119917. /**
  119918. * Callback called when the task is successful
  119919. */
  119920. onSuccess: (task: ImageAssetTask) => void;
  119921. /**
  119922. * Callback called when the task is successful
  119923. */
  119924. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  119925. /**
  119926. * Creates a new ImageAssetTask
  119927. * @param name defines the name of the task
  119928. * @param url defines the location of the image to load
  119929. */
  119930. constructor(
  119931. /**
  119932. * Defines the name of the task
  119933. */
  119934. name: string,
  119935. /**
  119936. * Defines the location of the image to load
  119937. */
  119938. url: string);
  119939. /**
  119940. * Execute the current task
  119941. * @param scene defines the scene where you want your assets to be loaded
  119942. * @param onSuccess is a callback called when the task is successfully executed
  119943. * @param onError is a callback called if an error occurs
  119944. */
  119945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119946. }
  119947. /**
  119948. * Defines the interface used by texture loading tasks
  119949. */
  119950. export interface ITextureAssetTask<TEX extends BaseTexture> {
  119951. /**
  119952. * Gets the loaded texture
  119953. */
  119954. texture: TEX;
  119955. }
  119956. /**
  119957. * Define a task used by AssetsManager to load 2D textures
  119958. */
  119959. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  119960. /**
  119961. * Defines the name of the task
  119962. */
  119963. name: string;
  119964. /**
  119965. * Defines the location of the file to load
  119966. */
  119967. url: string;
  119968. /**
  119969. * Defines if mipmap should not be generated (default is false)
  119970. */
  119971. noMipmap?: boolean | undefined;
  119972. /**
  119973. * Defines if texture must be inverted on Y axis (default is false)
  119974. */
  119975. invertY?: boolean | undefined;
  119976. /**
  119977. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119978. */
  119979. samplingMode: number;
  119980. /**
  119981. * Gets the loaded texture
  119982. */
  119983. texture: Texture;
  119984. /**
  119985. * Callback called when the task is successful
  119986. */
  119987. onSuccess: (task: TextureAssetTask) => void;
  119988. /**
  119989. * Callback called when the task is successful
  119990. */
  119991. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  119992. /**
  119993. * Creates a new TextureAssetTask object
  119994. * @param name defines the name of the task
  119995. * @param url defines the location of the file to load
  119996. * @param noMipmap defines if mipmap should not be generated (default is false)
  119997. * @param invertY defines if texture must be inverted on Y axis (default is false)
  119998. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119999. */
  120000. constructor(
  120001. /**
  120002. * Defines the name of the task
  120003. */
  120004. name: string,
  120005. /**
  120006. * Defines the location of the file to load
  120007. */
  120008. url: string,
  120009. /**
  120010. * Defines if mipmap should not be generated (default is false)
  120011. */
  120012. noMipmap?: boolean | undefined,
  120013. /**
  120014. * Defines if texture must be inverted on Y axis (default is false)
  120015. */
  120016. invertY?: boolean | undefined,
  120017. /**
  120018. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120019. */
  120020. samplingMode?: number);
  120021. /**
  120022. * Execute the current task
  120023. * @param scene defines the scene where you want your assets to be loaded
  120024. * @param onSuccess is a callback called when the task is successfully executed
  120025. * @param onError is a callback called if an error occurs
  120026. */
  120027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120028. }
  120029. /**
  120030. * Define a task used by AssetsManager to load cube textures
  120031. */
  120032. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120033. /**
  120034. * Defines the name of the task
  120035. */
  120036. name: string;
  120037. /**
  120038. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120039. */
  120040. url: string;
  120041. /**
  120042. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120043. */
  120044. extensions?: string[] | undefined;
  120045. /**
  120046. * Defines if mipmaps should not be generated (default is false)
  120047. */
  120048. noMipmap?: boolean | undefined;
  120049. /**
  120050. * Defines the explicit list of files (undefined by default)
  120051. */
  120052. files?: string[] | undefined;
  120053. /**
  120054. * Gets the loaded texture
  120055. */
  120056. texture: CubeTexture;
  120057. /**
  120058. * Callback called when the task is successful
  120059. */
  120060. onSuccess: (task: CubeTextureAssetTask) => void;
  120061. /**
  120062. * Callback called when the task is successful
  120063. */
  120064. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120065. /**
  120066. * Creates a new CubeTextureAssetTask
  120067. * @param name defines the name of the task
  120068. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120069. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120070. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120071. * @param files defines the explicit list of files (undefined by default)
  120072. */
  120073. constructor(
  120074. /**
  120075. * Defines the name of the task
  120076. */
  120077. name: string,
  120078. /**
  120079. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120080. */
  120081. url: string,
  120082. /**
  120083. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120084. */
  120085. extensions?: string[] | undefined,
  120086. /**
  120087. * Defines if mipmaps should not be generated (default is false)
  120088. */
  120089. noMipmap?: boolean | undefined,
  120090. /**
  120091. * Defines the explicit list of files (undefined by default)
  120092. */
  120093. files?: string[] | undefined);
  120094. /**
  120095. * Execute the current task
  120096. * @param scene defines the scene where you want your assets to be loaded
  120097. * @param onSuccess is a callback called when the task is successfully executed
  120098. * @param onError is a callback called if an error occurs
  120099. */
  120100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120101. }
  120102. /**
  120103. * Define a task used by AssetsManager to load HDR cube textures
  120104. */
  120105. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120106. /**
  120107. * Defines the name of the task
  120108. */
  120109. name: string;
  120110. /**
  120111. * Defines the location of the file to load
  120112. */
  120113. url: string;
  120114. /**
  120115. * Defines the desired size (the more it increases the longer the generation will be)
  120116. */
  120117. size: number;
  120118. /**
  120119. * Defines if mipmaps should not be generated (default is false)
  120120. */
  120121. noMipmap: boolean;
  120122. /**
  120123. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120124. */
  120125. generateHarmonics: boolean;
  120126. /**
  120127. * 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)
  120128. */
  120129. gammaSpace: boolean;
  120130. /**
  120131. * Internal Use Only
  120132. */
  120133. reserved: boolean;
  120134. /**
  120135. * Gets the loaded texture
  120136. */
  120137. texture: HDRCubeTexture;
  120138. /**
  120139. * Callback called when the task is successful
  120140. */
  120141. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120142. /**
  120143. * Callback called when the task is successful
  120144. */
  120145. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120146. /**
  120147. * Creates a new HDRCubeTextureAssetTask object
  120148. * @param name defines the name of the task
  120149. * @param url defines the location of the file to load
  120150. * @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.
  120151. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120152. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120153. * @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)
  120154. * @param reserved Internal use only
  120155. */
  120156. constructor(
  120157. /**
  120158. * Defines the name of the task
  120159. */
  120160. name: string,
  120161. /**
  120162. * Defines the location of the file to load
  120163. */
  120164. url: string,
  120165. /**
  120166. * Defines the desired size (the more it increases the longer the generation will be)
  120167. */
  120168. size: number,
  120169. /**
  120170. * Defines if mipmaps should not be generated (default is false)
  120171. */
  120172. noMipmap?: boolean,
  120173. /**
  120174. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120175. */
  120176. generateHarmonics?: boolean,
  120177. /**
  120178. * 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)
  120179. */
  120180. gammaSpace?: boolean,
  120181. /**
  120182. * Internal Use Only
  120183. */
  120184. reserved?: boolean);
  120185. /**
  120186. * Execute the current task
  120187. * @param scene defines the scene where you want your assets to be loaded
  120188. * @param onSuccess is a callback called when the task is successfully executed
  120189. * @param onError is a callback called if an error occurs
  120190. */
  120191. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120192. }
  120193. /**
  120194. * Define a task used by AssetsManager to load Equirectangular cube textures
  120195. */
  120196. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120197. /**
  120198. * Defines the name of the task
  120199. */
  120200. name: string;
  120201. /**
  120202. * Defines the location of the file to load
  120203. */
  120204. url: string;
  120205. /**
  120206. * Defines the desired size (the more it increases the longer the generation will be)
  120207. */
  120208. size: number;
  120209. /**
  120210. * Defines if mipmaps should not be generated (default is false)
  120211. */
  120212. noMipmap: boolean;
  120213. /**
  120214. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120215. * but the standard material would require them in Gamma space) (default is true)
  120216. */
  120217. gammaSpace: boolean;
  120218. /**
  120219. * Gets the loaded texture
  120220. */
  120221. texture: EquiRectangularCubeTexture;
  120222. /**
  120223. * Callback called when the task is successful
  120224. */
  120225. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120226. /**
  120227. * Callback called when the task is successful
  120228. */
  120229. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120230. /**
  120231. * Creates a new EquiRectangularCubeTextureAssetTask object
  120232. * @param name defines the name of the task
  120233. * @param url defines the location of the file to load
  120234. * @param size defines the desired size (the more it increases the longer the generation will be)
  120235. * If the size is omitted this implies you are using a preprocessed cubemap.
  120236. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120237. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120238. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120239. * (default is true)
  120240. */
  120241. constructor(
  120242. /**
  120243. * Defines the name of the task
  120244. */
  120245. name: string,
  120246. /**
  120247. * Defines the location of the file to load
  120248. */
  120249. url: string,
  120250. /**
  120251. * Defines the desired size (the more it increases the longer the generation will be)
  120252. */
  120253. size: number,
  120254. /**
  120255. * Defines if mipmaps should not be generated (default is false)
  120256. */
  120257. noMipmap?: boolean,
  120258. /**
  120259. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120260. * but the standard material would require them in Gamma space) (default is true)
  120261. */
  120262. gammaSpace?: boolean);
  120263. /**
  120264. * Execute the current task
  120265. * @param scene defines the scene where you want your assets to be loaded
  120266. * @param onSuccess is a callback called when the task is successfully executed
  120267. * @param onError is a callback called if an error occurs
  120268. */
  120269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120270. }
  120271. /**
  120272. * This class can be used to easily import assets into a scene
  120273. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  120274. */
  120275. export class AssetsManager {
  120276. private _scene;
  120277. private _isLoading;
  120278. protected _tasks: AbstractAssetTask[];
  120279. protected _waitingTasksCount: number;
  120280. protected _totalTasksCount: number;
  120281. /**
  120282. * Callback called when all tasks are processed
  120283. */
  120284. onFinish: (tasks: AbstractAssetTask[]) => void;
  120285. /**
  120286. * Callback called when a task is successful
  120287. */
  120288. onTaskSuccess: (task: AbstractAssetTask) => void;
  120289. /**
  120290. * Callback called when a task had an error
  120291. */
  120292. onTaskError: (task: AbstractAssetTask) => void;
  120293. /**
  120294. * Callback called when a task is done (whatever the result is)
  120295. */
  120296. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  120297. /**
  120298. * Observable called when all tasks are processed
  120299. */
  120300. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  120301. /**
  120302. * Observable called when a task had an error
  120303. */
  120304. onTaskErrorObservable: Observable<AbstractAssetTask>;
  120305. /**
  120306. * Observable called when all tasks were executed
  120307. */
  120308. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  120309. /**
  120310. * Observable called when a task is done (whatever the result is)
  120311. */
  120312. onProgressObservable: Observable<IAssetsProgressEvent>;
  120313. /**
  120314. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  120315. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  120316. */
  120317. useDefaultLoadingScreen: boolean;
  120318. /**
  120319. * Creates a new AssetsManager
  120320. * @param scene defines the scene to work on
  120321. */
  120322. constructor(scene: Scene);
  120323. /**
  120324. * Add a MeshAssetTask to the list of active tasks
  120325. * @param taskName defines the name of the new task
  120326. * @param meshesNames defines the name of meshes to load
  120327. * @param rootUrl defines the root url to use to locate files
  120328. * @param sceneFilename defines the filename of the scene file
  120329. * @returns a new MeshAssetTask object
  120330. */
  120331. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  120332. /**
  120333. * Add a TextFileAssetTask to the list of active tasks
  120334. * @param taskName defines the name of the new task
  120335. * @param url defines the url of the file to load
  120336. * @returns a new TextFileAssetTask object
  120337. */
  120338. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  120339. /**
  120340. * Add a BinaryFileAssetTask to the list of active tasks
  120341. * @param taskName defines the name of the new task
  120342. * @param url defines the url of the file to load
  120343. * @returns a new BinaryFileAssetTask object
  120344. */
  120345. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  120346. /**
  120347. * Add a ImageAssetTask to the list of active tasks
  120348. * @param taskName defines the name of the new task
  120349. * @param url defines the url of the file to load
  120350. * @returns a new ImageAssetTask object
  120351. */
  120352. addImageTask(taskName: string, url: string): ImageAssetTask;
  120353. /**
  120354. * Add a TextureAssetTask to the list of active tasks
  120355. * @param taskName defines the name of the new task
  120356. * @param url defines the url of the file to load
  120357. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120358. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  120359. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  120360. * @returns a new TextureAssetTask object
  120361. */
  120362. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  120363. /**
  120364. * Add a CubeTextureAssetTask to the list of active tasks
  120365. * @param taskName defines the name of the new task
  120366. * @param url defines the url of the file to load
  120367. * @param extensions defines the extension to use to load the cube map (can be null)
  120368. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120369. * @param files defines the list of files to load (can be null)
  120370. * @returns a new CubeTextureAssetTask object
  120371. */
  120372. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  120373. /**
  120374. *
  120375. * Add a HDRCubeTextureAssetTask to the list of active tasks
  120376. * @param taskName defines the name of the new task
  120377. * @param url defines the url of the file to load
  120378. * @param size defines the size you want for the cubemap (can be null)
  120379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120380. * @param generateHarmonics defines if you want to automatically generate (true by default)
  120381. * @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)
  120382. * @param reserved Internal use only
  120383. * @returns a new HDRCubeTextureAssetTask object
  120384. */
  120385. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  120386. /**
  120387. *
  120388. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  120389. * @param taskName defines the name of the new task
  120390. * @param url defines the url of the file to load
  120391. * @param size defines the size you want for the cubemap (can be null)
  120392. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  120393. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  120394. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  120395. * @returns a new EquiRectangularCubeTextureAssetTask object
  120396. */
  120397. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  120398. /**
  120399. * Remove a task from the assets manager.
  120400. * @param task the task to remove
  120401. */
  120402. removeTask(task: AbstractAssetTask): void;
  120403. private _decreaseWaitingTasksCount;
  120404. private _runTask;
  120405. /**
  120406. * Reset the AssetsManager and remove all tasks
  120407. * @return the current instance of the AssetsManager
  120408. */
  120409. reset(): AssetsManager;
  120410. /**
  120411. * Start the loading process
  120412. * @return the current instance of the AssetsManager
  120413. */
  120414. load(): AssetsManager;
  120415. /**
  120416. * Start the loading process as an async operation
  120417. * @return a promise returning the list of failed tasks
  120418. */
  120419. loadAsync(): Promise<void>;
  120420. }
  120421. }
  120422. declare module BABYLON {
  120423. /**
  120424. * Wrapper class for promise with external resolve and reject.
  120425. */
  120426. export class Deferred<T> {
  120427. /**
  120428. * The promise associated with this deferred object.
  120429. */
  120430. readonly promise: Promise<T>;
  120431. private _resolve;
  120432. private _reject;
  120433. /**
  120434. * The resolve method of the promise associated with this deferred object.
  120435. */
  120436. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  120437. /**
  120438. * The reject method of the promise associated with this deferred object.
  120439. */
  120440. readonly reject: (reason?: any) => void;
  120441. /**
  120442. * Constructor for this deferred object.
  120443. */
  120444. constructor();
  120445. }
  120446. }
  120447. declare module BABYLON {
  120448. /**
  120449. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  120450. */
  120451. export class MeshExploder {
  120452. private _centerMesh;
  120453. private _meshes;
  120454. private _meshesOrigins;
  120455. private _toCenterVectors;
  120456. private _scaledDirection;
  120457. private _newPosition;
  120458. private _centerPosition;
  120459. /**
  120460. * Explodes meshes from a center mesh.
  120461. * @param meshes The meshes to explode.
  120462. * @param centerMesh The mesh to be center of explosion.
  120463. */
  120464. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  120465. private _setCenterMesh;
  120466. /**
  120467. * Get class name
  120468. * @returns "MeshExploder"
  120469. */
  120470. getClassName(): string;
  120471. /**
  120472. * "Exploded meshes"
  120473. * @returns Array of meshes with the centerMesh at index 0.
  120474. */
  120475. getMeshes(): Array<Mesh>;
  120476. /**
  120477. * Explodes meshes giving a specific direction
  120478. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  120479. */
  120480. explode(direction?: number): void;
  120481. }
  120482. }
  120483. declare module BABYLON {
  120484. /**
  120485. * Class used to help managing file picking and drag'n'drop
  120486. */
  120487. export class FilesInput {
  120488. /**
  120489. * List of files ready to be loaded
  120490. */
  120491. static readonly FilesToLoad: {
  120492. [key: string]: File;
  120493. };
  120494. /**
  120495. * Callback called when a file is processed
  120496. */
  120497. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  120498. private _engine;
  120499. private _currentScene;
  120500. private _sceneLoadedCallback;
  120501. private _progressCallback;
  120502. private _additionalRenderLoopLogicCallback;
  120503. private _textureLoadingCallback;
  120504. private _startingProcessingFilesCallback;
  120505. private _onReloadCallback;
  120506. private _errorCallback;
  120507. private _elementToMonitor;
  120508. private _sceneFileToLoad;
  120509. private _filesToLoad;
  120510. /**
  120511. * Creates a new FilesInput
  120512. * @param engine defines the rendering engine
  120513. * @param scene defines the hosting scene
  120514. * @param sceneLoadedCallback callback called when scene is loaded
  120515. * @param progressCallback callback called to track progress
  120516. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  120517. * @param textureLoadingCallback callback called when a texture is loading
  120518. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  120519. * @param onReloadCallback callback called when a reload is requested
  120520. * @param errorCallback callback call if an error occurs
  120521. */
  120522. 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);
  120523. private _dragEnterHandler;
  120524. private _dragOverHandler;
  120525. private _dropHandler;
  120526. /**
  120527. * Calls this function to listen to drag'n'drop events on a specific DOM element
  120528. * @param elementToMonitor defines the DOM element to track
  120529. */
  120530. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  120531. /**
  120532. * Release all associated resources
  120533. */
  120534. dispose(): void;
  120535. private renderFunction;
  120536. private drag;
  120537. private drop;
  120538. private _traverseFolder;
  120539. private _processFiles;
  120540. /**
  120541. * Load files from a drop event
  120542. * @param event defines the drop event to use as source
  120543. */
  120544. loadFiles(event: any): void;
  120545. private _processReload;
  120546. /**
  120547. * Reload the current scene from the loaded files
  120548. */
  120549. reload(): void;
  120550. }
  120551. }
  120552. declare module BABYLON {
  120553. /**
  120554. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120555. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120556. */
  120557. export class SceneOptimization {
  120558. /**
  120559. * Defines the priority of this optimization (0 by default which means first in the list)
  120560. */
  120561. priority: number;
  120562. /**
  120563. * Gets a string describing the action executed by the current optimization
  120564. * @returns description string
  120565. */
  120566. getDescription(): string;
  120567. /**
  120568. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120569. * @param scene defines the current scene where to apply this optimization
  120570. * @param optimizer defines the current optimizer
  120571. * @returns true if everything that can be done was applied
  120572. */
  120573. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120574. /**
  120575. * Creates the SceneOptimization object
  120576. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120577. * @param desc defines the description associated with the optimization
  120578. */
  120579. constructor(
  120580. /**
  120581. * Defines the priority of this optimization (0 by default which means first in the list)
  120582. */
  120583. priority?: number);
  120584. }
  120585. /**
  120586. * Defines an optimization used to reduce the size of render target textures
  120587. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120588. */
  120589. export class TextureOptimization extends SceneOptimization {
  120590. /**
  120591. * Defines the priority of this optimization (0 by default which means first in the list)
  120592. */
  120593. priority: number;
  120594. /**
  120595. * 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
  120596. */
  120597. maximumSize: number;
  120598. /**
  120599. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120600. */
  120601. step: number;
  120602. /**
  120603. * Gets a string describing the action executed by the current optimization
  120604. * @returns description string
  120605. */
  120606. getDescription(): string;
  120607. /**
  120608. * Creates the TextureOptimization object
  120609. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120610. * @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
  120611. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120612. */
  120613. constructor(
  120614. /**
  120615. * Defines the priority of this optimization (0 by default which means first in the list)
  120616. */
  120617. priority?: number,
  120618. /**
  120619. * 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
  120620. */
  120621. maximumSize?: number,
  120622. /**
  120623. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120624. */
  120625. step?: number);
  120626. /**
  120627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120628. * @param scene defines the current scene where to apply this optimization
  120629. * @param optimizer defines the current optimizer
  120630. * @returns true if everything that can be done was applied
  120631. */
  120632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120633. }
  120634. /**
  120635. * Defines an optimization used to increase or decrease the rendering resolution
  120636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120637. */
  120638. export class HardwareScalingOptimization extends SceneOptimization {
  120639. /**
  120640. * Defines the priority of this optimization (0 by default which means first in the list)
  120641. */
  120642. priority: number;
  120643. /**
  120644. * Defines the maximum scale to use (2 by default)
  120645. */
  120646. maximumScale: number;
  120647. /**
  120648. * Defines the step to use between two passes (0.5 by default)
  120649. */
  120650. step: number;
  120651. private _currentScale;
  120652. private _directionOffset;
  120653. /**
  120654. * Gets a string describing the action executed by the current optimization
  120655. * @return description string
  120656. */
  120657. getDescription(): string;
  120658. /**
  120659. * Creates the HardwareScalingOptimization object
  120660. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120661. * @param maximumScale defines the maximum scale to use (2 by default)
  120662. * @param step defines the step to use between two passes (0.5 by default)
  120663. */
  120664. constructor(
  120665. /**
  120666. * Defines the priority of this optimization (0 by default which means first in the list)
  120667. */
  120668. priority?: number,
  120669. /**
  120670. * Defines the maximum scale to use (2 by default)
  120671. */
  120672. maximumScale?: number,
  120673. /**
  120674. * Defines the step to use between two passes (0.5 by default)
  120675. */
  120676. step?: number);
  120677. /**
  120678. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120679. * @param scene defines the current scene where to apply this optimization
  120680. * @param optimizer defines the current optimizer
  120681. * @returns true if everything that can be done was applied
  120682. */
  120683. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120684. }
  120685. /**
  120686. * Defines an optimization used to remove shadows
  120687. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120688. */
  120689. export class ShadowsOptimization extends SceneOptimization {
  120690. /**
  120691. * Gets a string describing the action executed by the current optimization
  120692. * @return description string
  120693. */
  120694. getDescription(): string;
  120695. /**
  120696. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120697. * @param scene defines the current scene where to apply this optimization
  120698. * @param optimizer defines the current optimizer
  120699. * @returns true if everything that can be done was applied
  120700. */
  120701. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120702. }
  120703. /**
  120704. * Defines an optimization used to turn post-processes off
  120705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120706. */
  120707. export class PostProcessesOptimization extends SceneOptimization {
  120708. /**
  120709. * Gets a string describing the action executed by the current optimization
  120710. * @return description string
  120711. */
  120712. getDescription(): string;
  120713. /**
  120714. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120715. * @param scene defines the current scene where to apply this optimization
  120716. * @param optimizer defines the current optimizer
  120717. * @returns true if everything that can be done was applied
  120718. */
  120719. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120720. }
  120721. /**
  120722. * Defines an optimization used to turn lens flares off
  120723. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120724. */
  120725. export class LensFlaresOptimization extends SceneOptimization {
  120726. /**
  120727. * Gets a string describing the action executed by the current optimization
  120728. * @return description string
  120729. */
  120730. getDescription(): string;
  120731. /**
  120732. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120733. * @param scene defines the current scene where to apply this optimization
  120734. * @param optimizer defines the current optimizer
  120735. * @returns true if everything that can be done was applied
  120736. */
  120737. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120738. }
  120739. /**
  120740. * Defines an optimization based on user defined callback.
  120741. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120742. */
  120743. export class CustomOptimization extends SceneOptimization {
  120744. /**
  120745. * Callback called to apply the custom optimization.
  120746. */
  120747. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  120748. /**
  120749. * Callback called to get custom description
  120750. */
  120751. onGetDescription: () => string;
  120752. /**
  120753. * Gets a string describing the action executed by the current optimization
  120754. * @returns description string
  120755. */
  120756. getDescription(): string;
  120757. /**
  120758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120759. * @param scene defines the current scene where to apply this optimization
  120760. * @param optimizer defines the current optimizer
  120761. * @returns true if everything that can be done was applied
  120762. */
  120763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120764. }
  120765. /**
  120766. * Defines an optimization used to turn particles off
  120767. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120768. */
  120769. export class ParticlesOptimization extends SceneOptimization {
  120770. /**
  120771. * Gets a string describing the action executed by the current optimization
  120772. * @return description string
  120773. */
  120774. getDescription(): string;
  120775. /**
  120776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120777. * @param scene defines the current scene where to apply this optimization
  120778. * @param optimizer defines the current optimizer
  120779. * @returns true if everything that can be done was applied
  120780. */
  120781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120782. }
  120783. /**
  120784. * Defines an optimization used to turn render targets off
  120785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120786. */
  120787. export class RenderTargetsOptimization extends SceneOptimization {
  120788. /**
  120789. * Gets a string describing the action executed by the current optimization
  120790. * @return description string
  120791. */
  120792. getDescription(): string;
  120793. /**
  120794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120795. * @param scene defines the current scene where to apply this optimization
  120796. * @param optimizer defines the current optimizer
  120797. * @returns true if everything that can be done was applied
  120798. */
  120799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120800. }
  120801. /**
  120802. * Defines an optimization used to merge meshes with compatible materials
  120803. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120804. */
  120805. export class MergeMeshesOptimization extends SceneOptimization {
  120806. private static _UpdateSelectionTree;
  120807. /**
  120808. * Gets or sets a boolean which defines if optimization octree has to be updated
  120809. */
  120810. /**
  120811. * Gets or sets a boolean which defines if optimization octree has to be updated
  120812. */
  120813. static UpdateSelectionTree: boolean;
  120814. /**
  120815. * Gets a string describing the action executed by the current optimization
  120816. * @return description string
  120817. */
  120818. getDescription(): string;
  120819. private _canBeMerged;
  120820. /**
  120821. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120822. * @param scene defines the current scene where to apply this optimization
  120823. * @param optimizer defines the current optimizer
  120824. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  120825. * @returns true if everything that can be done was applied
  120826. */
  120827. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  120828. }
  120829. /**
  120830. * Defines a list of options used by SceneOptimizer
  120831. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120832. */
  120833. export class SceneOptimizerOptions {
  120834. /**
  120835. * Defines the target frame rate to reach (60 by default)
  120836. */
  120837. targetFrameRate: number;
  120838. /**
  120839. * Defines the interval between two checkes (2000ms by default)
  120840. */
  120841. trackerDuration: number;
  120842. /**
  120843. * Gets the list of optimizations to apply
  120844. */
  120845. optimizations: SceneOptimization[];
  120846. /**
  120847. * Creates a new list of options used by SceneOptimizer
  120848. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  120849. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  120850. */
  120851. constructor(
  120852. /**
  120853. * Defines the target frame rate to reach (60 by default)
  120854. */
  120855. targetFrameRate?: number,
  120856. /**
  120857. * Defines the interval between two checkes (2000ms by default)
  120858. */
  120859. trackerDuration?: number);
  120860. /**
  120861. * Add a new optimization
  120862. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  120863. * @returns the current SceneOptimizerOptions
  120864. */
  120865. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  120866. /**
  120867. * Add a new custom optimization
  120868. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  120869. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  120870. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120871. * @returns the current SceneOptimizerOptions
  120872. */
  120873. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  120874. /**
  120875. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  120876. * @param targetFrameRate defines the target frame rate (60 by default)
  120877. * @returns a SceneOptimizerOptions object
  120878. */
  120879. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120880. /**
  120881. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  120882. * @param targetFrameRate defines the target frame rate (60 by default)
  120883. * @returns a SceneOptimizerOptions object
  120884. */
  120885. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120886. /**
  120887. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  120888. * @param targetFrameRate defines the target frame rate (60 by default)
  120889. * @returns a SceneOptimizerOptions object
  120890. */
  120891. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120892. }
  120893. /**
  120894. * Class used to run optimizations in order to reach a target frame rate
  120895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120896. */
  120897. export class SceneOptimizer implements IDisposable {
  120898. private _isRunning;
  120899. private _options;
  120900. private _scene;
  120901. private _currentPriorityLevel;
  120902. private _targetFrameRate;
  120903. private _trackerDuration;
  120904. private _currentFrameRate;
  120905. private _sceneDisposeObserver;
  120906. private _improvementMode;
  120907. /**
  120908. * Defines an observable called when the optimizer reaches the target frame rate
  120909. */
  120910. onSuccessObservable: Observable<SceneOptimizer>;
  120911. /**
  120912. * Defines an observable called when the optimizer enables an optimization
  120913. */
  120914. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  120915. /**
  120916. * Defines an observable called when the optimizer is not able to reach the target frame rate
  120917. */
  120918. onFailureObservable: Observable<SceneOptimizer>;
  120919. /**
  120920. * Gets a boolean indicating if the optimizer is in improvement mode
  120921. */
  120922. readonly isInImprovementMode: boolean;
  120923. /**
  120924. * Gets the current priority level (0 at start)
  120925. */
  120926. readonly currentPriorityLevel: number;
  120927. /**
  120928. * Gets the current frame rate checked by the SceneOptimizer
  120929. */
  120930. readonly currentFrameRate: number;
  120931. /**
  120932. * Gets or sets the current target frame rate (60 by default)
  120933. */
  120934. /**
  120935. * Gets or sets the current target frame rate (60 by default)
  120936. */
  120937. targetFrameRate: number;
  120938. /**
  120939. * Gets or sets the current interval between two checks (every 2000ms by default)
  120940. */
  120941. /**
  120942. * Gets or sets the current interval between two checks (every 2000ms by default)
  120943. */
  120944. trackerDuration: number;
  120945. /**
  120946. * Gets the list of active optimizations
  120947. */
  120948. readonly optimizations: SceneOptimization[];
  120949. /**
  120950. * Creates a new SceneOptimizer
  120951. * @param scene defines the scene to work on
  120952. * @param options defines the options to use with the SceneOptimizer
  120953. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  120954. * @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)
  120955. */
  120956. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  120957. /**
  120958. * Stops the current optimizer
  120959. */
  120960. stop(): void;
  120961. /**
  120962. * Reset the optimizer to initial step (current priority level = 0)
  120963. */
  120964. reset(): void;
  120965. /**
  120966. * Start the optimizer. By default it will try to reach a specific framerate
  120967. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  120968. */
  120969. start(): void;
  120970. private _checkCurrentState;
  120971. /**
  120972. * Release all resources
  120973. */
  120974. dispose(): void;
  120975. /**
  120976. * Helper function to create a SceneOptimizer with one single line of code
  120977. * @param scene defines the scene to work on
  120978. * @param options defines the options to use with the SceneOptimizer
  120979. * @param onSuccess defines a callback to call on success
  120980. * @param onFailure defines a callback to call on failure
  120981. * @returns the new SceneOptimizer object
  120982. */
  120983. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. /**
  120988. * Class used to serialize a scene into a string
  120989. */
  120990. export class SceneSerializer {
  120991. /**
  120992. * Clear cache used by a previous serialization
  120993. */
  120994. static ClearCache(): void;
  120995. /**
  120996. * Serialize a scene into a JSON compatible object
  120997. * @param scene defines the scene to serialize
  120998. * @returns a JSON compatible object
  120999. */
  121000. static Serialize(scene: Scene): any;
  121001. /**
  121002. * Serialize a mesh into a JSON compatible object
  121003. * @param toSerialize defines the mesh to serialize
  121004. * @param withParents defines if parents must be serialized as well
  121005. * @param withChildren defines if children must be serialized as well
  121006. * @returns a JSON compatible object
  121007. */
  121008. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121009. }
  121010. }
  121011. declare module BABYLON {
  121012. /**
  121013. * Class used to host texture specific utilities
  121014. */
  121015. export class TextureTools {
  121016. /**
  121017. * Uses the GPU to create a copy texture rescaled at a given size
  121018. * @param texture Texture to copy from
  121019. * @param width defines the desired width
  121020. * @param height defines the desired height
  121021. * @param useBilinearMode defines if bilinear mode has to be used
  121022. * @return the generated texture
  121023. */
  121024. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121025. }
  121026. }
  121027. declare module BABYLON {
  121028. /**
  121029. * This represents the different options avilable for the video capture.
  121030. */
  121031. export interface VideoRecorderOptions {
  121032. /** Defines the mime type of the video */
  121033. mimeType: string;
  121034. /** Defines the video the video should be recorded at */
  121035. fps: number;
  121036. /** Defines the chunk size for the recording data */
  121037. recordChunckSize: number;
  121038. /** The audio tracks to attach to the record */
  121039. audioTracks?: MediaStreamTrack[];
  121040. }
  121041. /**
  121042. * This can helps recording videos from BabylonJS.
  121043. * This is based on the available WebRTC functionalities of the browser.
  121044. *
  121045. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121046. */
  121047. export class VideoRecorder {
  121048. private static readonly _defaultOptions;
  121049. /**
  121050. * Returns wehther or not the VideoRecorder is available in your browser.
  121051. * @param engine Defines the Babylon Engine to check the support for
  121052. * @returns true if supported otherwise false
  121053. */
  121054. static IsSupported(engine: Engine): boolean;
  121055. private readonly _options;
  121056. private _canvas;
  121057. private _mediaRecorder;
  121058. private _recordedChunks;
  121059. private _fileName;
  121060. private _resolve;
  121061. private _reject;
  121062. /**
  121063. * True wether a recording is already in progress.
  121064. */
  121065. readonly isRecording: boolean;
  121066. /**
  121067. * Create a new VideoCapture object which can help converting what you see in Babylon to
  121068. * a video file.
  121069. * @param engine Defines the BabylonJS Engine you wish to record
  121070. * @param options Defines options that can be used to customized the capture
  121071. */
  121072. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121073. /**
  121074. * Stops the current recording before the default capture timeout passed in the startRecording
  121075. * functions.
  121076. */
  121077. stopRecording(): void;
  121078. /**
  121079. * Starts recording the canvas for a max duration specified in parameters.
  121080. * @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.
  121081. * @param maxDuration Defines the maximum recording time in seconds.
  121082. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121083. * @return a promise callback at the end of the recording with the video data in Blob.
  121084. */
  121085. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121086. /**
  121087. * Releases internal resources used during the recording.
  121088. */
  121089. dispose(): void;
  121090. private _handleDataAvailable;
  121091. private _handleError;
  121092. private _handleStop;
  121093. }
  121094. }
  121095. declare module BABYLON {
  121096. /**
  121097. * Class containing a set of static utilities functions for screenshots
  121098. */
  121099. export class ScreenshotTools {
  121100. /**
  121101. * Captures a screenshot of the current rendering
  121102. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121103. * @param engine defines the rendering engine
  121104. * @param camera defines the source camera
  121105. * @param size This parameter can be set to a single number or to an object with the
  121106. * following (optional) properties: precision, width, height. If a single number is passed,
  121107. * it will be used for both width and height. If an object is passed, the screenshot size
  121108. * will be derived from the parameters. The precision property is a multiplier allowing
  121109. * rendering at a higher or lower resolution
  121110. * @param successCallback defines the callback receives a single parameter which contains the
  121111. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121112. * src parameter of an <img> to display it
  121113. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121114. * Check your browser for supported MIME types
  121115. */
  121116. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121117. /**
  121118. * Generates an image screenshot from the specified camera.
  121119. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121120. * @param engine The engine to use for rendering
  121121. * @param camera The camera to use for rendering
  121122. * @param size This parameter can be set to a single number or to an object with the
  121123. * following (optional) properties: precision, width, height. If a single number is passed,
  121124. * it will be used for both width and height. If an object is passed, the screenshot size
  121125. * will be derived from the parameters. The precision property is a multiplier allowing
  121126. * rendering at a higher or lower resolution
  121127. * @param successCallback The callback receives a single parameter which contains the
  121128. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121129. * src parameter of an <img> to display it
  121130. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121131. * Check your browser for supported MIME types
  121132. * @param samples Texture samples (default: 1)
  121133. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121134. * @param fileName A name for for the downloaded file.
  121135. */
  121136. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121137. }
  121138. }
  121139. declare module BABYLON {
  121140. /**
  121141. * A cursor which tracks a point on a path
  121142. */
  121143. export class PathCursor {
  121144. private path;
  121145. /**
  121146. * Stores path cursor callbacks for when an onchange event is triggered
  121147. */
  121148. private _onchange;
  121149. /**
  121150. * The value of the path cursor
  121151. */
  121152. value: number;
  121153. /**
  121154. * The animation array of the path cursor
  121155. */
  121156. animations: Animation[];
  121157. /**
  121158. * Initializes the path cursor
  121159. * @param path The path to track
  121160. */
  121161. constructor(path: Path2);
  121162. /**
  121163. * Gets the cursor point on the path
  121164. * @returns A point on the path cursor at the cursor location
  121165. */
  121166. getPoint(): Vector3;
  121167. /**
  121168. * Moves the cursor ahead by the step amount
  121169. * @param step The amount to move the cursor forward
  121170. * @returns This path cursor
  121171. */
  121172. moveAhead(step?: number): PathCursor;
  121173. /**
  121174. * Moves the cursor behind by the step amount
  121175. * @param step The amount to move the cursor back
  121176. * @returns This path cursor
  121177. */
  121178. moveBack(step?: number): PathCursor;
  121179. /**
  121180. * Moves the cursor by the step amount
  121181. * If the step amount is greater than one, an exception is thrown
  121182. * @param step The amount to move the cursor
  121183. * @returns This path cursor
  121184. */
  121185. move(step: number): PathCursor;
  121186. /**
  121187. * Ensures that the value is limited between zero and one
  121188. * @returns This path cursor
  121189. */
  121190. private ensureLimits;
  121191. /**
  121192. * Runs onchange callbacks on change (used by the animation engine)
  121193. * @returns This path cursor
  121194. */
  121195. private raiseOnChange;
  121196. /**
  121197. * Executes a function on change
  121198. * @param f A path cursor onchange callback
  121199. * @returns This path cursor
  121200. */
  121201. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121202. }
  121203. }
  121204. declare module BABYLON {
  121205. /** @hidden */
  121206. export var blurPixelShader: {
  121207. name: string;
  121208. shader: string;
  121209. };
  121210. }
  121211. declare module BABYLON {
  121212. /** @hidden */
  121213. export var bones300Declaration: {
  121214. name: string;
  121215. shader: string;
  121216. };
  121217. }
  121218. declare module BABYLON {
  121219. /** @hidden */
  121220. export var instances300Declaration: {
  121221. name: string;
  121222. shader: string;
  121223. };
  121224. }
  121225. declare module BABYLON {
  121226. /** @hidden */
  121227. export var pointCloudVertexDeclaration: {
  121228. name: string;
  121229. shader: string;
  121230. };
  121231. }
  121232. // Mixins
  121233. interface Window {
  121234. mozIndexedDB: IDBFactory;
  121235. webkitIndexedDB: IDBFactory;
  121236. msIndexedDB: IDBFactory;
  121237. webkitURL: typeof URL;
  121238. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121239. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121240. WebGLRenderingContext: WebGLRenderingContext;
  121241. MSGesture: MSGesture;
  121242. CANNON: any;
  121243. AudioContext: AudioContext;
  121244. webkitAudioContext: AudioContext;
  121245. PointerEvent: any;
  121246. Math: Math;
  121247. Uint8Array: Uint8ArrayConstructor;
  121248. Float32Array: Float32ArrayConstructor;
  121249. mozURL: typeof URL;
  121250. msURL: typeof URL;
  121251. VRFrameData: any; // WebVR, from specs 1.1
  121252. DracoDecoderModule: any;
  121253. setImmediate(handler: (...args: any[]) => void): number;
  121254. }
  121255. interface HTMLCanvasElement {
  121256. requestPointerLock(): void;
  121257. msRequestPointerLock?(): void;
  121258. mozRequestPointerLock?(): void;
  121259. webkitRequestPointerLock?(): void;
  121260. /** Track wether a record is in progress */
  121261. isRecording: boolean;
  121262. /** Capture Stream method defined by some browsers */
  121263. captureStream(fps?: number): MediaStream;
  121264. }
  121265. interface CanvasRenderingContext2D {
  121266. msImageSmoothingEnabled: boolean;
  121267. }
  121268. interface MouseEvent {
  121269. mozMovementX: number;
  121270. mozMovementY: number;
  121271. webkitMovementX: number;
  121272. webkitMovementY: number;
  121273. msMovementX: number;
  121274. msMovementY: number;
  121275. }
  121276. interface Navigator {
  121277. mozGetVRDevices: (any: any) => any;
  121278. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121279. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121280. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  121281. webkitGetGamepads(): Gamepad[];
  121282. msGetGamepads(): Gamepad[];
  121283. webkitGamepads(): Gamepad[];
  121284. }
  121285. interface HTMLVideoElement {
  121286. mozSrcObject: any;
  121287. }
  121288. interface Math {
  121289. fround(x: number): number;
  121290. imul(a: number, b: number): number;
  121291. }
  121292. interface WebGLRenderingContext {
  121293. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  121294. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  121295. vertexAttribDivisor(index: number, divisor: number): void;
  121296. createVertexArray(): any;
  121297. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  121298. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  121299. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  121300. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  121301. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  121302. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  121303. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  121304. // Queries
  121305. createQuery(): WebGLQuery;
  121306. deleteQuery(query: WebGLQuery): void;
  121307. beginQuery(target: number, query: WebGLQuery): void;
  121308. endQuery(target: number): void;
  121309. getQueryParameter(query: WebGLQuery, pname: number): any;
  121310. getQuery(target: number, pname: number): any;
  121311. MAX_SAMPLES: number;
  121312. RGBA8: number;
  121313. READ_FRAMEBUFFER: number;
  121314. DRAW_FRAMEBUFFER: number;
  121315. UNIFORM_BUFFER: number;
  121316. HALF_FLOAT_OES: number;
  121317. RGBA16F: number;
  121318. RGBA32F: number;
  121319. R32F: number;
  121320. RG32F: number;
  121321. RGB32F: number;
  121322. R16F: number;
  121323. RG16F: number;
  121324. RGB16F: number;
  121325. RED: number;
  121326. RG: number;
  121327. R8: number;
  121328. RG8: number;
  121329. UNSIGNED_INT_24_8: number;
  121330. DEPTH24_STENCIL8: number;
  121331. /* Multiple Render Targets */
  121332. drawBuffers(buffers: number[]): void;
  121333. readBuffer(src: number): void;
  121334. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  121335. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  121336. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  121337. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  121338. // Occlusion Query
  121339. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  121340. ANY_SAMPLES_PASSED: number;
  121341. QUERY_RESULT_AVAILABLE: number;
  121342. QUERY_RESULT: number;
  121343. }
  121344. interface WebGLProgram {
  121345. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  121346. }
  121347. interface EXT_disjoint_timer_query {
  121348. QUERY_COUNTER_BITS_EXT: number;
  121349. TIME_ELAPSED_EXT: number;
  121350. TIMESTAMP_EXT: number;
  121351. GPU_DISJOINT_EXT: number;
  121352. QUERY_RESULT_EXT: number;
  121353. QUERY_RESULT_AVAILABLE_EXT: number;
  121354. queryCounterEXT(query: WebGLQuery, target: number): void;
  121355. createQueryEXT(): WebGLQuery;
  121356. beginQueryEXT(target: number, query: WebGLQuery): void;
  121357. endQueryEXT(target: number): void;
  121358. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  121359. deleteQueryEXT(query: WebGLQuery): void;
  121360. }
  121361. interface WebGLUniformLocation {
  121362. _currentState: any;
  121363. }
  121364. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  121365. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  121366. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  121367. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121368. interface WebGLRenderingContext {
  121369. readonly RASTERIZER_DISCARD: number;
  121370. readonly DEPTH_COMPONENT24: number;
  121371. readonly TEXTURE_3D: number;
  121372. readonly TEXTURE_2D_ARRAY: number;
  121373. readonly TEXTURE_COMPARE_FUNC: number;
  121374. readonly TEXTURE_COMPARE_MODE: number;
  121375. readonly COMPARE_REF_TO_TEXTURE: number;
  121376. readonly TEXTURE_WRAP_R: number;
  121377. readonly HALF_FLOAT: number;
  121378. readonly RGB8: number;
  121379. readonly RED_INTEGER: number;
  121380. readonly RG_INTEGER: number;
  121381. readonly RGB_INTEGER: number;
  121382. readonly RGBA_INTEGER: number;
  121383. readonly R8_SNORM: number;
  121384. readonly RG8_SNORM: number;
  121385. readonly RGB8_SNORM: number;
  121386. readonly RGBA8_SNORM: number;
  121387. readonly R8I: number;
  121388. readonly RG8I: number;
  121389. readonly RGB8I: number;
  121390. readonly RGBA8I: number;
  121391. readonly R8UI: number;
  121392. readonly RG8UI: number;
  121393. readonly RGB8UI: number;
  121394. readonly RGBA8UI: number;
  121395. readonly R16I: number;
  121396. readonly RG16I: number;
  121397. readonly RGB16I: number;
  121398. readonly RGBA16I: number;
  121399. readonly R16UI: number;
  121400. readonly RG16UI: number;
  121401. readonly RGB16UI: number;
  121402. readonly RGBA16UI: number;
  121403. readonly R32I: number;
  121404. readonly RG32I: number;
  121405. readonly RGB32I: number;
  121406. readonly RGBA32I: number;
  121407. readonly R32UI: number;
  121408. readonly RG32UI: number;
  121409. readonly RGB32UI: number;
  121410. readonly RGBA32UI: number;
  121411. readonly RGB10_A2UI: number;
  121412. readonly R11F_G11F_B10F: number;
  121413. readonly RGB9_E5: number;
  121414. readonly RGB10_A2: number;
  121415. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  121416. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  121417. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  121418. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121419. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  121420. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  121421. 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;
  121422. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  121423. readonly TRANSFORM_FEEDBACK: number;
  121424. readonly INTERLEAVED_ATTRIBS: number;
  121425. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  121426. createTransformFeedback(): WebGLTransformFeedback;
  121427. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  121428. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  121429. beginTransformFeedback(primitiveMode: number): void;
  121430. endTransformFeedback(): void;
  121431. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  121432. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121433. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121434. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  121435. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  121436. }
  121437. interface ImageBitmap {
  121438. readonly width: number;
  121439. readonly height: number;
  121440. close(): void;
  121441. }
  121442. interface WebGLQuery extends WebGLObject {
  121443. }
  121444. declare var WebGLQuery: {
  121445. prototype: WebGLQuery;
  121446. new(): WebGLQuery;
  121447. };
  121448. interface WebGLSampler extends WebGLObject {
  121449. }
  121450. declare var WebGLSampler: {
  121451. prototype: WebGLSampler;
  121452. new(): WebGLSampler;
  121453. };
  121454. interface WebGLSync extends WebGLObject {
  121455. }
  121456. declare var WebGLSync: {
  121457. prototype: WebGLSync;
  121458. new(): WebGLSync;
  121459. };
  121460. interface WebGLTransformFeedback extends WebGLObject {
  121461. }
  121462. declare var WebGLTransformFeedback: {
  121463. prototype: WebGLTransformFeedback;
  121464. new(): WebGLTransformFeedback;
  121465. };
  121466. interface WebGLVertexArrayObject extends WebGLObject {
  121467. }
  121468. declare var WebGLVertexArrayObject: {
  121469. prototype: WebGLVertexArrayObject;
  121470. new(): WebGLVertexArrayObject;
  121471. };
  121472. // Type definitions for WebVR API
  121473. // Project: https://w3c.github.io/webvr/
  121474. // Definitions by: six a <https://github.com/lostfictions>
  121475. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  121476. interface VRDisplay extends EventTarget {
  121477. /**
  121478. * Dictionary of capabilities describing the VRDisplay.
  121479. */
  121480. readonly capabilities: VRDisplayCapabilities;
  121481. /**
  121482. * z-depth defining the far plane of the eye view frustum
  121483. * enables mapping of values in the render target depth
  121484. * attachment to scene coordinates. Initially set to 10000.0.
  121485. */
  121486. depthFar: number;
  121487. /**
  121488. * z-depth defining the near plane of the eye view frustum
  121489. * enables mapping of values in the render target depth
  121490. * attachment to scene coordinates. Initially set to 0.01.
  121491. */
  121492. depthNear: number;
  121493. /**
  121494. * An identifier for this distinct VRDisplay. Used as an
  121495. * association point in the Gamepad API.
  121496. */
  121497. readonly displayId: number;
  121498. /**
  121499. * A display name, a user-readable name identifying it.
  121500. */
  121501. readonly displayName: string;
  121502. readonly isConnected: boolean;
  121503. readonly isPresenting: boolean;
  121504. /**
  121505. * If this VRDisplay supports room-scale experiences, the optional
  121506. * stage attribute contains details on the room-scale parameters.
  121507. */
  121508. readonly stageParameters: VRStageParameters | null;
  121509. /**
  121510. * Passing the value returned by `requestAnimationFrame` to
  121511. * `cancelAnimationFrame` will unregister the callback.
  121512. * @param handle Define the hanle of the request to cancel
  121513. */
  121514. cancelAnimationFrame(handle: number): void;
  121515. /**
  121516. * Stops presenting to the VRDisplay.
  121517. * @returns a promise to know when it stopped
  121518. */
  121519. exitPresent(): Promise<void>;
  121520. /**
  121521. * Return the current VREyeParameters for the given eye.
  121522. * @param whichEye Define the eye we want the parameter for
  121523. * @returns the eye parameters
  121524. */
  121525. getEyeParameters(whichEye: string): VREyeParameters;
  121526. /**
  121527. * Populates the passed VRFrameData with the information required to render
  121528. * the current frame.
  121529. * @param frameData Define the data structure to populate
  121530. * @returns true if ok otherwise false
  121531. */
  121532. getFrameData(frameData: VRFrameData): boolean;
  121533. /**
  121534. * Get the layers currently being presented.
  121535. * @returns the list of VR layers
  121536. */
  121537. getLayers(): VRLayer[];
  121538. /**
  121539. * Return a VRPose containing the future predicted pose of the VRDisplay
  121540. * when the current frame will be presented. The value returned will not
  121541. * change until JavaScript has returned control to the browser.
  121542. *
  121543. * The VRPose will contain the position, orientation, velocity,
  121544. * and acceleration of each of these properties.
  121545. * @returns the pose object
  121546. */
  121547. getPose(): VRPose;
  121548. /**
  121549. * Return the current instantaneous pose of the VRDisplay, with no
  121550. * prediction applied.
  121551. * @returns the current instantaneous pose
  121552. */
  121553. getImmediatePose(): VRPose;
  121554. /**
  121555. * The callback passed to `requestAnimationFrame` will be called
  121556. * any time a new frame should be rendered. When the VRDisplay is
  121557. * presenting the callback will be called at the native refresh
  121558. * rate of the HMD. When not presenting this function acts
  121559. * identically to how window.requestAnimationFrame acts. Content should
  121560. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121561. * asynchronously from other displays and at differing refresh rates.
  121562. * @param callback Define the eaction to run next frame
  121563. * @returns the request handle it
  121564. */
  121565. requestAnimationFrame(callback: FrameRequestCallback): number;
  121566. /**
  121567. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121568. * Repeat calls while already presenting will update the VRLayers being displayed.
  121569. * @param layers Define the list of layer to present
  121570. * @returns a promise to know when the request has been fulfilled
  121571. */
  121572. requestPresent(layers: VRLayer[]): Promise<void>;
  121573. /**
  121574. * Reset the pose for this display, treating its current position and
  121575. * orientation as the "origin/zero" values. VRPose.position,
  121576. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  121577. * updated when calling resetPose(). This should be called in only
  121578. * sitting-space experiences.
  121579. */
  121580. resetPose(): void;
  121581. /**
  121582. * The VRLayer provided to the VRDisplay will be captured and presented
  121583. * in the HMD. Calling this function has the same effect on the source
  121584. * canvas as any other operation that uses its source image, and canvases
  121585. * created without preserveDrawingBuffer set to true will be cleared.
  121586. * @param pose Define the pose to submit
  121587. */
  121588. submitFrame(pose?: VRPose): void;
  121589. }
  121590. declare var VRDisplay: {
  121591. prototype: VRDisplay;
  121592. new(): VRDisplay;
  121593. };
  121594. interface VRLayer {
  121595. leftBounds?: number[] | Float32Array | null;
  121596. rightBounds?: number[] | Float32Array | null;
  121597. source?: HTMLCanvasElement | null;
  121598. }
  121599. interface VRDisplayCapabilities {
  121600. readonly canPresent: boolean;
  121601. readonly hasExternalDisplay: boolean;
  121602. readonly hasOrientation: boolean;
  121603. readonly hasPosition: boolean;
  121604. readonly maxLayers: number;
  121605. }
  121606. interface VREyeParameters {
  121607. /** @deprecated */
  121608. readonly fieldOfView: VRFieldOfView;
  121609. readonly offset: Float32Array;
  121610. readonly renderHeight: number;
  121611. readonly renderWidth: number;
  121612. }
  121613. interface VRFieldOfView {
  121614. readonly downDegrees: number;
  121615. readonly leftDegrees: number;
  121616. readonly rightDegrees: number;
  121617. readonly upDegrees: number;
  121618. }
  121619. interface VRFrameData {
  121620. readonly leftProjectionMatrix: Float32Array;
  121621. readonly leftViewMatrix: Float32Array;
  121622. readonly pose: VRPose;
  121623. readonly rightProjectionMatrix: Float32Array;
  121624. readonly rightViewMatrix: Float32Array;
  121625. readonly timestamp: number;
  121626. }
  121627. interface VRPose {
  121628. readonly angularAcceleration: Float32Array | null;
  121629. readonly angularVelocity: Float32Array | null;
  121630. readonly linearAcceleration: Float32Array | null;
  121631. readonly linearVelocity: Float32Array | null;
  121632. readonly orientation: Float32Array | null;
  121633. readonly position: Float32Array | null;
  121634. readonly timestamp: number;
  121635. }
  121636. interface VRStageParameters {
  121637. sittingToStandingTransform?: Float32Array;
  121638. sizeX?: number;
  121639. sizeY?: number;
  121640. }
  121641. interface Navigator {
  121642. getVRDisplays(): Promise<VRDisplay[]>;
  121643. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  121644. }
  121645. interface Window {
  121646. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  121647. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  121648. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  121649. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121650. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121651. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  121652. }
  121653. interface Gamepad {
  121654. readonly displayId: number;
  121655. }
  121656. interface XRDevice {
  121657. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  121658. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  121659. }
  121660. interface XRSession {
  121661. getInputSources(): Array<any>;
  121662. baseLayer: XRWebGLLayer;
  121663. requestFrameOfReference(type: string): Promise<void>;
  121664. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  121665. end(): Promise<void>;
  121666. requestAnimationFrame: Function;
  121667. addEventListener: Function;
  121668. }
  121669. interface XRSessionCreationOptions {
  121670. outputContext?: WebGLRenderingContext | null;
  121671. immersive?: boolean;
  121672. environmentIntegration?: boolean;
  121673. }
  121674. interface XRLayer {
  121675. getViewport: Function;
  121676. framebufferWidth: number;
  121677. framebufferHeight: number;
  121678. }
  121679. interface XRView {
  121680. projectionMatrix: Float32Array;
  121681. }
  121682. interface XRFrame {
  121683. getDevicePose: Function;
  121684. getInputPose: Function;
  121685. views: Array<XRView>;
  121686. baseLayer: XRLayer;
  121687. }
  121688. interface XRFrameOfReference {
  121689. }
  121690. interface XRWebGLLayer extends XRLayer {
  121691. framebuffer: WebGLFramebuffer;
  121692. }
  121693. declare var XRWebGLLayer: {
  121694. prototype: XRWebGLLayer;
  121695. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  121696. };